Skip to content

Agent API ​

The Agent API is a read-only HTTP surface AI agents (Claude, Cursor, custom bots) and external integrations use to read your Cash Runway data. Every endpoint is JSON, bearer-token authenticated, and scoped — see API keys for how to provision one.

This guide is the high-level operator tour. If you're handing a key to an engineer, point them at the API reference for the full schema catalogue.

Endpoint surface at a glance ​

EndpointRequired scopeWhat it returns
GET /api/agent/statusanySubscription, query-credit usage, and key context. Session bootstrap. Exempt from query-credit counting.
GET /api/agent/bank-accountsREAD_BANKActive bank accounts and balances (reconciled + statement).
GET /api/agent/cash-positionREAD_FORECASTToday's cash position with per-account breakdown.
GET /api/agent/forecastREAD_FORECASTThe 13-week rolling forecast.
GET /api/agent/invoicesREAD_INVOICESAR invoices, with amountDue / amountPaid outstanding balances. Filter by status, contact, date range. Optional ?lines=true, ?credits=true.
GET /api/agent/billsREAD_INVOICESAP bills. Same shape as /invoices.
GET /api/agent/credit-notesREAD_INVOICESCredit notes. ?type=customer (default, AR) / supplier (AP) / all; every row carries type. ?invoiceNumber= / ?invoiceExternalId= answer "what credited this invoice (or bill)?".
GET /api/agent/contactsREAD_CONTACTSCustomers and suppliers. Filter by type, sort by revenue / spend / recency.
GET /api/agent/contacts/{id}READ_CONTACTSSingle-contact drill — LTV, payment cadence, ABC tier, recent paid invoices, availableCredit (AR credit held) and availableSupplierCredit (AP credit the supplier owes us).
GET /api/agent/daily-summaryREAD_SUMMARYComposite "how's my business going?" surface with a prose narrative.
GET /api/agent/quotesREAD_QUOTESXero sales quotes. Filter by status, customer, creator, issue date and expiry date. DELETED excluded unless requested. See Quotes.
GET /api/agent/quotes/{id}READ_QUOTESOne quote by GUID or quote number, with terms and lineItems.

Pick the narrowest scope set the integration needs. Sensitive-data gating applies automatically — see API keys.

Two things the table understates. GET /api/agent/contacts carries each contact's email and accountNumber on every list row, so assembling a send-to list for an AR chase is one call — not one drill per customer — and contactDetailsSyncedAt is what separates "Xero holds no address" from "we have never looked". GET /api/agent/invoices accepts ?sent=false to find invoices raised but never delivered. Both are written up in full in the CLI and MCP guides.

Chasing debt: read amountDue ​

/invoices and /bills return three money fields, all decimal strings:

FieldMeaning
amountDueWhat is still outstanding. The chase figure.
amountPaidCash actually received (or paid, on a bill).
amountState-dependent — see below. Not a stable "face value".

amount is not what you might assume, and this is the important part. On an open invoice or bill it holds the outstanding balance — the same figure as amountDue, because that is what the sync writes it from. Once a document settles it is usually rewritten to the gross total, but not dependably: a document settled by a payment we saw before we re-read the document keeps the balance it already had.

So amount is best treated as not a reliable figure for anything on its own — not as "outstanding" and not as "invoiced". In particular, do not sum it and call the result invoiced revenue or AP spend, and note that ?totals=true aggregates the same field, so it is not a way around this. If you are asked what was invoiced rather than what is owed, say the figure available here is balance-based and name the limitation.

Given all that, why read amountDue at all if it usually matches on open rows?

  1. Honest nulls. When Xero returns no AmountDue, amount records 0 — indistinguishable from a settled document — while amountDue records null, meaning unknown. Rendering null as 0 reports a live debt as settled. Say "we haven't checked" instead.
  2. Stable meaning. amountDue means outstanding on every row, open or paid. It does not flip meaning underneath you the way amount does.

amountPaid is likewise nullable with the same null = unknown rule.

A PAID row can report amountDue: null, and that is deliberate. When we see a payment for an invoice we have not re-read, we settle the row and retract both money fields to null. The alternative is worse in both directions: leaving the pre-payment figures publishes a balance owing on a document the same response calls PAID, and writing 0 claims a settlement we cannot prove — one payment is not necessarily the last one. So on a paid row, null means "we have not re-read this document yet"; a later sync fills it in. Treat it as unknown, exactly as anywhere else.

Do not derive amountPaid as amount − amountDue. On an open document those two hold the same figure, so the result is 0 however much has been paid; on a credit-note-settled document it returns the full face value and reports the invoice as paid in cash when nothing was received.

Was it credited? ?credits=true ​

Add ?credits=true to /invoices or /bills and every row gains creditedAmount (the total value of credit notes applied to it) and creditNotes[] (each credit's number, allocation date and amount). That answers "was this invoice credited down?" from the invoice you already hold, in one call.

This is the only reliable way to detect a credit — ask, don't infer. No arithmetic over amount, amountDue and amountPaid will find one on an open invoice, because amount and amountDue hold the same figure there:

SituationamountamountDueamountPaidamount − amountDue − amountPaid
Open, $296.12 credited down to $22222200 — misses the credit
Open, $500 with $200 paid in cash300300200−200 — invents a credit

The first row is exactly the case this feature was built for, and the second would have an agent assert a credit that does not exist — then be contradicted by creditedAmount: "0" on the very next call. On a paid invoice, amountDue: "0" together with amountPaid: "0" is a fair hint that a credit note rather than cash closed it; confirm with ?credits=true before reporting it.

Both keys are absent when the flag is off, so their null never means "you didn't ask". When present:

  • "0" / [] — known-and-none. We hold this org's allocation data and no credit note touches this document.
  • null — unknown. Four ways to get here, and only one of them is temporary: no allocation data has been normalised for the org yet (transient — the backfill fixes it); Xero omitted the amount on a matched allocation (creditNotes[] still lists it, so you can go and look); the org has never had a credit note at all, in which case it holds no allocation rows and reads null permanently; or a credit note applied to the document is sensitive (sensitive contact, or a line on a sensitive account) and your key lacks READ_SENSITIVE. In that last case the hidden credit is left out of creditNotes[] and the total is withheld, so the response neither itemises nor sums it. That withholds the itemisation only: the amount can still be worked out from the document's amount / amountDue / amountPaid and the visible entries.

Because of the third case, null does not mean "check back later". When creditNotes is also null, read it as "no credit-note data is recorded for this org" and say so. When creditNotes is an array and none of its entries has a null amount, say instead that credit has been applied which your key is not permitted to see. (A hidden credit and a Xero-omitted amount can occur on the same document, so an array that does contain a null-amount entry is ambiguous between the two.) An agent that reports "data still arriving" against a credit-free org will keep saying it forever.

Voided and deleted credit notes are excluded — a voided credit reduces nothing. AR credit notes offset invoices and AP credit notes offset bills; the two are never crossed.

From the other direction, GET /api/agent/credit-notes?invoiceNumber=LR-4359 (or ?invoiceExternalId=) returns the credit notes applied to a given invoice. The two parameters name the same invoice by different keys and compose as OR, because Xero populates either, both or neither per allocation.

Customer and supplier credit notes ​

/api/agent/credit-notes returns customer (AR, Xero ACCRECCREDIT) credit notes unless you ask otherwise. Pass ?type=supplier for supplier (AP, ACCPAYCREDIT) credits — money a supplier owes you — or ?type=all for both. Every row carries type: "customer" | "supplier". Any other type value is a 400 (invalid_type) rather than a silent fallback, so a supplier question can never be answered with customer credits. For supplier credits the reverse lookup's invoiceNumber is the bill number.

GET /api/agent/credit-notes/{id} resolves either side. A Xero GUID is unique; a credit-note number is not — supplier numbers are the supplier's own, often blank, and often collide with your own CN-#### series. When a number matches more than one credit note the drill answers 409:

json
{
  "error": "ambiguous",
  "candidates": [
    { "externalId": "c5ac705b-…", "type": "customer", "contactName": "Ecoview Melbourne", "xeroStatus": "AUTHORISED" },
    { "externalId": "0b8e2a4c-…", "type": "supplier", "contactName": "Widget Supplies", "xeroStatus": "AUTHORISED" }
  ]
}

Re-request with the externalId you want. If several credit notes share the number but exactly one is still live (not VOIDED / DELETED), the drill returns that one instead of a 409.

Sensitivity is at least as strict as on invoices and bills (line accounts are always checked, codes trimmed): without READ_SENSITIVE, a credit note whose contact is sensitive or any of whose lines is coded to a sensitive account is hidden in full — dropped from the list (counted in redactedItemCount), 404 on the drill, never listed as a 409 candidate. As on invoices (F8.6.139), totalCount and totals are computed before that drop, so they include credit notes your key cannot see.

totals include every status unless ?status= narrows them. For "how much open credit is there?", pass ?status=AUTHORISED and read remainingCredit. A voided or deleted credit note reports allocatedAmount: "0".

The contact drill reports both sides as separate scalars: availableCredit (customer credit the contact holds) and availableSupplierCredit (supplier credit they owe you), each in the org's base currency and never summed together. Without READ_SENSITIVE, credit notes with a line on a sensitive account are left out of both sums, so they agree with what the credit-note list shows the same key.

Quotes ​

GET /api/agent/quotes lists the company's Xero sales quotes; it needs the dedicated READ_QUOTES scope, which READ_INVOICES does not imply and which an admin grants per member on the Team page. Quotes are read-only and do not feed the forecast.

  • Filters: ?status= (comma list of DRAFT, SENT, DECLINED, ACCEPTED, INVOICED, DELETED), ?contactId= (customer GUID), ?dateFrom= / ?dateTo= on the issue date and ?expiryDateFrom= / ?expiryDateTo= on the expiry date, and ?createdBy= (part of the creator's name). Date bounds are inclusive, so ?status=DRAFT,SENT&expiryDateTo=2026-12-31 answers "which open quotes expire by year end?".
  • DELETED quotes are kept but hidden. Without ?status= every status except DELETED is returned, and totalCount and totals follow the same rule. Name DELETED in ?status= to see them.
  • ?totals=true groups by status. totals.grandTotal sums every status that was returned, so for the open quoted value pass ?status=DRAFT,SENT first. Quotes in more than one currency return the mixedCurrency shape instead of a sum.
  • Money fields are decimal strings in the quote's currency. subTotal, totalTax and totalDiscount are null when Xero did not send them.
  • Who created, edited and sent it. Every quote carries createdBy and createdAt (who raised it in Xero, and when), lastEditedBy / lastEditedAt and lastSentBy / lastSentAt. Xero has no such fields on a quote, so they come from its quote history and are null until that history has been fetched (it is filled in a batch per sync, newest quotes first, and re-fetched when a quote changes in Xero), or when the event never happened (a quote that was never edited has no lastEditedBy). createdBy is the person who raised the quote in Xero, which is not always the deal owner. createdAt is the Xero creation time, not when CashRunway stored the quote. ?createdBy= matches part of the creator's name, ignoring case and taking the text literally (% and _ are not wildcards; over 200 characters matches nothing), and narrows the rows, totalCount and totals together; quotes whose history has not been fetched yet never match it.

GET /api/agent/quotes/{id} accepts the Xero GUID or the quote number. Quote numbers can repeat in Xero; a number lookup returns a live quote over a deleted one, then the most recently updated. A quote that only exists as deleted is returned with status: "DELETED".

Sensitive contacts are handled more strictly than on invoices: without READ_SENSITIVE a sensitive customer's quotes are left out of the rows, totalCount and totals alike, and the drill answers 404. On this endpoint redactedItemCount is a flag, not a count: 1 means the organisation has quotes withheld from your key, whatever filters you passed, and 0 otherwise (always 0 with READ_SENSITIVE). It deliberately does not narrow with your filters, so it cannot be used to count a hidden customer's quotes. Quotes with no contact are never hidden by this rule.

Voided documents ​

Voided and deleted documents are kept as tombstones rather than removed, so an absence is now reportable as a fact. They are excluded from /invoices and /bills by default — including from totalCount and ?totals=true — and appear only when you name VOIDED or DELETED in ?status=. Each carries voidedAt: when the sync observed the void, not when the operator performed it (Xero does not expose the latter).

Two caveats before concluding anything from an empty void ledger:

  • History only reaches back 90 days, or to the sync cursor if that is earlier. Documents voided and pruned before this shipped are gone.
  • As a filter, VOIDED and DELETED are aliases — both select every tombstone. Discriminate on each row's xeroStatus.

Start here: daily-summary ​

For a generic AI assistant, daily-summary is the right first call. It returns enough context for an LLM to answer "how's my business going today?" in a single request:

  • cashToday — current cash position and bank-account count.
  • last7d — net cash flow plus top 5 inflows and top 5 outflows.
  • ar — aging buckets (current / 30 / 60 / 90+).
  • anomalies — pending anomaly count.
  • forecast13w — ending cash, lowest point, break-even date.
  • narrative — deterministic 2-4 sentence prose summary. The LLM doesn't need to derive "business is doing well" from raw numbers — the endpoint says so.
  • notesForAgent[] — plain-language signals (seasonality, AR risk, customer concentration) the LLM can quote without re-deriving.

Provision a key with just READ_SUMMARY to start; add the narrower scopes later when the assistant needs to slice deeper.

Example call ​

Every endpoint takes a bearer token in the Authorization header:

bash
curl -sS https://app.cashrunway.ai/api/agent/daily-summary \
  -H "Authorization: Bearer $CASHRUNWAY_API_KEY" \
  -D - | jq

The -D - flag prints response headers — X-CashRunway-Quota-Remaining is the one worth reading on every call. When quota drops below 10%, the response body folds in a billingAlert field.

See Agentic API — Example calls for curl, TypeScript, and Python recipes against the full endpoint set.

Tool tagging (for MCP / CLI clients) ​

Every endpoint accepts an optional X-CashRunway-Tool request header. MCP servers and CLI clients set it to record the calling tool name in the audit log (e.g. X-CashRunway-Tool: cashrunway.list_invoices). The value must match ^cashrunway\.[a-z_]+$ — bad values are silently ignored.

Operators using curl, direct fetch, or any current production integration don't need to set this header. It costs nothing to add (quota counts once per request either way) but adds nothing if the only consumer is your own script.

Rate limits ​

  • Per-key burst cap: 60 requests per minute per endpoint.
  • Query credits: metered per (user, account) in a rolling 5-hour window — Free 10 / Pocket 50 / Wallet 250 / Vault 1,000 / Reserve 5,000 per window. Credits free up continuously as each call ages past 5 hours; the usage block reports remaining, nextCreditInMinutes, fullResetInMinutes, and windowResetAt. Run dry and you can upgrade or let Cushion top up. See Plans, query credits & accounts.
  • /api/agent/status is exempt from query-credit counting — agents can poll it freely for session bootstrap.

Pacing a batch sweep ​

The credit window rolls; it does not reset on a schedule. Credits come back one at a time, each as the call that consumed it ages past five hours. There is no moment when the whole allowance returns at once, so a sweep that pauses "until the reset" waits far longer than it needs to.

When you are out of credits the API answers 429 with:

json
{
  "error": "daily_limit_exceeded",
  "usedToday": 250,
  "limit": 250,
  "remaining": 0,
  "resetAt": "2026-08-13T16:06:27.358Z",
  "nextCreditInMinutes": 3
}
  • nextCreditInMinutes — the wait until the first credit frees, i.e. until exactly one more call is possible. Also sent as Retry-After (seconds) and X-CashRunway-Reset-Minutes. Pace retries off this.
  • resetAt — the much later instant when every credit has returned. Useful for reporting; wrong for scheduling a retry.

So the right shape for a long sweep is: run until 429, sleep Retry-After, make one call, repeat — the window drip-feeds you. Once past the initial burst, the sustained rate settles at roughly limit calls per five hours.

Reading your own budget

/api/agent/status returns the same numbers under usage, and it is free to call. usage.limit is the cap actually enforced against your seat — including any trial entitlement — so usage.used should never exceed it.

See the API reference overview for the full header contract and response-shape catalogue.

Released under a proprietary license. · cashrunway.ai