Accountflow Developer prod

Errors

Every error the API returns, as RFC 9457 problem details.

Branch on error, then on reason. Show detail to people; never parse it. A server build fails if it can return a code that this page does not list.

{
  "type": "https://api.accountflow.com/errors/resource-not-found",
  "title": "Resource Not Found",
  "status": 404,
  "detail": "Resource not found",
  "error": "resource_not_found",
  "requestId": "6f1c2d3e-…"
}

type ends in the code with - for _. It is a name, not a URL to call.

Codes

Code Status Meaning What to do
validation_failed 400 The request is malformed: a missing or blank field, a value out of range (pageSize outside 1–200, period outside 1–12), an unparseable value. See reasons. Fix the request. detail, parameter and errors name the field.
idempotency_key_missing 400 A mutation without an Idempotency-Key header. Send a unique key per logical action.
invalid_cursor 400 The cursor is expired, altered, from another client, or from a request with other filters. Restart from the first page.
unauthorized 401 No token, or a rejected one. WWW-Authenticate is a bare Bearer challenge without a token and has error="invalid_token" for a rejected one; it does not say why. Fetch a new token; check audience and issuer.
forbidden 403 Authenticated, but this action is denied. Example: a USER-mode client whose linked person is disabled or has left the organization. See reasons. Check the client's provisioning in Accountflow.
capability_denied 403 This kind of principal can never do this: an MCP sign-in calling /v1, an interactive MCP session writing, an MCP sign-in where interactive AI sessions are switched off. Use an API client (client credentials) for /v1.
insufficient_scope 403 The token lacks a scope. WWW-Authenticate (scope="…") and requiredScope name it. Have the scope granted to the client.
resource_not_found 404 No such id within your reach. Identical for "missing", "not yours" and "deleted". Check the id and that the client belongs to the right organization. Don't retry.
method_not_allowed 405 The path exists; the method doesn't. /mcp answers POST only (Allow: POST). Check the reference.
duplicate_resource 409 It exists already: the same company number in the organization, policy name, assignment or rule. Read the existing resource, or change the distinguishing field.
conflict 409 The request is valid; the state is not: an expired upload slot, an archived policy, a missing GL mapping, an account template changed since its preview. See reasons. Read reason and the extensions, resolve the state, retry.
deleted_by_organization_cascade 409 The company was deleted with its organization; it can't be restored alone. Restore the organization.
idempotency_in_flight 409 The first request with this key is still running. Retry-After is set. Retry with the same key.
payload_too_large 413 More than 10 000 lines in one import request (limit), or a body over 8 MiB (refused before parsing). Split the data and send the requests one after another.
unsupported_media_type 415 The declared content type is not accepted. supported lists the accepted ones. Use an accepted type; the reference lists types and size caps.
unprocessable 422 Well-formed, but a rule refuses it: an unknown role, a company of another organization on a rule, a file over its type's cap, an upload whose content is another type (it is deleted), an invalid organization number, a forbidden character in an id, a reference to data that does not exist. See reasons. Fix the data. detail names the rule; errors lists the lines.
idempotency_key_reused 422 The key was used within 24 hours on the same operation with a different body. Use a new key per logical action.
malware_detected 422 The file failed the virus scan at POST /documents/{documentId}/actions/complete. It is deleted; no document is created. Don't resend that file. Upload a clean file to the same slot while its URL is valid, or start a new upload.
rate_limited 429 Over the plan quota. Retry-After and retryAfterSeconds say when to retry. Back off as told.
internal_error 500 A server bug. Retry with the same Idempotency-Key; report the requestId if it persists.
not_implemented 501 Reserved. No operation returns it. Report the requestId if you see it.
service_unavailable 503 A dependency is down: authorization, the import engine, the semantic layer, or the virus scanner at upload completion (the file is kept). Never wrong data. Retry-After is set. Retry with backoff and the same Idempotency-Key.

Reasons

reason narrows a code. The common ones are below; the spec's Problem schema and each operation's error examples have the full set.

reason Code Meaning Extensions
mode_not_available validation_failed An import mode other than MERGE.
parameter_renamed validation_failed A query parameter under a retired name (periodYear). detail names the replacement (year). parameter
account_year_mismatch validation_failed year is not the accounting year of the accountId beside it. parameter
default_policy_retired validation_failed isDefault: true on an access policy. The flag grants nothing.
threshold_negative, threshold_too_many_decimals, threshold_out_of_range, threshold_high_below_flag validation_failed A currency control's thresholds are invalid.
feature_disabled forbidden The comment or flag type's module is off for the company. feature
origin_not_allowed forbidden An /mcp request from a browser Origin that is not allowed. A request without Origin passes. Report-only for now: logged, not refused.
association_exists duplicate_resource The document already has this connection. connectionId
intercompany_pairing_key_taken duplicate_resource Another line of the intercompany link uses that pairing key. pairingKey
job_in_flight conflict A job of the same kind runs for the same scope. jobId
upload_not_completed conflict The document was completed before its file was PUT to the signed URL.
already_reconciled conflict GL lines or bank transactions are already in a reconciliation group. lineIds, bankTransactionIds
opening_balance_settled conflict Opening-balance rows are part of a settlement; remove it before reconciling them against the bank. lineIds
bank_accounts_not_on_same_gl_account conflict The group's bank transactions come from bank accounts that don't feed the same GL account. bankAccountIds, erpAccountCode
restricted_rule_dropped conflict An access-policy update would drop a template or account rule. Send it back, or state resourceScope. companyIds, portfolioIds
portfolio_rule_would_widen conflict An access-policy update would replace portfolio rules with an all-companies rule. portfolioIds
company_not_api_managed conflict The company, or the year's ledger, is not on the Api accounting system.
lines_in_use, opening_balances_in_use, account_in_use, dimension_in_use, sub_ledger_in_use conflict A deletion names data that work in Accountflow depends on. Nothing was deleted. See corrections. inUse
intercompany_account_owned, intercompany_account_shared, intercompany_account_split_differently, intercompany_slice_owned conflict That part of the account is on another intercompany link. definitionId, active, counterparty
fiscal_year_overlap conflict The fiscal year would overlap another of the company's years. accountingYear
ledger_exists conflict The year already has an Api ledger. ledgerId
fetch_in_progress conflict An Api ledger was requested while an ERP fetch runs.
foreign_gl_lines conflict A trial balance into a year holding lines or opening balances you pushed yourself.
trial_balance_year conflict General-ledger lines or opening balances into a year loaded as a trial balance.
trial_balance_import_unavailable conflict The trial-balance import is not switched on in this environment.
company_read_only conflict The company's organization was terminated. Reads work for 90 days, writes are refused; after that the company is 404. Not resolvable through the API.
unknown_account_codes unprocessable Account codes missing from the year's chart. accountCodes
bank_match_currency_mismatch unprocessable The group's bank transactions are in more than one currency, or a line has no amount in the bank's currency. currencies, currency
confirmation_required unprocessable An account-template apply with unconfirmed warnings. Have a person confirm them, then send them as confirmedWarnings. warnings
fiscal_year_not_twelve_months, fiscal_year_fields_disagree unprocessable Fiscal-year fields that are not twelve months from the first of a month, or that contradict each other.
fiscal_year_change_unsupported unprocessable A company update naming another fiscal-year start month. Change it in Accountflow.

A settings write whose version is stale is conflict with currentVersion or currentRevision: read the settings again and re-apply your change.

An MCP-Protocol-Version header naming a version /mcp does not support is validation_failed with parameter and supported. Like the Origin check, it is report-only for now.

Problem extension fields

Every problem has error and requestId (the X-Request-Id header's value) beside the RFC 9457 members (type, title, status, detail, instance). The spec's Problem schema declares every extension. These are the common ones; each appears only when it applies.

Extension Type On Meaning
reason string conflict, unprocessable, forbidden, validation_failed The rule that fired.
errors array of items validation_failed, unprocessable Field-level detail, up to 100 items.
parameter string validation_failed, invalid_cursor The parameter or header at fault (pageSize, cursor, year, MCP-Protocol-Version).
currentVersion string conflict on a settings write The settings' version now.
currentRevision integer conflict on an account settings write The account's settingsRevision now.
inUse array of {id, dependencies} conflict, reason: *_in_use Your ids or keys that are in use, and what uses them. Never an internal id.
accountCodes array of strings unknown_account_codes The missing codes.
warnings array of strings confirmation_required Unconfirmed template warnings: TEMPLATE_CHANGED, DOCUMENTATION_REQUIREMENT_REMOVED, AUTO_APPROVE_ENABLED.
definitionId, active, counterparty UUID, boolean, string reason: intercompany_* The link that holds that part of the account.
jobId UUID job_in_flight The blocking job. Poll it.
limit integer payload_too_large The cap that was exceeded.
retryAfterSeconds integer rate_limited, service_unavailable, idempotency_in_flight Retry-After as a number.
requiredScope string insufficient_scope The missing scope.
supported array of strings unsupported_media_type, validation_failed The accepted media types, or MCP protocol versions.

The errors item

{ "field": "lines[12].amount", "message": "amount is required", "index": 12 }
Field Meaning
field The field at fault; empty when a whole line is malformed.
message For people. Don't branch on it.
index The element of a request array, 0-based. Only when the error addresses one.
allowedValues The accepted values, when the field is an enumeration.

Every validation_failed and unprocessable uses this one shape.