Skip to content

List leave types with the REST API v1 endpoint

The leave-types endpoint returns every leave type defined for the account, along with the identifiers and display attributes you need to reference them elsewhere. This reference covers the request, the authentication header, the success payload and the error bodies so you can wire the call into a scheduling or reporting workflow.

Request and authentication

The endpoint uses the GET method at the path /v1/leave-types. Authentication is supplied through the x-api-key header, which carries your token. The request has no path parameters or query parameters in the documented form, so a single call returns the full set of leave types.

The cURL form below shows the method, path and header. The same request is also available in JavaScript, Go, Python, Java and C# from the language tabs on the reference page. Replace the empty header value with your own key before sending.

Success response (200 application/json)

A successful call returns a JSON array. The first element is an object with a status field set to "ok" and a data array. Each entry in data describes one leave type with four fields:

  • id: a UUID string that uniquely identifies the leave type.
  • name: the display name, such as "Team B" in the sample.
  • color: a hex color code without the leading #, such as "FF0000".
  • isActive: a boolean indicating whether the leave type is currently active.

The sample below shows one record. Treat the values as illustrative rather than as fixed defaults.

Error responses

The endpoint documents five error statuses. Each returns a JSON body, and the shape depends on where the request failed.

  • 400 application/json returns a standard error object with status "error" and a message describing the problem. The sample message references a missing startDate, which is the generic validation example used across the API.
  • 403 application/json returns a gateway-style body with only a message field, shown as "Forbidden". This is the response when the API key is missing or unrecognized.
  • 404 application/json returns a standard error object with status "error" and a message. The sample message in the documentation is "Failed to list users", which is a generic example rather than a leave-types-specific message.
  • 500 application/json returns a standard error object with status "error" and a message.

Use the status code and the presence or absence of the status field to distinguish a gateway rejection from a validated endpoint error.

Before you ship the call

  1. Confirm the base URL is set through your environment configuration rather than hard-coded.
  2. Confirm the x-api-key header is populated at request time and never committed to source control.
  3. Decide how your client will handle an empty data array versus a populated one.
  4. Map the color value to your UI with the leading # added, since the API returns the hex digits without it.
  5. Log the status code alongside the message so a 403 (key problem) is not confused with a 404 (path or resource problem).
  6. Treat the sample record as an example only; real names, colors and IDs will differ per account.

Worked example

Suppose your scheduling tool needs to show a colored badge for each leave type. You call GET /v1/leave-types with your key, receive the array, and read data[0]. The sample record has id 88681ca1-4a47-4e4d-bc35-ffff86c0f54e, name "Team B", color "FF0000" and isActive true. Your UI would render a red badge labelled "Team B" and could use the id as a stable reference when creating or filtering leaves. If isActive were false, you would typically hide the type from new leave requests while still displaying historical records that reference it.

Frequently asked questions

Which header carries the API key?

The x-api-key header. Send your token as its value on every request to /v1/leave-types.

What does a 403 response mean here?

A 403 with the body {"message": "Forbidden"} indicates the API key is missing or unrecognized. Check that the x-api-key header is present and that the token is current.

What does a 404 response mean here?

A 404 returns the standard error object with status "error" and a message. The documented sample message is "Failed to list users", which is a generic example; in practice a 404 usually means the path is wrong or the resource is not available to your key.

Does the color field include a leading #?

No. The sample value is "FF0000" without a leading #. Add the # in your UI layer if your styling system requires it.

Where can I get help with the API?

Contact the developer support address listed on the reference page.

curl -X GET "$API_BASE_URL/v1/leave-types" \
  -H "x-api-key: "
[
  {
    "status": "ok",
    "data": [
      {
        "id": "88681ca1-4a47-4e4d-bc35-ffff86c0f54e",
        "name": "Team B",
        "color": "FF0000",
        "isActive": true
      }
    ]
  }
]
{
  "status": "error",
  "message": "\"startDate\" is required"
}
{
  "message": "Forbidden"
}
{
  "message": "Not Found"
}
{
  "status": "error",
  "message": "Failed to list users"
}

response

FieldTypeRequiredDescriptionConstraints
responseunknown

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].statusstringYes"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.