> ## 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

> Register Account Types to enforce classification per Ledger, validate the type field on account creation, and align account behavior with your accounting rules.

Account Types classify the accounts in your ledger. Each [**Account Type**](/en/reference/midaz/create-an-account-type) has a name, a description, and a unique key value.

You register the Account Types that match your accounting structure. When you enable Account Type validation, the ledger checks the `type` field of every new non-external Account against these registered types.

## How Account Type validation works

### Enabling Account Type validation

You enable Account Type validation per ledger through the [Ledger Settings API](/en/midaz/ledgers#ledger-settings). 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 through the API.
</Tip>

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

When you create an Account, the `type` field behavior depends on the validation setting:

* **Validation disabled (default):** You must provide a `type`. It accepts any string value up to 256 characters. The ledger does not compare it to registered Account Types.
* **Validation enabled:** The `type` field must match the `keyValue` of a registered Account Type. Midaz stores new `keyValue` values in lowercase and compares the value case-insensitively. Use lowercase values in requests and configuration. If it does not match, the ledger rejects the account with a validation error. External accounts skip this check.

<Tip>
  Before you enable Account Type validation, review your existing accounts. The `type` field of an existing Account cannot be changed, so create a matching registered Account Type or recreate an Account whose `type` must change.
</Tip>

### The `keyValue` field

<Note>
  The `keyValue` field identifies an Account Type. It has these constraints:

  * **Immutable:** You set `keyValue` when you create the Account Type. You cannot change it afterward. The Update Account Type endpoint does not accept this field.
  * **Unique per ledger:** Each `keyValue` must be unique within a ledger.
  * **Used for validation:** When you enable `validateAccountType` in Ledger Settings, the ledger compares the `type` field of each non-external Account case-insensitively with a registered `keyValue`. The ledger rejects any non-external Account with an unregistered `type`.
</Note>

## Managing Account Types

***

You manage Account Types through the API or the Lerian Console.

* [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.

<Note>
  **See also**

  * [Transaction Routing](/en/midaz/transaction-routing-entities) — Operation Routes use `ruleType: account_type` to validate an account's `type` against the route's configured `account.validIf` values.
  * [Accounting Entries](/en/midaz/accounting-entries) — How Midaz resolves debit and credit rubrics for the accounts these types classify.
</Note>
