Skip to content

Get a User via the REST API v2 Endpoint

Retrieve one user record by ID, optionally embedding related location, department, and holiday information. This guide explains the authorization, parameters, response shape, and error distinctions needed to call the endpoint correctly.

Request overview

Send a GET request for a single user using the user ID in the path. The request needs the users:read scope and bearer authorization. The protected request example is provided by module code0001, while the path and query contracts are provided by modules schema0001 and schema0002.

Authorization and access check

Authorization uses a bearer API key in the Authorization header, with users:read as the endpoint scope. The key owner's role can further limit access. Before calling, confirm that the key is valid, that users:read is present, and that the requested user is within the key's data reach.

Path and expand parameters

The required path parameter is the resource ID. The optional expand query parameter accepts a comma-separated list. Location embeds the user's location and requires locations:read. Department embeds the user's department and requires departments:read. Holidays embeds public holidays for the user's location grouped by year and requires holidays:read. A practical preflight checklist is: confirm the user ID, decide which embedded resources are actually needed, confirm each matching read scope, and omit expand values you do not need.

Successful response

A successful 200 response returns the user under data. Core fields include id, name, email, isAdmin, locationId, departmentId, status, employeeId, startDate, endDate, and labels. Nullable fields may be null when no value is set. When expand is used, the response can also contain location, department, or holidays, each with its own nested fields. The complete success example is provided by module code0002 and the response contract by module schema0005.

Error distinctions

Treat these failures as different problems. A 400 VALIDATION_ERROR means an expand value is unknown. A 403 INSUFFICIENT_SCOPE means the key lacks the read scope for an embedded resource; details.expand names the values that requested it. A 404 RESOURCE_NOT_FOUND means the user does not exist or is outside the key's data reach. Other documented outcomes include 401 for an invalid or missing key, 429 for rate limiting, and 500 for an internal error. The corresponding protected examples are provided by modules code0003 through code0008, and the shared error contract is provided by modules schema0006 through schema0011.

Choosing expand values

For a focused lookup, request only the user record. For a profile view that also needs organizational context, add location and department only when their scopes are available. For holiday-aware calculations, add holidays only when holidays:read is available. If a 403 response names an expand value, remove that value or update the key's scopes rather than retrying the same request unchanged.

Choosing expand values

For a focused lookup, request only the user record. For a profile view that also needs organizational context, add location and department only when their scopes are available. For holiday-aware calculations, add holidays only when holidays:read is available. If a 403 response names an expand value, remove that value or update the key's scopes rather than retrying the same request unchanged.

Frequently asked questions

How do I include related location, department, or holiday data?

Use the expand query option with location, department, or holidays. Each embedded resource needs its own read scope, and a missing scope produces a 403 INSUFFICIENT_SCOPE response whose details.expand identifies the requested values.

What distinguishes the main errors for this endpoint?

A 400 VALIDATION_ERROR indicates an unknown expand value. A 403 INSUFFICIENT_SCOPE indicates the key lacks the read scope for an embedded resource. A 404 RESOURCE_NOT_FOUND indicates the user does not exist or is outside the key's data reach.

Does the key owner need extra scopes on their own record?

On the key owner's own record, location and department do not require an extra scope. Holidays still require holidays:read.

curl -X GET "$API_BASE_URL/v2/users/string?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"
      }
    ]
  }
}
{
  "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": "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

FieldTypeRequiredDescriptionConstraints
idstringYesresource ID.

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.dataobjectNo
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

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

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