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
- JavaScript
- Python
- Ruby
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"
const url = new URL("https://api.andopen.co/purchase_orders");
url.searchParams.set("team", "1122aabb-ccdd-eeff-0011-223344556677");
const response = await fetch(url, {
headers: {
Authorization: "Bearer <api_key>",
"AndOpen-API-Version": "2026-05",
},
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const page = await response.json();
for (const purchaseOrder of page.data) {
console.log(purchaseOrder.id, purchaseOrder.code, purchaseOrder.name ?? "(no name)");
}
import requests
response = requests.get(
"https://api.andopen.co/purchase_orders",
headers={
"Authorization": "Bearer <api_key>",
"AndOpen-API-Version": "2026-05",
},
params={"team": "1122aabb-ccdd-eeff-0011-223344556677"},
)
response.raise_for_status()
page = response.json()
for purchase_order in page["data"]:
print(purchase_order["id"], purchase_order["code"], purchase_order["name"] or "(no name)")
require "net/http"
require "json"
uri = URI("https://api.andopen.co/purchase_orders")
uri.query = URI.encode_www_form(team: "1122aabb-ccdd-eeff-0011-223344556677")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer <api_key>"
request["AndOpen-API-Version"] = "2026-05"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
http.request(request)
end
response.value # raises on a non-2xx response
page = JSON.parse(response.body)
page["data"].each do |purchase_order|
puts "#{purchase_order['id']} #{purchase_order['code']} #{purchase_order['name'] || '(no name)'}"
end
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
- JavaScript
- Python
- Ruby
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"
async function listAllPurchaseOrders() {
const purchaseOrders = [];
let after;
do {
const url = new URL("https://api.andopen.co/purchase_orders");
url.searchParams.set("limit", "100");
if (after) url.searchParams.set("after", after);
const response = await fetch(url, {
headers: {
Authorization: "Bearer <api_key>",
"AndOpen-API-Version": "2026-05",
},
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const page = await response.json();
purchaseOrders.push(...page.data);
const lastId = page.data.at(-1)?.id;
after = page.has_more && lastId ? lastId : undefined;
} while (after);
return purchaseOrders;
}
import requests
def list_all_purchase_orders():
purchase_orders = []
after = None
while True:
params = {"limit": 100}
if after:
params["after"] = after
response = requests.get(
"https://api.andopen.co/purchase_orders",
headers={
"Authorization": "Bearer <api_key>",
"AndOpen-API-Version": "2026-05",
},
params=params,
)
response.raise_for_status()
page = response.json()
purchase_orders.extend(page["data"])
if not page["has_more"] or not page["data"]:
return purchase_orders
after = page["data"][-1]["id"]
require "net/http"
require "json"
def list_all_purchase_orders
purchase_orders = []
after = nil
loop do
uri = URI("https://api.andopen.co/purchase_orders")
uri.query = URI.encode_www_form({ limit: 100, after: after }.compact)
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer <api_key>"
request["AndOpen-API-Version"] = "2026-05"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
http.request(request)
end
response.value # raises on a non-2xx response
page = JSON.parse(response.body)
purchase_orders.concat(page["data"])
break purchase_orders unless page["has_more"] && page["data"].any?
after = page["data"].last["id"]
end
end
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.
| Field | Description |
|---|---|
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. |
{
"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 asaccounting.purchase_orderand that the user endpoints embed asdefault_purchase_order. nameis optional on a purchase order, so expectnulland handle it when you label one. The second item in the example response has no name.has_moredrives paging. The response carries no total and nonextURL. Treathas_more: falseas the only signal to stop, and build the next request from the last item'sid.- An empty
dataarray has two causes: your team has no purchase orders, or theteamfilter named a team that doesn't exist or that you can't access. Check theteamvalue 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.
| Status | Meaning |
|---|---|
| 400 | The 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). |
| 401 | Authentication failed: missing or invalid bearer token. |
| 403 | Authorized but not permitted to access this resource. |
| 429 | Too many requests. Rate limit exceeded. |
| 500 | Internal server error. |
| 503 | Service 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 inparam. Anaftercursor that isn't a purchase order in the list you're paging isinvalid_reference. Alimitthat is not a positive integer and an unsupportedsortfield are bothinvalid_format. Theteamfilter never causes a400.400 api_error:unsupported_api_versionwhen theAndOpen-API-Versionheader 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). TheRateLimit-*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 (honorRetry-Afteron a503).
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"
}
]
}