Skip to main content
Version: 2026-05

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 -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"

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 -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"

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.

FieldDescription
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.
Response · 200
{
"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 as accounting.cost_centre and that the user endpoints embed as default_cost_centre.
  • 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 cost centers, 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 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.

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 cost center 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 cost centers (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"
}
]
}