> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Account types

> Classify accounts to enforce Ledger structure, validate transactions, and align account behavior with your business rules.

[**Account Types**](/en/reference/midaz/create-an-account-type) in Midaz allow you to systematically classify accounts according to your organization's financial structure needs. These classifications define the nature and purpose of accounts within your ledger design, enabling proper transaction routing and operational validation across different account categories.

Account Types can be customized via the Account Types API to match your specific business requirements and financial workflows, providing the foundation for structured transaction processing while maintaining data integrity.

### Enabling Account Type validation

Account Type validation is enabled per-ledger through the [Ledger Settings API](/en/midaz/ledgers#ledger-settings). To activate it, send a `PATCH` request to the Ledger Settings endpoint:

<CodeGroup>
  ```json PATCH /v1/organizations/{org_id}/ledgers/{ledger_id}/settings theme={null}
  {
    "accounting": {
      "validateAccountType": true
    }
  }
  ```
</CodeGroup>

<Tip>
  Settings changes take effect immediately — no redeployment required. You can update them at any time via the API.
</Tip>

### Behavior of the `type` field in Accounts API

When creating an Account, the `type` field behavior adapts based on the activation of the Account Type Validation feature:

* **Account Type Validation** **Disabled (Default):** The `type` field is optional and accepts any free-form string.
* **Account Type Validation Enabled:** The `type` field becomes **mandatory** and must match one of the Account Types previously registered via the Account Types API. If an invalid or non-registered type is submitted, the system will return a validation error.

<Tip>
  If your organization is enabling the Account Type Validation feature, we recommend reviewing existing accounts. You may need to either recreate them or retroactively assign the appropriate Account Type to align with your accounting structure.
</Tip>

This dynamic ensures that every account aligns with the formal accounting categories required by your business, strengthening governance and financial reporting.

### The `keyValue` field

<Note>
  The `keyValue` field identifies an Account Type and has the following constraints:

  * **Immutable:** `keyValue` is set at creation time and cannot be changed afterward. The Update Account Type endpoint does not accept this field.
  * **Unique per ledger:** Each `keyValue` must be unique within a given ledger.
  * **Used for type validation:** When `validateAccountType` is enabled in Ledger Settings, the `type` field of any Account must exactly match one of the registered `keyValue` strings. Accounts created with an unregistered `type` value will be rejected.
</Note>

## Managing Account Types

***

***

You can manage your Account Types exclusively via API.

* [Create an Account Type](/en/reference/midaz/create-an-account-type) — Register a new Account Type for your Ledger.
* [List Account Types](/en/reference/midaz/list-account-types) — Retrieve all Account Types configured in your Ledger.
* [Retrieve an Account Type](/en/reference/midaz/retrieve-an-account-type) — Get detailed information about a specific Account Type.
* [Update an Account Type](/en/reference/midaz/update-an-account-type) — Modify the definition of an existing Account Type.
* [Delete an Account Type](/en/reference/midaz/delete-an-account-type) — Remove an Account Type that is no longer in use.
