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.
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
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| id | string | Yes | resource ID. |
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 | object | No | ||
| 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
| 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 |
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 |