Skip to content

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:

  1. Decide the status you want. The default is ACTIVE; ACTIVE, INACTIVE and DELETED are the accepted values, matched case-insensitively.
  2. 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).
  3. 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.
  4. Pick a limit between 1 and 1000. The default is 200.
  5. 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

FieldTypeRequiredDescriptionConstraints
statusstringNofilter users by status, default is 'ACTIVE'."ACTIVE"
Allowed values: "ACTIVE" | "INACTIVE" | "DELETED"

locations

FieldTypeRequiredDescriptionConstraints
locationsarray<string>Nolocation 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

FieldTypeRequiredDescriptionConstraints
departmentsarray<string>Nodepartment 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

FieldTypeRequiredDescriptionConstraints
labelsarray<string>Nolabel 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

FieldTypeRequiredDescriptionConstraints
limitintegerNoa 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

FieldTypeRequiredDescriptionConstraints
nextTokenstringNoThe 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

FieldTypeRequiredDescriptionConstraints
expandarray<string>Noa 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[]stringAllowed values: "location" | "department" | "holidays"

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataarray<User>No
response.data[]object
response.data[].idstringYesuser ID
response.data[].namestringYesuser name
response.data[].emailstringYesuser email
response.data[].isAdminbooleanYesa boolean that tells you if the selected user is an admin
response.data[].locationIdstring | nullYesthe ID of the user's location, null when the user has none yet
response.data[].locationId[variant1]stringthe ID of the user's location, null when the user has none yet
response.data[].locationId[variant2]nullthe ID of the user's location, null when the user has none yet
response.data[].departmentIdstring | nullYesthe ID of the user's department, null when the user has none yet
response.data[].departmentId[variant1]stringthe ID of the user's department, null when the user has none yet
response.data[].departmentId[variant2]nullthe ID of the user's department, null when the user has none yet
response.data[].statusstringYesuser status"ACTIVE" | "INACTIVE" | "DELETED"
response.data[].employeeIdstring | nullYesthe employee ID set on the user profile page, null when it is not set
response.data[].employeeId[variant1]stringthe employee ID set on the user profile page, null when it is not set
response.data[].employeeId[variant2]nullthe employee ID set on the user profile page, null when it is not set
response.data[].startDatestring | nullYesemployment 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]stringemployment 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]nullemployment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set
response.data[].endDatestring | nullYesemployment 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]stringemployment 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]nullemployment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set
response.data[].labelsarray<object>Yeslabels assigned to the user
response.data[].labels[]object
response.data[].labels[].idstringYes
response.data[].labels[].namestringYes
response.data[].labels[].colorstringYes
response.data[].locationobjectNothe user's location (only when expand includes location)
response.data[].location.idstringYeslocation ID
response.data[].location.namestringYeslocation name
response.data[].location.timezonestringNothe location's IANA time zone, left out when none is stored
response.data[].location.isDefaultbooleanYeswhether this is the company's default location
response.data[].location.createdAtstringYesa timestamp in the ISO 8601 formatdate-time
response.data[].departmentobjectNothe user's department (only when expand includes department)
response.data[].department.idstringYesdepartment ID
response.data[].department.namestringYesdepartment name
response.data[].department.isDefaultbooleanYeswhether this is the company's default department
response.data[].department.createdAtstringYesa timestamp in the ISO 8601 formatdate-time
response.data[].holidaysarray<HolidayYear>Nopublic holidays for the user's location, grouped by year (only when expand includes holidays)
response.data[].holidays[]object
response.data[].holidays[].yearintegerNothe year for the holidays
response.data[].holidays[].holidaysarray<object>No
response.data[].holidays[].holidays[]object
response.data[].holidays[].holidays[].idstringNoholiday ID
response.data[].holidays[].holidays[].namestringNoholiday name
response.data[].holidays[].holidays[].datestringNodate in YYYY-MM-DD formatdate
response.data[].holidays[].holidays[].isHalfDaybooleanNowhether it is a half-day holiday
response.nextTokenstringNo

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

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