Update an account
Operation ID: updateAccount
Group: Accounting › Accounts
Open in the interactive reference
PATCH /accounting/accounts/{id}
Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.
Changes an account. Send only the fields to change; an omitted field keeps its value. The response is empty; read the account back with GET accounting/accounts/:id.
Once the account has postings, accountType, accountSubType, elimination, entityId and currency are locked, and revaluation cannot be switched on or off. accountStatus moves a posting account between 'enabled' and 'disabled'; a disabled account only accepts a request that enables it.
An account that breaks an accounting rule the server enforces, for example switching on revaluation for an account a cash-basis tax rate uses, fails with VALIDATION_FAILED, with the rule's message in reason and, where known, the rule's name in rule. 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. |
id |
path | string | yes | The identifier of the account to update. Example: "7d3c2b1a-9e8f-4d6c-b5a4-3e2f1d0c9b8a". |
Request body
Required, application/json: updateAccountInput.
| Field | Type | Required | Description |
|---|---|---|---|
accountNumber |
string | no | The new account number, unique within its chart of accounts. Only with manual numbering; with hierarchical numbering the number follows the parent account. Omit to leave unchanged. |
accountName |
string | no | The new display name. Omit to leave unchanged. Example: "Operating Bank USD (Main)". |
accountType |
string | no | The new top-level classification. Accepted values: 'asset', 'liability', 'equity', 'income', 'costOfGoodsSold', 'expense', 'otherIncome', 'otherExpense'. Locked once the account or one of its descendants has postings. A grouping account passes the new type to its descendants, and is refused with INVALID_FIELD_VALUE while a descendant posting account has a sub-type that does not belong to the new type. Omit to leave unchanged. |
accountSubType |
string | no | The new sub-type, 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'. Locked once the account has postings. Switching to 'bank' or 'creditCard' needs entityId and currency, and is refused with FIELD_NOT_ALLOWED on elimination while the account has elimination true, unless the request also sends elimination false. Switching away from 'bank' or 'creditCard' drops the account's entityId and currency, and is refused with FIELD_NOT_ALLOWED on payOnBehalf while payOnBehalf is true, unless the request also sends payOnBehalf false. Omit to leave unchanged. |
description |
string | no | The new description. Omit to leave unchanged. Example: "Main operating account". |
chartOfAccountsId |
string | no | The account's chart of accounts. It cannot change: accepted only when it names the current one. Omit to leave unchanged. |
parentAccountId |
string | null | no | The new parent grouping account, in the same chart of accounts with the same accountType, and not the account itself or one of its descendants. Pass null to move the account to the top level (not allowed for a posting account under hierarchical numbering). Omit to leave unchanged. |
groupingAccount |
boolean | no | Whether this is a grouping account. It cannot change: accepted only when it matches the stored value. Omit to leave unchanged. |
entityId |
string | no | The new legal entity of a 'bank' or 'creditCard' account, assigned to the chart of accounts. Locked once the account has postings. Omit to leave unchanged. |
currency |
string | no | The new currency of a 'bank' or 'creditCard' account. Format ISO 4217. Locked once the account has postings. Omit to leave unchanged. |
payOnBehalf |
boolean | no | Whether this account takes part in pay-on-behalf accounting. true is only allowed on 'bank' and 'creditCard' accounts of a legal entity that has subsidiaries or a parent entity. Omit to leave unchanged. |
elimination |
boolean | no | Whether this account is eliminated during consolidation. true is not allowed on grouping, 'bank' or 'creditCard' accounts. Locked once the account has postings. Omit to leave unchanged. |
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. Once the account has postings it may move between the two recognizing modes but not to or from 'none'. 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. Omit to leave unchanged. |
accountStatus |
string | no | The new status, posting accounts only. Accepted values: 'enabled', 'disabled'. A disabled account accepts a request only when it sets 'enabled'. Disabling unlinks the bank accounts that post to the account. Sending 'disabled' alone for an account that is already disabled changes nothing and succeeds. Omit to leave unchanged. Example: "enabled". |
createExternalIdentifiers |
array<object> | no | External identifiers to add. Rejected with DUPLICATE_EXTERNAL_IDENTIFIER when the account already has the fieldName. |
createExternalIdentifiers[].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. |
createExternalIdentifiers[].value |
string | yes | The identifier as the source system holds it. |
createExternalIdentifiers[].externalUrl |
string | no | An absolute http(s) link to the object in the source system; anything else is rejected with INVALID_FIELD_VALUE. Omit to leave none. |
updateExternalIdentifiers |
array<object> | no | External identifiers to rewrite, matched by fieldName. Rejected with EXTERNAL_IDENTIFIER_NOT_FOUND when the account does not have the fieldName. Example: [{"fieldName":"netsuiteAccountId","value":"1011"}]. |
updateExternalIdentifiers[].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. |
updateExternalIdentifiers[].value |
string | yes | The identifier as the source system holds it. |
updateExternalIdentifiers[].externalUrl |
string | null | no | An absolute http(s) link to the object in the source system; anything else is rejected with INVALID_FIELD_VALUE. Omit to keep the stored link; send null to remove it. |
deleteExternalIdentifiers |
array<string> | no | fieldNames of the external identifiers to remove. Rejected with EXTERNAL_IDENTIFIER_NOT_FOUND when the account does not have one. |
{}
Response
200 Success
{
"data": {},
"diagnostics": [
{
"code": "<code>",
"message": "<message>",
"severity": "error",
"path": [
"<path>"
],
"details": "<details>"
}
]
}
Response headers
Idempotency-Replayed— Present andtrueonly when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent asfalse.
Errors
| Code | Status |
|---|---|
NOT_FOUND |
400 |
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 |
ACCOUNT_TYPE_LOCKED |
400 |
CASH_ACCOUNT_IN_USE |
400 |
ACCOUNT_NOT_EDITABLE |
400 |
UNKNOWN_EXTERNAL_IDENTIFIER |
400 |
DUPLICATE_EXTERNAL_IDENTIFIER |
400 |
EXTERNAL_IDENTIFIER_NOT_FOUND |
400 |
VALIDATION_FAILED |
400 |
IDEMPOTENCY_KEY_CONFLICT |
409 |
IDEMPOTENCY_PAYLOAD_MISMATCH |
422 |
Statuses
400— Invalid request or business failure. Codes: NOT_FOUND, REFERENCE_NOT_FOUND, INVALID_FIELD_VALUE, FIELD_REQUIRED, FIELD_NOT_ALLOWED, DUPLICATE_ACCOUNT_NUMBER, INVALID_PARENT_ACCOUNT, TOP_LEVEL_ACCOUNT_TYPE_IN_USE, ENTITY_NOT_IN_CHART_OF_ACCOUNTS, ACCOUNT_TYPE_LOCKED, CASH_ACCOUNT_IN_USE, ACCOUNT_NOT_EDITABLE, UNKNOWN_EXTERNAL_IDENTIFIER, DUPLICATE_EXTERNAL_IDENTIFIER, EXTERNAL_IDENTIFIER_NOT_FOUND, VALIDATION_FAILED401— The request carries no valid access token.403— Not authorized404— Not found409— The Idempotency-Key is still being processed by another request.422— The Idempotency-Key was already used with a different request payload.429— Too many requests from this client address. The response has no body and noRetry-Afterheader.500— Internal server error