账审通 API 开发者文档
简单的 REST API 及已签名的 Webhooks,让你把 Zapier、Make、n8n、POS 收银机、网店及自家程序连接到香港公司的账目。
开始使用
- 由所有者或管理员创建 API 密钥: 设置 → API 及 Webhooks
- 选择权限(读取、写入)及密钥可访问哪些公司。复制密钥——只会显示一次。
- 经 HTTPS 调用 API,并在 Authorization 标头附上密钥。所有请求及响应都是 JSON;日期格式为 YYYY-MM-DD;金额以公司本位币计,两位小数。
所有付费方案及 14 日免费试用均包括 API 及 Webhooks。订阅到期后密钥会暂停,续订即恢复;数据会保留。
基本网址: https://auditrangers.com/api/v1
身份验证
每个请求都以 Bearer token 形式附上密钥:
Authorization: Bearer ar_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX- 请妥善保管密钥,只在服务器使用——切勿放在网页或手机 App 内。
- 读取密钥只可读数据;写入密钥另可创建往来单位及草稿凭证。经 API 创建的凭证一律是草稿,由同事在账审通审核及过账。
- 密钥可限制只访问部分公司。密钥被撤销,或创建者不再是所有者或管理员时,立即失效。
- 我们只储存密钥的指纹(SHA-256),遗失的密钥无法取回——请撤销并创建新密钥。
错误
错误使用标准 HTTP 状态码,并返回 JSON:
{ "error": { "code": "unbalanced", "message": "debits (100) must equal credits (90)" } }| 400 | invalid_request / invalid_json |
| 401 | unauthorized |
| 403 | insufficient_scope / company_forbidden / plan_required |
| 404 | not_found |
| 413 | payload_too_large |
| 415 | unsupported_media_type |
| 422 | unbalanced / period_locked |
| 429 | rate_limited |
次数限制及分页
每个密钥每分钟最多 120 个请求,超过会收到 429 及 Retry-After 标头。以错误密钥重复尝试会被暂停一分钟。
凭证及发票列表会返回 next_cursor,把它作为 cursor 参数即可取得下一页(null 代表已完)。往来单位使用 limit 及 offset,并返回 next_offset。
端点
把 $AR_KEY 换成你的密钥,$COMPANY 换成 GET /companies 返回的公司 id。
GET/api/v1/companiesread
列出此密钥可访问的公司,包括本位币及财政年度开始月份。
curl https://auditrangers.com/api/v1/companies \
-H "Authorization: Bearer $AR_KEY"GET/api/v1/companies/{id}/accountsread
会计科目表:编号、繁体/英文/简体名称、类型,以及是否按往来单位核算。
curl https://auditrangers.com/api/v1/companies/$COMPANY/accounts \
-H "Authorization: Bearer $AR_KEY"GET/api/v1/companies/{id}/contactsread
客户、供应商、员工及其他往来单位。
查询参数: kind, limit (≤500), offset
curl "https://auditrangers.com/api/v1/companies/$COMPANY/contacts?kind=customer&limit=100" \
-H "Authorization: Bearer $AR_KEY"POST/api/v1/companies/{id}/contactswrite
新增往来单位。字段:kind(customer、supplier、employee、other)、name,以及可选的 code、email、phone、address、currency、credit_days。
curl -X POST https://auditrangers.com/api/v1/companies/$COMPANY/contacts \
-H "Authorization: Bearer $AR_KEY" -H "Content-Type: application/json" \
-d '{"kind":"customer","name":"Example Trading Ltd","email":"ap@example.com","currency":"HKD","credit_days":30}'GET/api/v1/companies/{id}/vouchersread
凭证连分录(草稿、已提交、已批核、已过账及作废),按日期排序。
查询参数: from, to (YYYY-MM-DD), limit (≤500), cursor
curl "https://auditrangers.com/api/v1/companies/$COMPANY/vouchers?from=2026-04-01&to=2026-11-30&limit=200" \
-H "Authorization: Bearer $AR_KEY"POST/api/v1/companies/{id}/voucherswrite
创建草稿凭证。每行包括 account_code 及借方(debit)或贷方(credit)其中一项(最多两位小数),另可加 description 及 contact_id。借贷必须相等;日期在已锁定期间会被拒绝。
curl -X POST https://auditrangers.com/api/v1/companies/$COMPANY/vouchers \
-H "Authorization: Bearer $AR_KEY" -H "Content-Type: application/json" \
-d '{"date":"2026-11-28","description":"POS daily takings",
"lines":[{"account_code":"1010","debit":1250.50},
{"account_code":"4000","credit":1250.50,"description":"Sales"}]}'GET/api/v1/companies/{id}/invoicesread
销售发票连明细、总额、已收款及结欠。
查询参数: status (draft|issued|partial|paid|void), limit, cursor
curl "https://auditrangers.com/api/v1/companies/$COMPANY/invoices?status=issued" \
-H "Authorization: Bearer $AR_KEY"GET/api/v1/companies/{id}/reports/trial-balanceread
按已过账凭证计算的试算表:每个科目的期初、借方、贷方及期末余额。from 默认为财政年度第一日。
查询参数: from, to
curl "https://auditrangers.com/api/v1/companies/$COMPANY/reports/trial-balance?to=2027-03-31" \
-H "Authorization: Bearer $AR_KEY"GET/api/v1/companies/{id}/reports/profit-and-lossread
按已过账凭证计算的损益表,附上期比较。
查询参数: from, to
curl "https://auditrangers.com/api/v1/companies/$COMPANY/reports/profit-and-loss?from=2026-04-01&to=2026-11-30" \
-H "Authorization: Bearer $AR_KEY"GET/api/v1/companies/{id}/reports/balance-sheetread
按已过账凭证计算、截至指定日期的资产负债表,附上年比较。
查询参数: to
curl "https://auditrangers.com/api/v1/companies/$COMPANY/reports/balance-sheet?to=2026-11-30" \
-H "Authorization: Bearer $AR_KEY"暂时未能经 API 上传单据及发票。请在 App、电邮或 WhatsApp 上传——document.uploaded Webhook 会通知你的系统有新单据。
Webhooks
在“设置 → API 及 Webhooks”新增 Webhook,并选择需要的事件:
| voucher.created | 创建了凭证(任何状态) |
| voucher.posted | 凭证已过账 |
| invoice.created | 创建了销售发票 |
| invoice.paid | 销售发票已全数收款 |
| document.uploaded | 上传了单据或文件 |
我们会发出 HTTPS POST,内容是以下格式的 JSON。data 只包括主要字段,详细数据请调用 API。
{
"id": "6f1c…", // event id (same across retries)
"event": "voucher.posted",
"created_at": "2026-11-28T09:15:02.123+00:00",
"data": { "id": "…", "company_id": "…", "number": "202611-0042",
"date": "2026-11-28", "status": "posted", "amount": 1250.50 }
}每个请求都带有以下标头:
X-AuditRangers-Event: voucher.posted
X-AuditRangers-Delivery: <event id>
X-AuditRangers-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + "." + raw body)>用创建 Webhook 时显示的签名密钥验证签名(Node.js 例子):
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
const app = express();
// Verify against the raw body (do not JSON.parse and re-stringify first)
app.post('/auditrangers', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-AuditRangers-Signature') ?? ''; // t=1764300000,v1=ab12…
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const body = req.body.toString('utf8');
const expected = createHmac('sha256', process.env.AR_WEBHOOK_SECRET)
.update(`${parts.t}.${body}`).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300; // within 5 minutes
const ok = fresh && parts.v1?.length === 64 &&
timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(parts.v1, 'hex'));
if (!ok) return res.status(400).send('bad signature');
const event = JSON.parse(body); // { id, event, created_at, data }
// De-duplicate by event.id: retries keep the same id
res.sendStatus(200);
});- 请在 10 秒内回复任何 2xx 状态码。我们不会跟随重定向。
- 发送失败会重试最多 8 次,相隔约 2、4、8、16… 分钟。事件偶尔可能重复或次序不同——请以事件 id 去重。
- Webhook 网址必须使用 https 及公开域名;私有及本机网络地址会被拒绝。
Zapier、Make 及 n8n
不用写程序:Zapier、Make 及 n8n 可通过内置的 Webhooks 及 HTTP 模块使用此 API。
- 接收事件:在 Zapier 创建“Catch Hook”(Webhooks by Zapier)、在 Make 创建“Custom webhook”或在 n8n 创建“Webhook”触发器,再把它的 https 网址加为 Webhook。
- 传入数据:使用 Zapier 的“Webhooks by Zapier → Custom Request”、Make 的“HTTP → Make a request”或 n8n 的“HTTP Request”节点,并在 Authorization 标头填上 Bearer 及你的密钥。
- 例子:网店每有一笔销售,就创建一张借银行、贷销售收入的草稿凭证,由会计审核后过账。