Each recipe has a curl command and a Node version. Both assume:
export AUTOTALLY_TOKEN=tapi_...
export COMPANY_GUID=a1b2c3d4-0000-0000-0000-000000000001 # guid from /v1/companies
The Node snippets share this helper. Run them on your server, Node 18 or later.
const BASE = "https://relay.autotally.ai";
const TOKEN = process.env.AUTOTALLY_TOKEN;
const COMPANY_GUID = process.env.COMPANY_GUID;
const COMPANY = "Sharma Traders";
const q = encodeURIComponent;
async function api(method, path, { body, key } = {}) {
const headers = { authorization: `Bearer ${TOKEN}` };
if (body !== undefined) headers["content-type"] = "application/json";
if (key) headers["idempotency-key"] = key;
const res = await fetch(BASE + path, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
});
const data = await res.json().catch(() => null);
if (!res.ok) throw Object.assign(new Error(data?.message ?? data?.error), { status: res.status, data });
return { data, headers: res.headers };
}
Every write below is shown as a dry run. To send it for real, add ?commit=true to the URL. Ledger
names are examples: use the exact names from your books. Change date and voucherNumber, and use a
new idempotency key for each new write.
List customers
Customers are ledgers under Sundry Debtors. There is no group filter, so read the pages and filter on
parent.
curl -s "https://relay.autotally.ai/v1/ledgers?company=Sharma%20Traders&page=1&pageSize=1000" \
-H "authorization: Bearer $AUTOTALLY_TOKEN"
const customers = [];
for (let page = 1; ; page++) {
const { data } = await api("GET", `/v1/ledgers?company=${q(COMPANY)}&page=${page}&pageSize=1000`);
customers.push(...data.items.filter((l) => l.parent?.trim() === "Sundry Debtors"));
if (data.items.length === 0 || page * 1000 >= data.total) break;
}
A customer in a subgroup has that subgroup as parent. See
Pulling customers.
Get a party's outstanding
party is the exact ledger name.
curl -s "https://relay.autotally.ai/v1/outstandings?company=Sharma%20Traders&party=Mehta%20Retail" \
-H "authorization: Bearer $AUTOTALLY_TOKEN"
const { data } = await api("GET", `/v1/outstandings?company=${q(COMPANY)}&party=${q("Mehta Retail")}`);
const open = data.bills.map((b) => ({ bill: b.billName, open: Number(b.openAmount ?? b.amount ?? 0) }));
const total = data.parties?.[0]?.outstanding;
Use openAmount when present. A positive amount is money owed to you.
Post a sales invoice with CGST and SGST
For a sale inside the state. The party is debited, sales and tax are credited. New Ref creates the
bill.
curl -s -X POST "https://relay.autotally.ai/v1/vouchers" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: invoice-1042-v1" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"voucher": {
"voucherType": "Sales",
"date": "2026-10-15",
"voucherNumber": "INV-1042",
"narration": "Invoice INV-1042",
"placeOfSupply": "Maharashtra",
"ledgerEntries": [
{
"ledger": "Mehta Retail",
"amount": 11800,
"billAllocations": [
{ "name": "INV-1042", "billType": "New Ref", "amount": 11800, "dueDate": "2026-11-14" }
]
},
{ "ledger": "Sales", "amount": -10000 },
{ "ledger": "Output CGST 9%", "amount": -900 },
{ "ledger": "Output SGST 9%", "amount": -900 }
]
}
}'
const voucher = {
voucherType: "Sales",
date: "2026-10-15",
voucherNumber: "INV-1042",
narration: "Invoice INV-1042",
placeOfSupply: "Maharashtra",
ledgerEntries: [
{
ledger: "Mehta Retail",
amount: 11800,
billAllocations: [{ name: "INV-1042", billType: "New Ref", amount: 11800, dueDate: "2026-11-14" }],
},
{ ledger: "Sales", amount: -10000 },
{ ledger: "Output CGST 9%", amount: -900 },
{ ledger: "Output SGST 9%", amount: -900 },
],
};
const { data } = await api("POST", "/v1/vouchers", {
body: { companyGuid: COMPANY_GUID, voucher },
key: "invoice-1042-v1",
});
// data: { valid: true, dryRun: true, resolution: "checked", resolved: {...}, gates?: [...], warnings?: [...] }
Post an IGST invoice
For a sale to another state. One tax entry instead of two.
curl -s -X POST "https://relay.autotally.ai/v1/vouchers" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: invoice-1043-v1" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"voucher": {
"voucherType": "Sales",
"date": "2026-10-16",
"voucherNumber": "INV-1043",
"placeOfSupply": "Karnataka",
"ledgerEntries": [
{
"ledger": "Nair Distributors",
"amount": 59000,
"billAllocations": [
{ "name": "INV-1043", "billType": "New Ref", "amount": 59000, "dueDate": "2026-11-15" }
]
},
{ "ledger": "Sales", "amount": -50000 },
{ "ledger": "Output IGST 18%", "amount": -9000 }
]
}
}'
const voucher = {
voucherType: "Sales",
date: "2026-10-16",
voucherNumber: "INV-1043",
placeOfSupply: "Karnataka",
ledgerEntries: [
{
ledger: "Nair Distributors",
amount: 59000,
billAllocations: [{ name: "INV-1043", billType: "New Ref", amount: 59000, dueDate: "2026-11-15" }],
},
{ ledger: "Sales", amount: -50000 },
{ ledger: "Output IGST 18%", amount: -9000 },
],
};
await api("POST", "/v1/vouchers", { body: { companyGuid: COMPANY_GUID, voucher }, key: "invoice-1043-v1" });
Post a receipt against a bill
The bank is debited, the party credited. Agst Ref settles the bill by name, and amount carries the
same sign as its entry. bankAllocations is optional.
curl -s -X POST "https://relay.autotally.ai/v1/vouchers" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: receipt-7001-v1" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"voucher": {
"voucherType": "Receipt",
"date": "2026-11-02",
"voucherNumber": "RCT-7001",
"narration": "NEFT against INV-1042",
"ledgerEntries": [
{
"ledger": "HDFC Bank",
"amount": 11800,
"bankAllocations": [
{ "transferMode": "NEFT", "utr": "HDFCN52026110212345", "instrumentDate": "2026-11-02" }
]
},
{
"ledger": "Mehta Retail",
"amount": -11800,
"billAllocations": [
{ "name": "INV-1042", "billType": "Agst Ref", "amount": -11800 }
]
}
]
}
}'
const voucher = {
voucherType: "Receipt",
date: "2026-11-02",
voucherNumber: "RCT-7001",
narration: "NEFT against INV-1042",
ledgerEntries: [
{
ledger: "HDFC Bank",
amount: 11800,
bankAllocations: [{ transferMode: "NEFT", utr: "HDFCN52026110212345", instrumentDate: "2026-11-02" }],
},
{
ledger: "Mehta Retail",
amount: -11800,
billAllocations: [{ name: "INV-1042", billType: "Agst Ref", amount: -11800 }],
},
],
};
await api("POST", "/v1/vouchers", { body: { companyGuid: COMPANY_GUID, voucher }, key: "receipt-7001-v1" });
billType is one of New Ref, Agst Ref, Advance or On Account. On Account takes no name.
transferMode is one of Cheque, NEFT, RTGS, IMPS, UPI, ECS, DD, Inter Bank Transfer,
Same Bank Transfer, Cash, Card, Electronic Cheque or Electronic DD/PO.
Post a payment
Paying a supplier: the supplier is debited, the bank credited. The bill name is the one in your books.
curl -s -X POST "https://relay.autotally.ai/v1/vouchers" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: payment-3301-v1" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"voucher": {
"voucherType": "Payment",
"date": "2026-11-03",
"voucherNumber": "PAY-3301",
"ledgerEntries": [
{
"ledger": "Gupta Steel Suppliers",
"amount": 45000,
"billAllocations": [
{ "name": "GS/2026/881", "billType": "Agst Ref", "amount": 45000 }
]
},
{
"ledger": "HDFC Bank",
"amount": -45000,
"bankAllocations": [
{ "transferMode": "RTGS", "utr": "HDFCR52026110354321", "paymentFavouring": "Gupta Steel Suppliers" }
]
}
]
}
}'
const voucher = {
voucherType: "Payment",
date: "2026-11-03",
voucherNumber: "PAY-3301",
ledgerEntries: [
{
ledger: "Gupta Steel Suppliers",
amount: 45000,
billAllocations: [{ name: "GS/2026/881", billType: "Agst Ref", amount: 45000 }],
},
{
ledger: "HDFC Bank",
amount: -45000,
bankAllocations: [{ transferMode: "RTGS", utr: "HDFCR52026110354321", paymentFavouring: "Gupta Steel Suppliers" }],
},
],
};
await api("POST", "/v1/vouchers", { body: { companyGuid: COMPANY_GUID, voucher }, key: "payment-3301-v1" });
Alter a voucher
PATCH replaces the whole voucher: entries you leave out are dropped. Read it first, change it, and
send all of it. The read shape is not the write shape: an entry's ledgerName on a read is ledger on
a write. Money guards do not run on an alter.
GUID=9f8e7d6c-0000-0000-0000-000000000042
curl -s -X PATCH "https://relay.autotally.ai/v1/vouchers/$GUID" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: invoice-1042-edit-2" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"voucher": {
"voucherType": "Sales",
"date": "2026-10-15",
"voucherNumber": "INV-1042",
"narration": "Invoice INV-1042, PO 8841",
"ledgerEntries": [
{
"ledger": "Mehta Retail",
"amount": 11800,
"billAllocations": [
{ "name": "INV-1042", "billType": "New Ref", "amount": 11800, "dueDate": "2026-11-29" }
]
},
{ "ledger": "Sales", "amount": -10000 },
{ "ledger": "Output CGST 9%", "amount": -900 },
{ "ledger": "Output SGST 9%", "amount": -900 }
]
}
}'
const guid = "9f8e7d6c-0000-0000-0000-000000000042";
const { data: current } = await api("GET", `/v1/vouchers/${q(guid)}?company=${q(COMPANY)}`);
const voucher = {
voucherType: current.voucherType,
date: current.date,
voucherNumber: current.voucherNumber,
narration: "Invoice INV-1042, PO 8841",
ledgerEntries: current.ledgerEntries.map((e) => ({
ledger: e.ledgerName,
amount: Number(e.amount),
...(e.billAllocations?.length
? { billAllocations: e.billAllocations.map((b) => ({ ...b, amount: Number(b.amount) })) }
: {}),
})),
};
await api("PATCH", `/v1/vouchers/${q(guid)}`, {
body: { companyGuid: COMPANY_GUID, voucher },
key: "invoice-1042-edit-2",
});
This sketch carries ledger and bill entries only. If the voucher has inventory, cost-centre or bank details, carry those across too, or they are dropped.
Delete a voucher
Pass companyGuid in the query, and send no content-type header. A dry run checks the id's format
only, not that the voucher exists.
GUID=9f8e7d6c-0000-0000-0000-000000000042
curl -s -X DELETE "https://relay.autotally.ai/v1/vouchers/$GUID?companyGuid=$COMPANY_GUID" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "idempotency-key: invoice-1042-delete-v1"
await api("DELETE", `/v1/vouchers/${q(guid)}?companyGuid=${q(COMPANY_GUID)}`, {
key: "invoice-1042-delete-v1",
});
To commit, add &commit=true.
Create a ledger with a GSTIN
A Regular or Composition registration must carry a gstin. A master dry run checks the shape only.
Duplicate names are checked at commit.
curl -s -X POST "https://relay.autotally.ai/v1/ledgers" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-H "content-type: application/json" \
-H "idempotency-key: customer-8841-ledger-v1" \
-d '{
"companyGuid": "'"$COMPANY_GUID"'",
"ledger": {
"name": "Mehta Retail",
"group": "Sundry Debtors",
"isBillWise": true,
"email": "accounts@mehtaretail.example",
"panNumber": "AAPFM1234C",
"addresses": [
{
"addressLines": ["14 Station Road", "Andheri East"],
"state": "Maharashtra",
"country": "India",
"pinCode": "400069"
}
],
"gstRegistrationDetails": [
{
"applicableFrom": "2026-04-01",
"gstRegistrationType": "Regular",
"state": "Maharashtra",
"placeOfSupply": "Maharashtra",
"gstin": "27AAPFM1234C1Z5"
}
]
}
}'
const ledger = {
name: "Mehta Retail",
group: "Sundry Debtors",
isBillWise: true,
email: "accounts@mehtaretail.example",
panNumber: "AAPFM1234C",
addresses: [{
addressLines: ["14 Station Road", "Andheri East"],
state: "Maharashtra",
country: "India",
pinCode: "400069",
}],
gstRegistrationDetails: [{
applicableFrom: "2026-04-01",
gstRegistrationType: "Regular",
state: "Maharashtra",
placeOfSupply: "Maharashtra",
gstin: "27AAPFM1234C1Z5",
}],
};
await api("POST", "/v1/ledgers", { body: { companyGuid: COMPANY_GUID, ledger }, key: "customer-8841-ledger-v1" });
If the commit returns 409 similar_master_exists, look at candidates. To create it anyway, add
"acknowledge": ["similar-name"] beside companyGuid.
Trial balance with a status check
A 200 here does not promise figures. Always check for status. For the current financial year to
date the answer comes from storage. Any other period is asked of Tally live and can take up to 90
seconds, so give your client a long timeout.
curl -s -i "https://relay.autotally.ai/v1/reports/trial-balance?company=Sharma%20Traders" \
-H "authorization: Bearer $AUTOTALLY_TOKEN"
const { data: tb, headers } = await api("GET", `/v1/reports/trial-balance?company=${q(COMPANY)}`);
if (tb.status) {
// "no_snapshot_yet" or "not_available_offline": there are no figures in this response.
console.log(tb.message, tb.available);
} else {
console.log(tb.from, tb.to, tb.totalDebit, tb.totalCredit);
console.log("source", headers.get("x-tally-source"), "as of", headers.get("x-tally-synced-at"));
}
Follow a write to confirmation
A commit gives you an intentId. Poll it until the write is confirmed or has stopped.
curl -s "https://relay.autotally.ai/v1/intents/$INTENT_ID" \
-H "authorization: Bearer $AUTOTALLY_TOKEN"
async function confirmVoucher(intentId) {
for (;;) {
const { data: w } = await api("GET", `/v1/intents/${q(intentId)}`);
if (w.state === "failed") throw new Error(`Tally refused it: ${w.error}`);
if (w.state === "rejected") throw new Error("Rejected or retracted");
if (w.state === "applied" && w.resultGuid) {
// `applied` is Tally's answer. The read back is the proof.
const { data: voucher } = await api("GET", `/v1/vouchers/${q(w.resultGuid)}?company=${q(COMPANY)}`);
return voucher;
}
await new Promise((resolve) => setTimeout(resolve, 30_000));
}
}
In production, run this from a background job, not a loop: a pending write can wait for days. See
The write state machine.
Upload a bill
Send multipart/form-data with the file, and the company's guid in company. Use a key with
Allow writes on. Reading a document spends credits, and a workspace with none gets
402 insufficient_credits.
curl -s -X POST "https://relay.autotally.ai/v1/documents" \
-H "authorization: Bearer $AUTOTALLY_TOKEN" \
-F "file=@bill.pdf;type=application/pdf" \
-F "company=$COMPANY_GUID"
import { readFile } from "node:fs/promises";
const form = new FormData();
form.set("file", new Blob([await readFile("bill.pdf")], { type: "application/pdf" }), "bill.pdf");
form.set("company", COMPANY_GUID);
const res = await fetch(`${BASE}/v1/documents`, {
method: "POST",
headers: { authorization: `Bearer ${TOKEN}` },
body: form,
});
const document = await res.json();
201 means it was read. The body has the documentId and state. 502 means the file was stored but
could not be read, with "state": "failed". See Documents.
