Skip to content

List departments

The departments endpoint returns every active department in the account so a client can resolve department IDs to human-readable names. It is a read-only call: one request, one array, no pagination parameters. Use it when you need to display department labels, map people to a department, or find which department is the default.

Request

Send a GET request to /v1/departments. The endpoint takes no path parameters and no query parameters, so the URL is the same for every call. The only required input is the API key, supplied in the x-api-key header under the apiKeyAuth scheme. The base URL is configured per environment; the path segment stays /v1/departments.

Authorization

The endpoint uses the apiKeyAuth scheme. Pass the token in the x-api-key header. A missing or unrecognized key is rejected before the request reaches the endpoint, and a key that is valid but not scoped to this resource is rejected separately. Treat the token as a secret: keep it out of source control and out of client-side code.

Reading the 200 response

A successful call returns a JSON body with a status field and a data array. Each element of data is a department object with four fields. The id is a UUID that identifies the department. The name is the display label. The isDefault boolean tells you whether the department is the account default. The createdAt value is an ISO 8601 timestamp recording when the department was created. The table below explains what each field is for and how a client should treat it.

Field guide

Use the id as the stable key when storing department references; names can change. Use the name for display only. Use isDefault to decide which department should be pre-selected when a user has no explicit assignment. Use createdAt for ordering or auditing, not for access control. The status field on the envelope is a string that is either "ok" or "error".

Error responses

Errors come back as JSON. The 400 response carries a status of "error" and a message that names the problem. The 403 response is a plain message of "Forbidden". The 404 response is a plain message of "Not Found". The 500 response carries a status of "error" and a message. The two gateway-level failures — a missing or unrecognized API key, and a key not authorized for this resource — are returned before the endpoint runs and use a message-only body. The table below maps each status to its likely cause and the next step for the caller.

Worked example: pick the default department

A common task is assigning a new hire to the default department when no department has been chosen. After calling GET /v1/departments, filter the data array for the element whose isDefault is true. If exactly one match exists, use its id as the assignment target and its name for the confirmation message. If no match exists, fall back to asking the user to choose from the returned names. If more than one match exists, treat the response as ambiguous and surface the list to the user rather than guessing. The example response in the reference shows a single department named "Dev Team" with isDefault set to false, which is the shape to expect for a non-default department.

First-call checklist

Before shipping an integration, confirm four things. First, the base URL for the environment is set and the path is exactly /v1/departments. Second, the x-api-key header is populated from a secret store, not hard-coded. Third, the client handles both the ok envelope and the error envelope, including the message-only gateway failures. Fourth, the client treats the id as the stable key and the name as display text. A quick smoke test is to call the endpoint once and confirm the response contains a status field and a data array.

Department object fields
FieldTypeMeaningHow to use it
idstring (UUID)department IDStable key for storing department references
namestringdepartment nameDisplay label only; may change
isDefaultbooleana boolean that tells you if the department is default or notPre-select when a user has no explicit assignment
createdAtstring (ISO 8601)a timestamp in the ISO 8601 formatOrdering and auditing, not access control

Field descriptions are quoted from the endpoint's response schema. Types and formats are as defined in that schema.

Status codes and next steps
StatusBody shapeLikely causeNext step
200status + data arrayRequest succeededRead the data array
400status + messageRequest validation failedRead the message and correct the request
403message onlyKey not authorized for this resourceCheck the key's scope
404message onlyPath not foundConfirm the path is /v1/departments
500status + messageServer-side failureRetry with backoff; escalate if it persists

Body shapes reflect the response schemas for this endpoint. The 403 and 404 bodies are message-only; the 400 and 500 bodies carry a status and message.

Frequently asked questions

Where does the API key go?

In the x-api-key header under the apiKeyAuth scheme. A missing or unrecognized key is rejected before the request reaches the endpoint, and a key that is valid but not authorized for this resource is rejected separately.

Does the endpoint accept filters or pagination?

No. The request takes no path parameters and no query parameters; the path is always /v1/departments. The response returns the full list of active departments in a single data array.

How do I find the default department?

Look for the element in the data array whose isDefault field is true. If no element has it set, there is no default department in the account and the caller should ask the user to choose from the returned names.

What format is createdAt in?

An ISO 8601 timestamp string, for example 2022-08-22T15:00:00.000Z. Parse it with a standard ISO 8601 parser rather than a locale-specific date function.

Where can I get help?

Contact the developer support address listed in the reference footer.

curl -X GET "$API_BASE_URL/v1/departments" \
  -H "x-api-key: "
{
  "status": "ok",
  "data": [
    {
      "id": "teams-969f8429-7dc3-48a1-96b1-6049a99dda06",
      "name": "Dev Team",
      "isDefault": false,
      "createdAt": "2022-08-22T15:00:00.000Z"
    }
  ]
}
{
  "status": "error",
  "message": "\"startDate\" is required"
}
{
  "message": "Forbidden"
}
{
  "message": "Not Found"
}
{
  "status": "error",
  "message": "Failed to list users"
}

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.statusstringNoAllowed values: "ok" | "error"
response.dataarray<Departments>No
response.data[]object
response.data[].idstringNodepartment IDFormat: UUID
response.data[].namestringNodepartment name
response.data[].isDefaultbooleanNoa boolean that tells you if the department is default or not
response.data[].createdAtstringNoa timestamp in the ISO 8601 formatFormat: Date ISO 8601 format

response

FieldTypeRequiredDescriptionConstraints
responseobjectStandard error body returned by all validated endpoints.
response.statusstringYesAllowed values: "error"
response.messagestringYesHuman-readable description of what went wrong.

response

FieldTypeRequiredDescriptionConstraints
responseGatewayErrorResponse | ErrorResponse
response[variant1]objectError body returned when the request is rejected before reaching the endpoint (missing API key, unknown path).
response[variant1].messagestringYes
response[variant2]objectStandard error body returned by all validated endpoints.
response[variant2].statusstringYesAllowed values: "error"
response[variant2].messagestringYesHuman-readable description of what went wrong.

response

FieldTypeRequiredDescriptionConstraints
responseobjectError body returned when the request is rejected before reaching the endpoint (missing API key, unknown path).
response.messagestringYes

response

FieldTypeRequiredDescriptionConstraints
responseobjectStandard error body returned by all validated endpoints.
response.statusstringYesAllowed values: "error"
response.messagestringYesHuman-readable description of what went wrong.