GET /api/agent/purchase-orders
Returns the caller's org Xero purchase orders. Filterable by raw Xero status (comma-separated string match: DRAFT/SUBMITTED/AUTHORISED/BILLED/DELETED), contactId (supplier), itemCode (single code, fully case-insensitive in both directions; ANDs with the other filters and narrows totalCount/totals too), and issue-date range. Each row carries itemCodes — the distinct item codes across the PO's lines, [] when none — so callers can see which items a PO covers without drilling it. Same pagination/totals/redaction semantics as /api/agent/invoices (cursor + nextCursor, ?autoPaginate=true 5,000-row cap with truncated, ?totals=true aggregate block grouped by raw status, totalCount, sensitive-contact drop with redactedItemCount). Each PO row carries suppressedReason (nullable): when non-null the PO has been matched to a supplier bill and is excluded from the forecast to avoid double-counting the outflow. Read-only; requires the dedicated READ_PURCHASE_ORDERS scope (NOT implied by bill/invoice access).
Auth
- Required scope:
READ_PURCHASE_ORDERS - Header:
Authorization: Bearer cr_live_<prefix>_<secret>
Query parameters
| Name | Type | Required | Notes |
|---|---|---|---|
status | string | no | Comma-separated raw Xero PO statuses (e.g. AUTHORISED,BILLED). Direct string match. |
contactId | string | no | |
itemCode | string | no | Single Xero item code. Returns only POs whose itemCodes contain it, and narrows totalCount and ?totals=true alongside the rows. Matching is fully case-insensitive: the query and the stored code are compared in lowercase, so zc-relay, ZC-RELAY and Zc-Relay all find a PO however its code is spelled in Xero — including one stored in mixed case such as TCI-DALI Supply Fit Leads. Single value only — unlike status, a comma-separated list is NOT split and will match nothing. An empty or whitespace-only value is ignored (no filter). |
dateFrom | string | no | Inclusive issue-date lower bound (YYYY-MM-DD). |
dateTo | string | no | Inclusive issue-date upper bound (YYYY-MM-DD). |
cursor | string | no | |
limit | integer | no | |
autoPaginate | boolean | no | |
totals | boolean | no |
Responses
200 — Matching purchase orders.
Body: PurchaseOrdersResponse
| Field | Type | Required | Notes |
|---|---|---|---|
purchaseOrders | array of PurchaseOrder | yes | |
nextCursor | string | yes | |
totalCount | integer | yes | |
redactedItemCount | integer | yes | |
truncated | boolean | no | |
totals | InvoiceBillTotals | no | |
totalsTruncated | boolean | no | |
billingAlert | BillingAlert | no | |
xeroAlert | XeroAlert | no |
401 — Unauthorized
Body: ErrorResponse
| Field | Type | Required | Notes |
|---|---|---|---|
error | string | yes |
429 — Rate-limited (per-minute burst) or query credits exhausted. Credits return individually on a rolling 5h window — retry after Retry-After seconds for one more call.
Body:
any
Response headers
Every successful response carries X-CashRunway-Subscription, X-CashRunway-Plan, X-CashRunway-Quota-Remaining, and X-CashRunway-Quota-Reset. Trialing subscriptions also include X-CashRunway-Trial-Days-Remaining. See the overview for details.