List cost centers
GET /cost_centres
Description
Lists the cost centers your teams can charge a gift to, ordered by code, as a
cursor-paginated collection. A cost center is an accounting code your
organization books gift spend against. Each gift request reports the one it's
charged to as accounting.cost_centre; see
Get a gift request.
A cost center 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' cost centers 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 cost centers.
- Any other user token lists only the cost centers 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 cost centers 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 cost center a user's gifts are charged to when they send without a
campaign, read default_cost_centre on Get the current user
or Get a user. To read the one a gift request was charged
to, read accounting.cost_centre on
Get a gift request.
For the matching list of purchase orders, use List purchase orders.
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 cost centers one or more
teams can use. Pass one team id, or several separated by commas; a cost center
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 cost centers of the ones you can access. Leaving team out, or sending it
empty, applies no filter.
limit (integer · optional) is how many cost centers 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 cost center 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 cost center 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 cost centers one team can use.
- cURL
- JavaScript
- Python
- Ruby
curl -X GET "https://api.andopen.co/cost_centres?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/cost_centres");
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 costCentre of page.data) {
console.log(costCentre.id, costCentre.code, costCentre.name);
}
import requests
response = requests.get(
"https://api.andopen.co/cost_centres",
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 cost_centre in page["data"]:
print(cost_centre["id"], cost_centre["code"], cost_centre["name"])
require "net/http"
require "json"
uri = URI("https://api.andopen.co/cost_centres")
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 |cost_centre|
puts "#{cost_centre['id']} #{cost_centre['code']} #{cost_centre['name']}"
end
Paging through every cost center
To walk the whole collection, keep fetching while has_more is true, passing
the last cost center'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/cost_centres?limit=100&after=8a1c5e2f-4b7d-4c3a-b6e9-0d2f4a6c8e1b" \
-H "Authorization: Bearer <api_key>" \
-H "AndOpen-API-Version: 2026-05"
async function listAllCostCentres() {
const costCentres = [];
let after;
do {
const url = new URL("https://api.andopen.co/cost_centres");
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();
costCentres.push(...page.data);
const lastId = page.data.at(-1)?.id;
after = page.has_more && lastId ? lastId : undefined;
} while (after);
return costCentres;
}
import requests
def list_all_cost_centres():
cost_centres = []
after = None
while True:
params = {"limit": 100}
if after:
params["after"] = after
response = requests.get(
"https://api.andopen.co/cost_centres",
headers={
"Authorization": "Bearer <api_key>",
"AndOpen-API-Version": "2026-05",
},
params=params,
)
response.raise_for_status()
page = response.json()
cost_centres.extend(page["data"])
if not page["has_more"] or not page["data"]:
return cost_centres
after = page["data"][-1]["id"]
require "net/http"
require "json"
def list_all_cost_centres
cost_centres = []
after = nil
loop do
uri = URI("https://api.andopen.co/cost_centres")
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)
cost_centres.concat(page["data"])
break cost_centres 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 cost
centers plus a boolean cursor flag. Paging is driven by has_more and the
after cursor.
| Field | Description |
|---|---|
data (array · required) | The cost centers in this page. |
has_more (boolean · required) | Whether more cost centers 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 cost center's identifier. It's the same id a gift request carries as accounting.cost_centre.id and a user carries as default_cost_centre.id, so you can compare them directly. |
data.code (string · required) | The code your organization gave the cost center, unique within your account. This is the value to match against your finance system. |
data.name (string · required) | The cost center's display name. Always set. |
{
"data": [
{
"id": "3d6f0a1e-8c2b-4e57-9a10-5b7c2e4f6a8d",
"code": "MKT-001",
"name": "Marketing"
},
{
"id": "8a1c5e2f-4b7d-4c3a-b6e9-0d2f4a6c8e1b",
"code": "SAL-002",
"name": "Sales"
}
],
"has_more": false
}
Per-field notes
- Every item is the same
{ id, code, name }object that Get a gift request embeds asaccounting.cost_centreand that the user endpoints embed asdefault_cost_centre. 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 cost centers, or theteamfilter named a team that doesn't exist or that you can't access. Check theteamvalue before you conclude an account has no cost centers.
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 cost center 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 cost centers (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"
}
]
}