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.
| Field | Meaning | Use it to |
|---|---|---|
| id | Label identifier | Reference the label in get, update and delete calls |
| name | Label name | Display and match labels in your UI |
| color | Stored colour value, shown as a hex code in the dashboard | Render the label colour consistently |
| userCount | Users with this label across the whole company; 0 when none | Report 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
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | |||
| response.data | array<Label> | Yes | ||
| response.data[] | object | |||
| response.data[].id | string | Yes | label ID | |
| response.data[].name | string | Yes | label name | |
| response.data[].color | string | Yes | label color, as stored (the dashboard uses a hex code) | |
| response.data[].userCount | integer | Yes | the number of users with this label, 0 when none |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |