# `create_accounts` Create one or more [`Account`](../accounts.md)s. ## Event The account to create. See [`Account`](../accounts.md) for constraints. ## Result Results are listed in this section in order of descending precedence — that is, if more than one error is applicable to the account being created, only the result listed first is returned. ### `ok` The account was successfully created; it did not previously exist. Note that `ok` is generated by the client implementation; the network protocol does not include a result when the account was successfully created. ### `linked_event_failed` The account was not created. One or more of the accounts in the [linked chain](../accounts.md#flagslinked) is invalid, so the whole chain failed. ### `linked_event_chain_open` The account was not created. The [`Account.flags.linked`](../accounts.md#flagslinked) flag was set on the last event in the batch, which is not legal. (`flags.linked` indicates that the chain continues to the next operation). ### `timestamp_must_be_zero` The account was not created. The [`Account.timestamp`](../accounts.md#timestamp) is nonzero, but must be zero. The cluster is responsible for setting this field. ### `reserved_field` The account was not created. [`Account.reserved`](../accounts.md#reserved) is nonzero, but must be zero. ### `reserved_flag` The account was not created. `Account.flags.reserved` is nonzero, but must be zero. ### `id_must_not_be_zero` The account was not created. [`Account.id`](../accounts.md#id) is zero, which is a reserved value. ### `id_must_not_be_int_max` The account was not created. [`Account.id`](../accounts.md#id) is `2^128 - 1`, which is a reserved value. ### `flags_are_mutually_exclusive` The account was not created. An account cannot be created with the specified combination of [`Account.flags`](../accounts.md#flags). The following flags are mutually exclusive: - [`Account.flags.debits_must_not_exceed_credits`](../accounts.md#flagsdebits_must_not_exceed_credits) - [`Account.flags.credits_must_not_exceed_debits`](../accounts.md#flagscredits_must_not_exceed_debits) ### `debits_pending_must_be_zero` The account was not created. [`Account.debits_pending`](../accounts.md#debits_pending) is nonzero, but must be zero. An account's debits and credits are only modified by transfers. ### `debits_posted_must_be_zero` The account was not created. [`Account.debits_posted`](../accounts.md#debits_posted) is nonzero, but must be zero. An account's debits and credits are only modified by transfers. ### `credits_pending_must_be_zero` The account was not created. [`Account.credits_pending`](../accounts.md#credits_pending) is nonzero, but must be zero. An account's debits and credits are only modified by transfers. ### `credits_posted_must_be_zero` The account was not created. [`Account.credits_posted`](../accounts.md#credits_posted) is nonzero, but must be zero. An account's debits and credits are only modified by transfers. ### `ledger_must_not_be_zero` The account was not created. [`Account.ledger`](../accounts.md#ledger) is zero, but must be nonzero. ### `code_must_not_be_zero` The account was not created. [`Account.code`](../accounts.md#code) is zero, but must be nonzero. ### `exists_with_different_flags` An account with the same `id` already exists, but with different [`flags`](../accounts.md#flags). ### `exists_with_different_user_data_128` An account with the same `id` already exists, but with different [`user_data_128`](../accounts.md#user_data_128). ### `exists_with_different_user_data_64` An account with the same `id` already exists, but with different [`user_data_64`](../accounts.md#user_data_64). ### `exists_with_different_user_data_32` An account with the same `id` already exists, but with different [`user_data_32`](../accounts.md#user_data_32). ### `exists_with_different_ledger` An account with the same `id` already exists, but with different [`ledger`](../accounts.md#ledger). ### `exists_with_different_code` An account with the same `id` already exists, but with different [`code`](../accounts.md#code). ### `exists` An account with the same `id` already exists. With the possible exception of the following fields, the existing account is identical to the account in the request: - `debits_pending` - `debits_posted` - `credits_pending` - `credits_posted` To correctly recover from application crashes [many applications](../../design/consistency.md#consistency-with-foreign-databases) should handle `exists` exactly as [`ok`](#ok). ## Client libraries For language-specific docs see: * [.NET library](/src/clients/dotnet/README.md#creating-accounts) * [Java library](/src/clients/java/README.md#creating-accounts) * [Go library](/src/clients/go/README.md#creating-accounts) * [Node.js library](/src/clients/node/README.md#creating-accounts) ## Internals If you're curious and want to learn more, you can find the source code for creating an account in [src/state_machine.zig](https://github.com/tigerbeetle/tigerbeetle/blob/main/src/state_machine.zig). Search for `fn create_account(` and `fn execute(`.