Skip to main content
Version: 2026-05

List purchase orders

GET /purchase_orders

Description​

Lists the purchase orders your teams can charge a gift to, ordered by code, as a cursor-paginated collection. A purchase order is a reference your organization books gift spend against. Each gift request reports the one it's charged to as accounting.purchase_order; see Get a gift request.

A purchase order appears once, no matter how many teams it's enabled for, and doesn't appear if it isn't enabled for any team.

Which teams' purchase orders you get back depends on who you're authenticated as:

  • An admin's user token, a service or system token, and an OAuth token from an account-level partner grant each list every team's purchase orders.
  • Any other user token lists only the purchase orders of that user's own team.

For the two kinds of OAuth grant, see User-level and account-level grants.

When to use​

Use this endpoint to show which purchase orders a team can use, or to turn a code from your finance system into the id that gift requests and users carry.

To find the purchase order a user's gifts are charged to when they send without a campaign, read default_purchase_order on Get the current user or Get a user. To read the one a gift request was charged to, read accounting.purchase_order on Get a gift request.

For the matching list of cost centers, use List cost centers.

Parameters​

Headers​

AndOpen-API-Version (string · required) is the API version this request targets. Always send 2026-05. Requests authenticate with a bearer token; see Authentication for how to present it and Environments for the regional base URL to send it to.

Query parameters​

All four are optional.

team (string · optional) narrows the list to the purchase orders one or more teams can use. Pass one team id, or several separated by commas; a purchase order any of them can use is returned once. You get a team's id from the team on a user, for example on Get the current user.

A team that doesn't exist, or one you can't access, matches no records, so the response is 200 with an empty data array. If you name several teams, you get the purchase orders of the ones you can access. Leaving team out, or sending it empty, applies no filter.

limit (integer · optional) is how many purchase orders to return per page. Defaults to 25, and the maximum is 100. A larger value is clamped to 100 server-side; a non-numeric, zero, or negative value is rejected with a 400.

after (string · uuid · optional) is the keyset pagination cursor. Pagination is cursor-based, not page-numbered: to fetch the next page, pass the id of the last purchase order in the page you just received, and keep any team filter the same. Omit it for the first page. A cursor that isn't a purchase order in the list you're paging is rejected with a 400. Stop paging when the response's has_more is false.

sort (string · optional) is the field to order by, - prefix for descending. Defaults to code, ascending; -code, created_at, and -created_at are also accepted. Any other field is rejected with a 400.

Worked examples​

The cURL version is the raw HTTP call; the JavaScript, Python, and Ruby versions are idiomatic equivalents. Each requests the first page of the purchase orders one team can use.

curl -X GET "https://api.andopen.co/purchase_orders?team=1122aabb-ccdd-eeff-0011-223344556677" \
-H "Authorization: Bearer <api_key>" \
-H "AndOpen-API-Version: 2026-05"

Paging through every purchase order​

To walk the whole collection, keep fetching while has_more is true, passing the last purchase order's id as the after cursor each time. The cURL version shows a single follow-up request; the others loop until the last page.

curl -X GET "https://api.andopen.co/purchase_orders?limit=100&after=3d5f7a9c-2b4e-4c6d-9f81-0a2c4e6f8b1d" \
-H "Authorization: Bearer <api_key>" \
-H "AndOpen-API-Version: 2026-05"

Response shape​

A successful call returns 200 OK with a page object: a data array of purchase orders plus a boolean cursor flag. Paging is driven by has_more and the after cursor.

FieldDescription
data (array · required)The purchase orders in this page.
has_more (boolean · required)Whether more purchase orders exist beyond this page. When true, fetch the next page by passing the last item's id as the after cursor; when false, you've reached the end.
data.id (string · uuid · required)The purchase order's identifier. It's the same id a gift request carries as accounting.purchase_order.id and a user carries as default_purchase_order.id, so you can compare them directly.
data.code (string · required)The code your organization gave the purchase order, unique within your account. This is the value to match against your finance system.
data.name (string · required · nullable)The purchase order's display name, or null when it has none.
Response · 200
{
"data": [
{
"id": "9b2e4c6a-1f3d-4a58-8e70-2c4d6f8a0b1e",
"code": "PO-2026-0042",
"name": "Q4 client gifting"
},
{
"id": "3d5f7a9c-2b4e-4c6d-9f81-0a2c4e6f8b1d",
"code": "PO-2026-0057",
"name": null
}
],
"has_more": false
}

Per-field notes​

  • Every item is the same { id, code, name } object that Get a gift request embeds as accounting.purchase_order and that the user endpoints embed as default_purchase_order.
  • name is optional on a purchase order, so expect null and handle it when you label one. The second item in the example response has no name.
  • has_more drives paging. The response carries no total and no next URL. Treat has_more: false as the only signal to stop, and build the next request from the last item's id.
  • An empty data array has two causes: your team has no purchase orders, or the team filter named a team that doesn't exist or that you can't access. Check the team value before you conclude an account has no purchase orders.

Error cases​

Every failure uses the shared error model: a top-level errors array of objects carrying type, code, message, and (for field-level problems) param. See Errors for the full type/code taxonomy and how to handle each category; the codes below are the ones this endpoint produces.

StatusMeaning
400The request is malformed or violates a precondition. Typical triggers are a missing or unsupported `AndOpen-API-Version` header, a request body that is not valid JSON, or pagination parameters that fail server-side validation (`limit` non-numeric or non-positive, `after` referencing a record that does not exist).
401Authentication failed: missing or invalid bearer token.
403Authorized but not permitted to access this resource.
429Too many requests. Rate limit exceeded.
500Internal server error.
503Service unavailable. The account may be under maintenance. Check the `Retry-After` header.

Every error carries a type, one of: validation_error, authentication_error, authorization_error, not_found_error, rate_limit_error, api_error.

The ones you'll meet in practice:

  • 400 validation_error: a query parameter was rejected, each naming the offending one in param. An after cursor that isn't a purchase order in the list you're paging is invalid_reference. A limit that is not a positive integer and an unsupported sort field are both invalid_format. The team filter never causes a 400.
  • 400 api_error: unsupported_api_version when the AndOpen-API-Version header is missing or unsupported (returned before authentication).
  • 401 authentication_error: the bearer token is missing, invalid, or expired (unauthorized).
  • 403 authorization_error: the token is valid but not permitted to list purchase orders (forbidden).
  • 429 rate_limit_error: too many requests; back off and retry (rate_limited). The RateLimit-* response headers tell you the budget and reset time.
  • 500 / 503 api_error: a fault on our side; rare, and safe to retry after a short delay (honor Retry-After on a 503).

Sorting by a field this endpoint doesn't support, such as sort=name, returns:

{
"errors": [
{
"type": "validation_error",
"code": "invalid_format",
"message": "sort must be one of: code, created_at, optionally prefixed with '-' for descending order.",
"param": "sort"
}
]
}