> For the complete documentation index, see [llms.txt](https://ledgera.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ledgera.gitbook.io/api/setup/chart-of-accounts.md).

# Chart of Accounts

The Chart of Accounts is where a classification of account description, type of balance, type of account, numeric code, and a hierarchy between accounts is determined, indicating whether this account will have an analytical or synthetic balance - grouping balances of its child accounts.

The use of the hierarchy between accounts, creating a synthetic chart of accounts is optional, depending on the client's choice.

{% hint style="danger" %} <mark style="color:red;">The presence of a chart of accounts configuration is a requirement for the balance sheet to function in the Operation Module and many reports</mark>
{% endhint %}

## Creation or Update of chart of accounts rule <a href="#creation-or-update-of-chart-of-accounts-rule" id="creation-or-update-of-chart-of-accounts-rule"></a>

The PUT /chart\_of\_accounts method is used to register a chart of accounts rule or update an already existing one. The system will validade the unicity on account description and balance type.

The method will receive a mapping list with the following fields in each record:

| Field                | Description                                                                                                                              |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| description          | Unique account description freely created by the user                                                                                    |
| balance\_type        | Type of balance to be mapped. Types can be available, pending and blocked                                                                |
| type                 | Type of account to be mapped. Types can be asset, liability, equity, revenue and expense                                                 |
| code\_number         | Standard numeric code (as string) of the accounting chosen by the user                                                                   |
| parent\_code\_number | Standard numerical accounting code (as a string) for the synthetic account that will add up the balances of this account. Optional field |

Example of creating/updating chart of accounts rules:

```json
PUT /chart_of_accounts

{
  "data": [
    {
      "description": "digital_account",
      "balance_type": "available",
      "type": "liability",
      "code_number": "2.1.1",
      "parent_code_number": "2.1"
    },
    {
      "description": "cash",
      "balance_type": "available",
      "type": "asset",
      "code_number": "1.1",
      "parent_code_number": "1"
    },
  ]
}
```

## Delete chart of accounts rules <a href="#delete-chart-of-accounts-rules" id="delete-chart-of-accounts-rules"></a>

The DELETE /chart\_of\_accounts method is used to delete a chart of accounts rule individually. The system will receive the account description and balance type for the target rule.

Example of chart of accounts rule delete:

```json
DELETE /chart_of_accounts?description=<description>&balance_type=<balance_type>
```

## Query chart of accounts <a href="#query-chart-of-accounts" id="query-chart-of-accounts"></a>

The GET /chart\_of\_accounts method is used to query the chart of accounts.

Example of chart of accounts query:

```json
GET /chart_of_accounts
```

Example response:

```json
{
  "data": [
    {
      "description": "digital_account",
      "balance_type": "available",
      "type": "liability",
      "code_number": "2.1.1",
      "parent_code_number": "2.1"
    },
    {
      "description": "cash",
      "balance_type": "available",
      "type": "asset",
      "code_number": "1.1",
      "parent_code_number": "1"
    },
  ]
}
```
