Create many accounts

Operation ID: bulkCreateAccounts

Group: Accounting › Accounts

Open in the interactive reference

POST /accounting/accounts/bulk

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates many accounts in one call and returns their ids in input order. All-or-nothing: if any row is rejected, nothing is created and every error carries the row's index.

Each row is the same object POST accounting/accounts takes. A parentAccountId must name an account that existed before the request, so a tree is created one level per request.

An account that breaks an accounting rule the server enforces, for example a bank account for a legal entity whose book has no currency, fails with VALIDATION_FAILED, with the rule's message in reason and, where known, the rule's name in rule.

One call takes at most 100 accounts; more fails with TOO_MANY_ACCOUNTS before any row is checked. Every request must carry the Api-Version header: a missing or empty header, or one naming no API version, is answered 400; a route that exists but not in the requested version is answered 404.

Parameters

Name In Type Required Description
Api-Version header string · v1 yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.

Request body

Required, application/json: bulkCreateAccountsInput.

Field Type Required Description
accounts array<object> yes The accounts to create, each the same object POST accounting/accounts takes. At most 100 rows; more fails with TOO_MANY_ACCOUNTS. If any row is invalid, nothing is created. Example: [{"accountName":"Prepaid Insurance","accountType":"asset","accountSubType":"prepaidExpenses","chartOfAccountsId":"5c1f0e2a-7b3d-4e8a-9f61-2d4b8c0a7e13","parentAccountId":"a8e2c4d1-3f5b-4a7c-8e9d-1b2c3d4e5f60"},{"accountName":"Office Supplies","accountType":"expense","accountSubType":"expense","chartOfAccountsId":"5c1f0e2a-7b3d-4e8a-9f61-2d4b8c0a7e13","parentAccountId":"c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f"}].
accounts[].accountNumber string no The account number, unique within its chart of accounts. Required when the chart of accounts uses manual numbering. Not allowed when it uses hierarchical numbering, where the number is derived from the parent account.
accounts[].accountName string yes The display name of the account.
accounts[].accountType string yes The top-level classification of the account. Accepted values: 'asset', 'liability', 'equity', 'income', 'costOfGoodsSold', 'expense', 'otherIncome', 'otherExpense'.
accounts[].accountSubType string no A finer classification within accountType, for posting accounts only. Accepted values per accountType: 'bank', 'accountsReceivable', 'fixedAsset', 'cip', 'prepaidExpenses', 'deferredExpenses', 'otherCurrentAsset', 'otherAsset', 'unbilledReceivable', 'longTermAsset' (asset); 'accountsPayable', 'creditCard', 'deferredRevenue', 'otherCurrentLiability', 'longTermLiability' (liability); 'equity', 'otherComprehensiveIncome' (equity); and the sub-type named like the type for 'income', 'costOfGoodsSold', 'expense', 'otherIncome' and 'otherExpense'. Required for posting accounts. 'bank' and 'creditCard' require entityId and currency.
accounts[].description string no A free-form description of the account.
accounts[].chartOfAccountsId string yes The chart of accounts the account belongs to. See id on GET accounting/chart-of-accounts/:id.
accounts[].parentAccountId string no The grouping account this account rolls up to. It must already exist and be a grouping account in the same chart of accounts with the same accountType. Required for a posting account when the chart of accounts uses hierarchical numbering. Omit for a top-level account. See id on GET accounting/accounts/:id.
accounts[].groupingAccount boolean no Whether this is a grouping (rollup) account. Defaults to false. A grouping account takes no accountSubType, entityId, currency or revaluationMode. Cannot be changed later.
accounts[].entityId string no The legal entity a bank or credit-card account is denominated for. Required for, and only allowed on, 'bank' and 'creditCard' accounts. The entity must be assigned to the chart of accounts. See id on GET base/entities.
accounts[].currency string no The account's currency. Format ISO 4217, for example 'USD'. Required for, and only allowed on, 'bank' and 'creditCard' accounts.
accounts[].payOnBehalf boolean no Whether this account takes part in pay-on-behalf accounting. Defaults to false. true is only allowed on 'bank' and 'creditCard' accounts of a legal entity that has subsidiaries or a parent entity.
accounts[].elimination boolean no Whether this account is eliminated during consolidation. Defaults to false. true is not allowed on grouping, 'bank' or 'creditCard' accounts.
accounts[].revaluationMode string no Which revaluation results this account recognizes. Accepted values: 'recognizeAll' (both unrealized gains and unrealized losses), 'recognizeAllButUnrealizedGains' (only unrealized losses), 'none' (the account is not revalued). Posting accounts only. Omit to take the default the server derives. Which modes an account can take depends on its sub-type, on a bank or credit-card account's currency against its book's currency, and on the accounting standard of the chart's book; a mode the account cannot take is rejected with INVALID_FIELD_VALUE, whose allowedValues lists the modes it can take, never replaced.
accounts[].accountStatus string no The account's status, posting accounts only. Accepted values: 'enabled', 'disabled'. Defaults to 'enabled'. A grouping account accepts only 'enabled', the status it reads back with.
accounts[].externalIdentifiers array<object> no External identifiers owned by other systems, at most one per fieldName. Each fieldName must match an active account external-identifier configuration. GET accounting/account-external-identifier-fields lists them.
accounts[].externalIdentifiers[].fieldName string yes The configured key of the external identifier, a camelCase slug such as 'netsuiteAccountId'. GET accounting/account-external-identifier-fields lists the accepted keys.
accounts[].externalIdentifiers[].value string yes The identifier as the source system holds it.
accounts[].externalIdentifiers[].externalUrl string no An absolute http(s) link to the object in the source system. Anything else is rejected with INVALID_FIELD_VALUE.
{
  "accounts": [
    {
      "accountName": "Prepaid Insurance",
      "accountType": "asset",
      "accountSubType": "prepaidExpenses",
      "chartOfAccountsId": "5c1f0e2a-7b3d-4e8a-9f61-2d4b8c0a7e13",
      "parentAccountId": "a8e2c4d1-3f5b-4a7c-8e9d-1b2c3d4e5f60"
    },
    {
      "accountName": "Office Supplies",
      "accountType": "expense",
      "accountSubType": "expense",
      "chartOfAccountsId": "5c1f0e2a-7b3d-4e8a-9f61-2d4b8c0a7e13",
      "parentAccountId": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f"
    }
  ]
}

Response

200 Success

Under data (bulkCreateAccountsOutput):

Field Type Required Description
created array<object> yes The created accounts, in the same order as the input. Match rows to inputs by index. Example: [{"id":"7d3c2b1a-9e8f-4d6c-b5a4-3e2f1d0c9b8a"},{"id":"2b4d6f80-1a3c-4e5f-8a9b-c0d1e2f3a4b5"}].
created[].id string yes The identifier of the created account.
{
  "data": {
    "created": [
      {
        "id": "7d3c2b1a-9e8f-4d6c-b5a4-3e2f1d0c9b8a"
      },
      {
        "id": "2b4d6f80-1a3c-4e5f-8a9b-c0d1e2f3a4b5"
      }
    ]
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

Errors

Code Status
REFERENCE_NOT_FOUND 400
INVALID_FIELD_VALUE 400
FIELD_REQUIRED 400
FIELD_NOT_ALLOWED 400
DUPLICATE_ACCOUNT_NUMBER 400
INVALID_PARENT_ACCOUNT 400
TOP_LEVEL_ACCOUNT_TYPE_IN_USE 400
ENTITY_NOT_IN_CHART_OF_ACCOUNTS 400
UNKNOWN_EXTERNAL_IDENTIFIER 400
DUPLICATE_EXTERNAL_IDENTIFIER 400
VALIDATION_FAILED 400
TOO_MANY_ACCOUNTS 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses