Skip to content

List labels API: fetch every company label in one call

Use this endpoint when you need a complete label inventory for reporting, filtering or synchronisation, rather than looking up one label by ID. It returns the full set in a single response, so client code does not need to page through results.

How to call it

Send a GET request to /v2/labels with bearerAuth and the labels:read scope. The Authorization header carries the API key as a Bearer token. The key owner's role can further limit what the key may do, so a valid key with the right scope is still subject to that role.

Pre-flight checklist

Checklist before you call: 1) Create or select a key with labels:read. 2) Put the full key in the Authorization header. 3) Call GET /v2/labels with no pagination parameters. 4) Expect a 200 response whose data array contains every label. 5) Treat each label's userCount as company-wide, not limited to the key's data reach.

Reading the response

Each item in the data array is a label object. Use id to reference the label in later calls, name for display, color for presentation, and userCount to see how many users in the whole company carry it. A count of 0 means no users currently have that label. The example response in protected module code0002 shows a label with users and one with none, which is a useful test case for empty-count handling.

Errors at a glance

Distinguish three common failures. 401 means the key itself is missing, malformed, unrecognised or revoked. 403 means the key is recognised but lacks a required scope, or the acting user may not perform the action. 429 means too many requests were sent in a short time. 500 means a server-side failure. All of them use the shared error envelope described in schema0002, with a stable code, a short name, a description, a resolution hint and a requestId for support.

Request example

The request example is provided as protected module code0001. Language variants generated from the same contract are available through the hidden SDK variants module, but the cURL form is the canonical example to copy. Replace the token placeholder with your key and set the base URL from configuration.

Label fields in the list response
FieldMeaningUse it to
idLabel identifierReference the label in get, update and delete calls
nameLabel nameDisplay and match labels in your UI
colorStored colour value, shown as a hex code in the dashboardRender the label colour consistently
userCountUsers with this label across the whole company; 0 when noneReport adoption and spot unused labels

All four fields are required on every label object in the 200 response.

Frequently asked questions

Why does the request return 401?

Send the full key after Bearer in the Authorization header. A missing, malformed or unrecognised key returns 401 with code UNAUTHORIZED; check the key value and header format before retrying.

Why does the request return 403 for insufficient scope?

The key needs the scope required for this endpoint. The error body lists the needed scopes under details.requiredScopes, so add those scopes to the key and retry.

What should I do when rate limited?

Wait a few seconds and retry. For writes, reuse the same Idempotency-Key; this endpoint is a GET, so no write key is needed for the list call itself.

What should I do on a 500 error?

Retry later. If the failure persists, contact support and quote the requestId from the error body so the request can be traced.

curl -X GET "$API_BASE_URL/v2/labels" \
  -H "Authorization: Bearer "
{
  "data": [
    {
      "id": "969f8429-7dc3-48a1-96b1-6049a99dda06",
      "name": "contractor",
      "color": "#FF0000",
      "userCount": 12
    },
    {
      "id": "2c7d9e1f-3a4b-4c5d-8e6f-7a8b9c0d1e2f",
      "name": "Team B",
      "color": "#00AAFF",
      "userCount": 0
    }
  ]
}
{
  "error": {
    "code": "UNAUTHORIZED",
    "name": "Unauthorized",
    "description": "Example post details.",
    "resolution": "Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "INSUFFICIENT_SCOPE",
    "name": "InsufficientScope",
    "description": "Example post details.",
    "resolution": "Add the scopes listed in details.requiredScopes to the key in the OnlyLeave dashboard.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
    "details": {
      "requiredScopes": [
        "leaves:write"
      ]
    }
  }
}
{
  "error": {
    "code": "RATE_LIMITED",
    "name": "RateLimited",
    "description": "Example post details.",
    "resolution": "Wait a few seconds and retry, using the same Idempotency-Key for writes.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}
{
  "error": {
    "code": "INTERNAL_ERROR",
    "name": "InternalError",
    "description": "Example post details.",
    "resolution": "Retry later, and if it keeps happening, contact OnlyLeave support and quote the requestId.",
    "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
  }
}

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataarray<Label>Yes
response.data[]object
response.data[].idstringYeslabel ID
response.data[].namestringYeslabel name
response.data[].colorstringYeslabel color, as stored (the dashboard uses a hex code)
response.data[].userCountintegerYesthe number of users with this label, 0 when none

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo

response

FieldTypeRequiredDescriptionConstraints
responseobjectError envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog .
response.errorobjectYes
response.error.codestringYesstable machine-readable error code
response.error.namestringYesshort human-readable error name
response.error.descriptionstringYeswhat went wrong
response.error.resolutionstringYeshow to fix the problem
response.error.requestIdstringYesrequest ID, include it when contacting support
response.error.detailsobjectNooptional additional information specific to the error code
response.error.details.[key: string]anyNo