{"article":{"title":"Reconciliation API","breadcrumb":["Billing","Reconciliation API"],"body":"**What this solves**: Lets a finance system, ERP, or dashboard pull accounts from Tare automatically, without a human logging into the console.\n\nThe Reconciliation API is an accounting interface for **machines**. It authenticates with a Reconciliation key, not an Inference key, and doesn't need to simulate a console login.\n\n### When to use the Reconciliation API\n\n- Sync balance and transactions daily.\n- Pull locked statements at month-end.\n- Break usage down by key, model, and date.\n- Compare Tare's accounts with your upstream providers' bills.\n\n### Integration advice\n\n1. Create a Reconciliation key.\n2. Set an expiry on it.\n3. Start with `/whoami` to confirm the account, period, and time zone.\n4. Sync `/balance` and `/transactions`.\n5. Sync `/statements` at month-end.\n6. When you need business breakdowns, pull `/usage/daily` and `/attribution`.\n7. When you need to check upstream bills, pull `/reconciliation`.\n\n> [!WARNING]\n> A Reconciliation key **can only read accounts**; it can't call models, and it can't manage keys. The reverse is also true: **don't put a spend-capable Inference key into a finance system**.\n\n![Reconciliation API integration order: start from whoami, pull statements at month-end](diagram:en-integration-api-sequence)\n\n### Details\n\n#### Use a reconciliation key, not an inference key\n\nReconciliation endpoints need a **reconciliation key** (integration key). Create one on the console's API Keys page, choosing Reconciliation as the type; it can also be issued by the platform on your behalf.\n\n> [!WARNING]\n> The three key types have non-overlapping permissions. Using the wrong type returns a **clear rejection**, not a vague 401:\n>\n> | Key type | Permission |\n> |---|---|\n> | Inference key | Call models |\n> | Reconciliation key | Read reports, **cannot call models** |\n> | Provisioning key | Manage keys, **can neither call models nor read accounts** |\n\n#### Endpoints\n\nBase: `https://tare.jamerly.ai/v1/integration`\n\n| Path | Purpose |\n|---|---|\n| `/whoami` | Whose key this is, the current period, accessible resources |\n| `/balance` | Balance, credit limit, available credit, cumulative top-ups and spend |\n| `/transactions` | Transactions, paginated |\n| `/statements` | Monthly statement list |\n| `/statements/{period}` | The statement for one period, e.g. `2026-07` |\n| `/usage/daily` | Daily usage, filterable by `apiKeyId` |\n| `/attribution` | Cost, request count, retry / tool-failure waste, **broken down by model and by stage**. Currently no filtering by `usage_label`, `task_id`, or `action_code`; only the three parameters `from` / `to` / `apiKeyId` |\n| `/reconciliation` | Differences between platform accounts and upstream bills |\n\n```bash\ncurl https://tare.jamerly.ai/v1/integration/balance \\\n  -H \"Authorization: Bearer $TARE_INTEGRATION_KEY\"\n```\n\n> [!WARNING]\n> **This response wraps only one layer** (`response.data.balance`). If you put another Java gateway in front and forward this path through it (instead of hitting `tare.jamerly.ai` directly as above), the gateway adds its own envelope, making it two layers of nesting (`response.data.data.balance`). For how to tell which one you got, see [Error codes](errors).\n\n#### Granularity: balance is account-level, usage can be split by key\n\n`/balance` and `/transactions` are **account-level**; all keys under the same account share one wallet.\n\nThis is consistent with the role a key plays: **a key is a billing unit**, usage can be split by key, and the balance is shared. To limit a single key's spend, use the `limit` of the [Provisioning key](provisioning), which is a separate mechanism.\n\n**Splitting usage by key**: `/usage/daily?apiKeyId=…`.\n\n#### Two limits\n\n- **A single query window is capped at 100 days.** A year's reconciliation takes four pulls. Exceeding it returns a clear error rather than silently truncating — a scheduled job starting from `from=2020-01-01` will fail clearly here, instead of getting data quietly cut short.\n- **Rate limit 1200/minute**, counted separately from model traffic. Reconciliation often pages through hundreds of pages by day, by key, by model; the model-tier threshold **will 429 on first integration**.\n\n#### Field stability\n\nThe response fields of these endpoints are a **stability promise** and won't be renamed by later implementation changes. If you need OpenAPI / JSON Schema descriptions, see the last section of [Endpoint list](endpoints).\n\n#### Two prerequisites for reconciliation\n\n**The period is split by some time zone.** `2026-07` is just a string; its starting instant isn't self-evident, so every response carries the time zone used for the split. If your side splits months by a different time zone, the usage on the last day of the month falls into a different month, the two sides never reconcile, and the difference is small enough to be mistaken for rounding error.\n\n**Late corrections count toward the next period.** A locked statement isn't rewritten. If your ERP expects \"when a correction arrives, last month's numbers change with it\", that won't happen. Look for the top-up line in the current period; it notes which month it came from.\n\n### Next steps\n\n- Want to understand why statements lock and where top-ups come from: read [Statements and invoices](statements).\n- Want to figure out which costs land on you: read [Billing rules](billing).\n- Want to see all available endpoints: read [Endpoint list](endpoints).\n"},"diagrams":{"en-integration-api-sequence":"<svg viewBox=\"0 0 708 361\" width=\"708\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Reconciliation API: whoami, then the month-end bill</title>\n  <desc>A finance system starts with GET /whoami, syncs /balance and /transactions daily, pulls /statements at month-end, then /usage/daily and /attribution for a business split, and /reconciliation to check the upstream bill.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow-blue\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#3b82f6\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"708\" height=\"361\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       只有两位参与者，各宽 318、间距 28，于是 22..340 / 368..686；\n       同一行里的两框必须挨着 25–30px，所以参与者不能摆成一左一右隔开半张图。\n       生命线落在各框中心 181 / 527，从 101 收到 280。\n       消息行从 130 起、行距 32；五条消息，末行 258。\n       右键起点 = 181 + 5 = 186，终点 = 527 - 11 = 516（12px 起点间隙 + 6px 箭头尖），\n       通道宽 330，标签居中在 351，压在消息线上方 13px。\n       内容左右边界 22..686，中心 354；viewBox 宽 = 664 + 两侧各 22 = 708。\n       高度 = 脚注末行基线 336 + 下伸 2.5 + 22px 边距 = 360.5，取整 361。 -->\n\n  <text x=\"354\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Reconciliation API: whoami, then the month-end bill</text>\n\n  <rect x=\"22\" y=\"60\" width=\"318\" height=\"36\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"181\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Your job / finance system</text>\n  <rect x=\"368\" y=\"60\" width=\"318\" height=\"36\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"527\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Tare /v1/integration</text>\n\n  <path d=\"M181,101 L 181,280\" fill=\"none\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n  <path d=\"M527,101 L 527,280\" fill=\"none\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n\n  <path d=\"M186,130 L 516,130\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"351\" y=\"117\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">GET /whoami — account, period, timezone</text>\n\n  <path d=\"M186,162 L 516,162\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"351\" y=\"149\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">GET /balance · /transactions — daily sync</text>\n\n  <path d=\"M186,194 L 516,194\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"351\" y=\"181\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">GET /statements — locked bills at month-end</text>\n\n  <path d=\"M186,226 L 516,226\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"351\" y=\"213\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">GET /usage/daily · /attribution — by business</text>\n\n  <path d=\"M186,258 L 516,258\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"351\" y=\"245\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">GET /reconciliation — check the upstream bill</text>\n\n  <!-- 脚注 -->\n  <text x=\"354\" y=\"306\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Create a Reconciliation key with an expiry. It only reads billing. It cannot call models or manage keys.</text>\n  <text x=\"354\" y=\"321\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Do not put a spending Inference key in finance. One query covers 100 days, so a year is four pulls.</text>\n  <text x=\"354\" y=\"336\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Limit 1200/min, apart from model traffic. /balance and /transactions are account-level, one shared wallet.</text>\n</svg>\n"}}