List a user's labels
This endpoint returns every label attached to one user. It requires the labels:read scope, takes the user's ID in the path, and returns the whole list in a single response rather than in pages. Labels are company-wide, so the call works for any user of the company whatever the key's data reach.
Request and authorization
Send a GET request to /v2/users/{id}/labels. The path parameter id is a required string holding the resource ID of the user. Authenticate with a bearer token in the Authorization header, and the key must carry the labels:read scope. Because the list is not paginated, there is no page or cursor parameter to manage.
What the response contains
The 200 response wraps an array in a data property. Each entry is a label object with four required fields: id (the label ID), name (the label name), color (the label color as stored; the dashboard uses a hex code), and userCount (how many users carry that label, or 0 when none do). The sample shows one label in the array; a real response can contain several.
Error cases to distinguish
A 404 with code RESOURCE_NOT_FOUND means the user does not exist. A 401 means the API key is missing, malformed or unrecognized. A 403 covers a key that lacks the required scope, a revoked key, or an acting user who may not perform the action. A 429 means too many requests were sent in a short time, and a 500 signals a server-side problem. Each error body carries a code, name, description, resolution and requestId; keep the requestId when contacting support.
Before you call it
A short check to avoid the common mistakes: confirm the key has labels:read; pass the user's resource ID rather than a display name; expect a flat array in data with no pagination fields; and treat a 404 as a missing user rather than a scope problem. If you need to change a user's labels, use the assign or remove label endpoints instead of this read-only call.
Frequently asked questions
Does this endpoint paginate the label list?
No. The list is returned in full and is not paginated, so you do not pass page or cursor parameters.
Which scope does the request need?
The key must include labels:read. A key without it receives a 403 insufficient-scope error.
What does a 404 mean here?
A 404 RESOURCE_NOT_FOUND means the user does not exist. It is not the same as a missing scope, which produces a 403.
Can I read labels for any user in the company?
Yes. Labels are company-wide, so the request works for any user of the company regardless of the key's data reach.
curl -X GET "$API_BASE_URL/v2/users/string/labels" \
-H "Authorization: Bearer "{
"data": [
{
"id": "969f8429-7dc3-48a1-96b1-6049a99dda06",
"name": "contractor",
"color": "#FF0000",
"userCount": 12
}
]
}{
"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": "RESOURCE_NOT_FOUND",
"name": "ResourceNotFound",
"description": "Example post details.",
"resolution": "Check the ID of the resource named in details.resource and that the key owner can see it.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"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"
}
}id
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| id | string | Yes | resource ID. |
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 |
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 |