Write safety

The guardrails around software and agents posting to your accounting data.


Writes to Tally are high-stakes: software is posting to real accounting data. The API enforces these guardrails on every write made with a key.

Dry run by default

A write validates without committing unless you pass ?commit=true. A dry run stores nothing, and it tells you whether the write would be accepted.

How deep the check goes depends on what you send:

Write What a dry run checks
Create a voucher, with companyGuid Names against your synced masters, the arithmetic, money guards (reported), the voucher number
Alter a voucher, with companyGuid The same, minus the money guards
A voucher, without companyGuid The arithmetic only. resolution comes back skipped_no_company
Delete a voucher That the id is well formed. Not that the voucher exists
Masters The payload's shape only. Names and duplicates are checked at commit

Always send companyGuid on a voucher dry run.

A clean dry run does not promise a clean commit. Money guards only report on a dry run and refuse at commit, and a master's name checks run only at commit. Handle a refusal at commit too.

Idempotency keys

Every write needs an Idempotency-Key header, on dry runs as well. It is enforced:

  • There is one namespace per workspace, across all your keys. Keys never expire.
  • Sending the same key with the same write returns the first write, with "deduped": true.
  • Sending the same key with a different write returns 409 idempotency_key_reused.
  • A failed or rejected write stays failed under its key. To try again, use a new key.

Generate one key per logical write, derive it from your own record id, and reuse it on retries.

Tally numbers some vouchers itself and leaves others to AutoTally. If the company's book needs a number and you send none, AutoTally allocates one, and a retry can allocate a different one and come back 409 idempotency_key_reused. Send your own voucherNumber when you intend to retry. On that 409, read the first attempt's result before you write again.

Company scoping

Every write names its company explicitly with companyGuid. There is no implicit "active company" a write could silently land in. A commit without one is refused with 400.

Name checks

Names on a write must match your books. AutoTally never guesses:

  • A name that matches nothing is refused with no_such_master.
  • A name that matches several records is refused with ambiguous_name, and lists the candidates.
  • Creating a master that looks like one you already have is refused with similar_master_exists, and lists the candidates. If it really is a new record, send "acknowledge": ["similar-name"] in the body.

Money guards

When you commit a new voucher, three checks can refuse it with 422 gate_blocked:

Code Meaning
duplicate-bill This party already has this bill number, posted or on its way to Tally
over-threshold The voucher is over a limit you set in your rules
expense-equals-party One ledger sits on both sides of a sales or purchase voucher, so it would book nothing

A dry run with companyGuid reports these under gates. To go ahead anyway, send the code in "acknowledge": ["duplicate-bill"]. A voucher sent that way waits for a person to approve it, even if the key does not require approval.

Altering a voucher does not run these checks.

Approval

A key issued with Require approval (the default for write keys) holds every committed write on the workspace's Agent activity page. Nothing reaches Tally until someone with approval rights chooses Approve write. Reject discards it. Only someone allowed to auto-approve writes can issue a key without approval. See Approving writes.

A key cannot approve or reject. Only a person in the workspace can. A key can take back a queued draft nobody has approved yet:

curl -s -X POST "https://relay.autotally.ai/v1/intents/$INTENT_ID/supersede" \
  -H "authorization: Bearer $AUTOTALLY_TOKEN" \
  -H "content-type: application/json" \
  -d '{ "reason": "Invoice cancelled in the CRM" }'

A key can only retract writes it created. Anything else returns 404, including a write from a key you have since rotated. A person can still reject those.

The answer is 200 either way. Check superseded. If it is false, reason says why: already-applied, failed, already-withdrawn or approved-and-in-flight.

Applied does not mean confirmed

A commit returns 202 with an intentId. Writes never reach Tally during your request.

GET /v1/intents/<intentId> shows where the write is:

state Meaning
pending Queued. Either waiting for approval, or approved and waiting for the extension. The API cannot tell you which
claimed The extension has picked it up
submitted Sent to Tally, but the response could not be read. Check Tally before you post again
applied Tally accepted the import
failed It did not complete, and error says why. Read it before you resend: some failures mean the book did change, or that the result is unknown. See Errors
rejected A person rejected it, or it was retracted

applied means Tally accepted the import. It is not proof the record is there. Confirmation is the read back:

  • Vouchers: wait for resultGuid to be non-null, then GET /v1/vouchers/<resultGuid>?company=<name>.
  • Masters: re-read by name, for example GET /v1/ledgers/<name>?company=<name>.

The amount convention

Voucher entries follow one rule, and they must net to zero:

  • positive amount = debit
  • negative amount = credit
{
  "voucherType": "Sales",
  "date": "2026-10-15",
  "voucherNumber": "INV-1042",
  "ledgerEntries": [
    { "ledger": "Mehta Retail", "amount": 118000 },
    { "ledger": "Sales", "amount": -100000 },
    { "ledger": "Output IGST 18%", "amount": -18000 }
  ]
}

A voucher whose entries don't net to zero is rejected. Always check the dry-run result before you commit to production data.