Errors

Every error the REST API returns, what it means, and what to do about it.


Errors use standard HTTP status codes, with a JSON body. Branch on the error field. It is stable. Show or log message for people.

Error shapes

Most errors look like this:

{ "error": "bad_request", "message": "Idempotency-Key header is required" }

Some carry more. Read the fields your case needs:

When Shape
Default { error, message }
GET /v1/intents/:id errors { error } only
Payload validation, invalid_* { error, messages: [] }, note the plural
Voucher dry run with a name problem { error, messages: [], issues: [] }
Voucher commit with a name problem { error, message, issues: [] }
gate_blocked { error, gates: [{ code, message }] }, with no message key
similar_master_exists { error, message, candidates: [{ name, relation, why? }] }
ambiguous_name on a master write { error, message, candidates: [{ name, parent }] }
A reference inside a master write { error, message, field, candidates? }
Malformed JSON, oversized body { statusCode, code, error, message }. Read code: error is only the status text
Unknown route { message, error, statusCode }
An unexpected fault on a write or document route { statusCode, error, message }, where error is only the status text. Branch on the status

Each item in issues is { code, field, asked, message, candidates? }. code is no_such_master, ambiguous_name or masters_not_synced, and candidates holds suggestions or the records that matched.

Handle them all with one function:

function errorText(body) {
  if (body?.gates) return body.gates.map((g) => `${g.code}: ${g.message}`).join("; ");
  if (body?.messages) return body.messages.join("; ");
  return body?.message ?? body?.error ?? "Unknown error";
}

Two answers are not errors and arrive with a 2xx. A statement can return 200 with a status and no figures. A retraction can return 200 with "superseded": false. Check for both.

Code table

"Retry" below means the same request with the same Idempotency-Key.

Status error What it means What to do
400 bad_request Missing Idempotency-Key, missing companyGuid on a commit, a bad date, or several companies and no ?company= Fix the request. Do not retry
400 company_required A statement without ?company= Add the company name
400 invalid_voucher The voucher failed validation, or a name in it did not resolve on a dry run Read messages and issues, fix the payload
400 invalid_ledger, invalid_ledger_alter, invalid_stock_item, invalid_stock_item_alter, invalid_group, invalid_group_alter, invalid_unit, invalid_unit_alter, invalid_godown, invalid_godown_alter, invalid_cost_centre, invalid_cost_category, invalid_currency, invalid_stock_group, invalid_employee_group, invalid_employee, invalid_pay_head, invalid_attendance_type, invalid_unit_of_attendance, invalid_delete The master payload failed validation Read messages, fix the payload
400 FST_ERR_CTP_INVALID_JSON_BODY, FST_ERR_CTP_EMPTY_JSON_BODY (in code) Bad JSON, or content-type: application/json with no body. The usual cause is a DELETE Fix the body, or drop the header
401 unauthorized Missing, wrong or revoked key Check the key. If a customer revoked or rotated it, ask them for a new one
402 plan_required Committing needs a paid seat. message says which case: the bridge is beyond the workspace's plan, the connection has been used on more than one computer, or there is no paid plan Ask the customer to sort out billing. Dry runs still work
402 insufficient_credits Reading a document needs credits the workspace does not have Ask the customer to add credits
403 forbidden The key has no write permission, or the route is for people signed in to the workspace Issue a key with Allow writes, or do this in the workspace
404 not_found Unknown company, record, write or document Check the id or the exact name. A new write is not readable until it syncs
409 idempotency_key_reused The same key was sent with a different write Do not change the payload under a key. Read the first attempt's result before you write again
409 ambiguous_name A name matches several records Use one of the candidates by its exact name
409 no_such_master A name matches nothing. Also appears inside issues on a dry run Fix the name, or create the master first
409 masters_not_synced The company's masters have not synced yet Wait for the first sync. Check /v1/status
409 similar_master_exists A master like this one already exists Show candidates to a person. Use the existing one, or resend with "acknowledge": ["similar-name"]
409 nothing_to_reconcile, not_disputed, nothing_to_resolve, nothing_to_repropose, nothing_to_propose, already_posting, already_proposed, ambiguous_company, not_filed, not_filed_there, not_from_document, bad_choice A document action does not apply in its current state. The status can differ per code Read message. Refresh the document first
413 payload_too_large, too_large The file is over the limit Send a smaller file
413 quota_exceeded The workspace's storage is full Ask the customer to free space
413 FST_ERR_CTP_BODY_TOO_LARGE (in code) The JSON body is over 1 MiB Send a smaller body
415 unsupported_media_type A document upload was not multipart Send multipart/form-data
422 gate_blocked A money guard refused the voucher: duplicate-bill, over-threshold or expense-equals-party. See below Show gates to a person. To go ahead, resend with acknowledge, which holds the voucher for approval
422 unknown_document, document_already_entered A documentIds entry is unknown, or already entered Check documentIds in the body.
422 not_applicable GSTR-1 or GSTR-3B for a composition company Do not request this report for this company
429 Too many requests Back off. See Retries
500 internal_error A fault on our side Retry with backoff
502 A document was stored but could not be read. The body has "state": "failed" Read errorMessage
503 gate_unavailable, numbering_unavailable, document_link_unavailable A check could not read what it needed. Nothing was queued Retry with backoff
503 reader_unavailable Document reading is unavailable right now Retry later

Failures after a 202

A write that was accepted can still fail. Those arrive as a state on GET /v1/intents/:id, not as an HTTP error:

state What to do
failed Read error, often Tally's own words. Unless it says nothing was written, look in Tally first: Tally accepted this as a DATA EXCEPTION means the company was changed and a resend makes it worse, and Tally returned no IMPORTRESULT or a lease message means the result is unknown. Then fix the cause and send with a new key
rejected A person said no, or it was retracted. Ask before you send again, with a new key
submitted, for a long time Tally may or may not have it. Look for the record before you post again

Validation messages worth knowing

These come back in messages on invalid_voucher:

Message starts Cause
ledger entries must net to zero Your debits and credits differ. Add positive and negative amounts
bill allocations on "..." net to billAllocations must sum to the leg's signed amount
This company numbers '...' vouchers as This voucher type needs a voucherNumber from you
billType must be one of Use exactly New Ref, Agst Ref, Advance or On Account

A company on an educational Tally licence can only take vouchers dated the 1st, 2nd or 31st of a month. Other dates are refused with invalid_voucher.

Retries

Safe to retry with the same key: network failures, timeouts, 429, 500, 503. A write that reached us returns the first write with "deduped": true, not a second one.

Do not retry unchanged: any other 4xx. The same request gets the same answer.

Back off: wait about 1 second, then 2, 4, 8, with some random jitter, and stop after a handful of tries. If a 429 or 503 carries Retry-After, honour it.

async function withRetry(call, attempts = 5) {
  for (let i = 0; ; i++) {
    try {
      return await call();
    } catch (err) {
      const status = err.status;
      const transient = status === undefined || status === 429 || status >= 500;
      if (!transient || i >= attempts - 1) throw err;
      const retryAfterMs = Number(err.retryAfter) * 1000 || 0;
      const backoffMs = 2 ** i * 1000 + Math.random() * 250;
      await new Promise((r) => setTimeout(r, Math.max(retryAfterMs, backoffMs)));
    }
  }
}

Retrying a voucher with a bill

A retry of POST /v1/vouchers with the same key and the same voucher returns the first attempt with "deduped": true. That check runs first, so the retry takes no new voucher number and the duplicate-bill guard does not count your own first attempt. If you left voucherNumber out, the number AutoTally allocated stays on the first attempt.

Master creates differ: once a created master has synced, a retry gets 409 similar_master_exists.