List users
GET /v2/users returns a page of users visible to the API key, each with an ID, name, email, admin flag, status and profile details. This reference covers the query parameters, the scopes each expansion needs, the shape of the response, and the errors you can hit.
What the endpoint returns
Each call returns a paginated list of users within the key's data reach. The base user object carries id, name, email, isAdmin, locationId, departmentId, status, employeeId, startDate, endDate and labels. locationId and departmentId are always returned, even when you don't ask for the related objects. The user shape matches API v1. The response is a JSON object with a data array and, when more pages exist, a nextToken string.
Authorization and scope
Send the API key in the Authorization header as a Bearer token. The base call needs the users:read scope. Per the source's Authentication and Scopes documentation, how keys are created, which scopes exist, and how the key owner's role limits them are described there; the same request can therefore return different results for different keys.
Query parameters
All parameters are optional. Use them to narrow the list or to request related objects.
Choosing filters and expansions
A short checklist before the first call:
- Decide the status you want. The default is ACTIVE; ACTIVE, INACTIVE and DELETED are the accepted values, matched case-insensitively.
- If you need a subset of locations, departments or labels, pass their IDs. Each of these accepts a repeated parameter (locations=a&locations=b) or a comma-separated list (locations=a,b).
- Decide whether you need the embedded objects. location needs locations:read, department needs departments:read, and holidays needs holidays:read. If you request an expansion without its scope, the call fails with 403 INSUFFICIENT_SCOPE and details.expand names the values that asked for it.
- Pick a limit between 1 and 1000. The default is 200.
- Keep the same filters on every follow-up call and pass the previous response's nextToken.
Pagination behavior
A page can contain fewer users than the limit you set while nextToken is still returned. Do not treat a short page as the end of the list. Keep calling with the same filters and the latest nextToken until nextToken is absent. A token that was not issued by this API fails with 400 INVALID_PAGINATION_TOKEN. When the key owner sees only their own data, the response contains only the key owner, when they match the filters, and no nextToken.
Response fields and expansions
The base user fields are always present. The expanded objects appear only when requested:
- location: id, name, timezone (omitted when none is stored), isDefault, createdAt.
- department: id, name, isDefault, createdAt.
- holidays: an array grouped by year, each year with year and a holidays array of id, name, date (YYYY-MM-DD) and isHalfDay.
startDate and endDate are returned as stored, either an ISO 8601 date or timestamp, and are null when not set. employeeId is null when not set. locationId and departmentId are null when the user has none yet.
Errors and how to tell them apart
Errors use a common envelope with code, name, description, resolution, requestId and optional details. The status code and error code together identify what went wrong, and the resolution field suggests the next step. The cases to expect are: 400 VALIDATION_ERROR, when status, limit or expand is invalid, with details.fields listing the offending fields; 400 INVALID_PAGINATION_TOKEN, when the nextToken was not issued by this API; 401 UNAUTHORIZED, when the key is missing, malformed or not recognized; 403 INSUFFICIENT_SCOPE, when an expand value needs a read scope the key does not have, with details.expand naming those values; 429 RATE_LIMITED, when too many requests arrive in a short time, so wait and retry; and 500 INTERNAL_ERROR, for a server-side problem, where retrying later is appropriate. If a 500 persists, use the support channel your organization has designated for API questions and quote the requestId from the error body.
Example request and response
The example below requests two expansions, location and department, and shows the shape of a successful response with two users and a nextToken. The cURL example is the canonical request form; the JSON example shows the fields you can expect. Both are supplied as exact contract modules and are reproduced in full.
Frequently asked questions
What does the endpoint return?
A paginated list of users within the key's data reach, each with ID, name, email, admin flag, status, profile details and labels. A nextToken is included when more pages exist.
Which scope does the base call need?
users:read. Each expand value adds its own requirement: locations:read for location, departments:read for department, and holidays:read for holidays.
Why did I get 403 INSUFFICIENT_SCOPE?
An expand value asked for a read scope the key does not have. details.expand names the values that triggered it. Add the missing scopes to the key and retry.
How do I know when to stop paginating?
Stop when nextToken is absent. A page with fewer items than the limit does not mean the list is finished.
Can I filter by more than one location or department?
Yes. Pass the IDs as a repeated parameter or a comma-separated list. Users in any of the provided locations or departments are returned. Filters entirely outside the key's data reach return an empty list.
Where can I get help with this endpoint?
Use the support channel your organization has designated for API questions, and include the requestId from the error response so the issue can be traced.
curl -X GET "$API_BASE_URL/v2/users?expand=location%2Cdepartment" \
-H "Authorization: Bearer "{
"data": [
{
"id": "user-cfe5d39b-f1f0-45aa-85cd-ce93e637a262",
"name": "John Chao",
"email": "[email protected]",
"isAdmin": false,
"locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
"departmentId": "team-0a21c25e-6925-4a5b-90ee-ecf82096c4f6",
"status": "ACTIVE",
"employeeId": "E-1024",
"startDate": "2022-11-08",
"endDate": null,
"labels": [
{
"id": "969f8429-7dc3-48a1-96b1-6049a99dda06",
"name": "contractor",
"color": "#FF0000"
}
]
},
{
"id": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
"name": "Ana Petrović",
"email": "[email protected]",
"isAdmin": true,
"locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
"departmentId": "team-0a21c25e-6925-4a5b-90ee-ecf82096c4f6",
"status": "ACTIVE",
"employeeId": null,
"startDate": null,
"endDate": null,
"labels": []
}
],
"nextToken": "next-token"
}{
"error": {
"code": "VALIDATION_ERROR",
"name": "ValidationError",
"description": "Example post details.",
"resolution": "Fix the fields listed in details.fields and send the request again.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"fields": [
{
"path": "startDate",
"message": "\"startDate\" is required"
}
]
}
}
}{
"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"
}
}status
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| status | string | No | filter users by status, default is 'ACTIVE'. | "ACTIVE" Allowed values: "ACTIVE" | "INACTIVE" | "DELETED" |
locations
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| locations | array<string> | No | location IDs used for filtering, sent as a repeated parameter ( locations=a&locations=b ) or a comma-separated list ( locations=a,b ). If provided, the API method returns users in one of the provided locations. By default, it returns users in any location within the key's data reach. | |
| locations[] | string |
departments
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| departments | array<string> | No | department IDs used for filtering, sent as a repeated parameter or a comma-separated list. If provided, the API method returns users in one of the provided departments. By default, it returns users in any department within the key's data reach. | |
| departments[] | string |
labels
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| labels | array<string> | No | label IDs used for filtering, sent as a repeated parameter or a comma-separated list. If provided, the API method returns users with one of the provided labels. By default, it returns users with or without labels. | |
| labels[] | string |
limit
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| limit | integer | No | a number of items to return per page, between 1 and 1000, default is 200. The number of returned items might be less than the provided limit even when more pages exist; rely on nextToken . Same semantics as the v1 limit parameter. | 200 1 <= value <= 1000 |
nextToken
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| nextToken | string | No | The nextToken returned by the previous API call. Send the same filters as in the previous call. Same semantics as the v1 nextToken parameter; a token that was not issued by this API fails with 400 INVALID_PAGINATION_TOKEN . |
expand
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| expand | array<string> | No | a comma-separated list of related resources to include in each user. Options: location (the user's location, requires locations:read ), department (the user's department, requires departments:read ) and holidays (public holidays for the user's location grouped by year, requires holidays:read ). Each value needs the read scope of the resource it embeds. | Allowed values: "location" | "department" | "holidays" |
| expand[] | string | Allowed values: "location" | "department" | "holidays" |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | |||
| response.data | array<User> | No | ||
| response.data[] | object | |||
| response.data[].id | string | Yes | user ID | |
| response.data[].name | string | Yes | user name | |
| response.data[].email | string | Yes | user email | |
| response.data[].isAdmin | boolean | Yes | a boolean that tells you if the selected user is an admin | |
| response.data[].locationId | string | null | Yes | the ID of the user's location, null when the user has none yet | |
| response.data[].locationId[variant1] | string | the ID of the user's location, null when the user has none yet | ||
| response.data[].locationId[variant2] | null | the ID of the user's location, null when the user has none yet | ||
| response.data[].departmentId | string | null | Yes | the ID of the user's department, null when the user has none yet | |
| response.data[].departmentId[variant1] | string | the ID of the user's department, null when the user has none yet | ||
| response.data[].departmentId[variant2] | null | the ID of the user's department, null when the user has none yet | ||
| response.data[].status | string | Yes | user status | "ACTIVE" | "INACTIVE" | "DELETED" |
| response.data[].employeeId | string | null | Yes | the employee ID set on the user profile page, null when it is not set | |
| response.data[].employeeId[variant1] | string | the employee ID set on the user profile page, null when it is not set | ||
| response.data[].employeeId[variant2] | null | the employee ID set on the user profile page, null when it is not set | ||
| response.data[].startDate | string | null | Yes | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | |
| response.data[].startDate[variant1] | string | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data[].startDate[variant2] | null | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data[].endDate | string | null | Yes | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | |
| response.data[].endDate[variant1] | string | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data[].endDate[variant2] | null | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data[].labels | array<object> | Yes | labels assigned to the user | |
| response.data[].labels[] | object | |||
| response.data[].labels[].id | string | Yes | ||
| response.data[].labels[].name | string | Yes | ||
| response.data[].labels[].color | string | Yes | ||
| response.data[].location | object | No | the user's location (only when expand includes location) | |
| response.data[].location.id | string | Yes | location ID | |
| response.data[].location.name | string | Yes | location name | |
| response.data[].location.timezone | string | No | the location's IANA time zone, left out when none is stored | |
| response.data[].location.isDefault | boolean | Yes | whether this is the company's default location | |
| response.data[].location.createdAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data[].department | object | No | the user's department (only when expand includes department) | |
| response.data[].department.id | string | Yes | department ID | |
| response.data[].department.name | string | Yes | department name | |
| response.data[].department.isDefault | boolean | Yes | whether this is the company's default department | |
| response.data[].department.createdAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data[].holidays | array<HolidayYear> | No | public holidays for the user's location, grouped by year (only when expand includes holidays) | |
| response.data[].holidays[] | object | |||
| response.data[].holidays[].year | integer | No | the year for the holidays | |
| response.data[].holidays[].holidays | array<object> | No | ||
| response.data[].holidays[].holidays[] | object | |||
| response.data[].holidays[].holidays[].id | string | No | holiday ID | |
| response.data[].holidays[].holidays[].name | string | No | holiday name | |
| response.data[].holidays[].holidays[].date | string | No | date in YYYY-MM-DD format | date |
| response.data[].holidays[].holidays[].isHalfDay | boolean | No | whether it is a half-day holiday | |
| response.nextToken | string | 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 |
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 |