Use this endpoint when a user should manage the people, leave records and settings of specific locations without becoming a full Admin. The call replaces the user's managed-location list rather than appending to it, so the payload you send is the complete set the user should hold afterwards.
What this call actually changes
The request targets one user and supplies the locations that user will manage as a Location Admin. The list you send is authoritative: any location previously managed but omitted from the new list is dropped. A Location Admin is not the same as an Admin; if the goal is full administrative rights, use PATCH /v2/users/{id} with isAdmin: true instead. The endpoint requires the users:write scope and a bearer API key. The key owner, or the user named in X-On-Behalf-Of, must be an admin or a location admin who already manages every location in the request. Naming a location outside that reach produces 403 FORBIDDEN. The call waits for the change and returns the updated user with 200, or returns 202 Accepted with an operation object to poll.
Side effect when the list shrinks
If the new list contains fewer locations than the user currently manages, their reach is reduced. Their API keys and webhooks are revoked within roughly 60 seconds of the change. Plan for this before you trim a Location Admin's scope, especially if integrations depend on that user's credentials.
Inputs and controls
The path parameter id is a required string identifying the user. The body is application/json and must contain locationIds, a required array of strings with at least one item and no duplicates. The optional Idempotency-Key header is 1 to 255 printable ASCII characters and makes the write safe to retry; keys are kept for 24 hours per API key. The optional X-On-Behalf-Of header names the user the write is performed for and requires the users:act-on-behalf scope; the key owner must manage the target user. That header is ignored on GET requests. The exact request and response contracts, including the cURL example and the 200, 202 and error bodies, accompany this page as protected modules.
Worked example
Suppose a user should manage two locations, location-79c77ac8-e5bf-479f-9488-648a58379ff1 and location-6ca89536-be55-42c5-8e52-c5c4215afb9f. Send both IDs in locationIds. If the user previously managed those two plus a third, the third is removed. If the response is 200, the returned user object reflects the new state. If the response is 202, poll the operation URL until its status is SUCCEEDED or FAILED. An UNKNOWN status means no result arrived within 15 minutes; the change may or may not have been applied, so read the user resource to check.
Telling the failures apart
400 VALIDATION_ERROR means locationIds is missing, empty or contains duplicates. 400 ROLE_SCOPE_MISMATCH points to a role and scope conflict. 403 ON_BEHALF_OF_NOT_ALLOWED means the acting user is not permitted for the on-behalf-of request. 403 FORBIDDEN means a listed location sits outside the acting user's reach. 404 RESOURCE_NOT_FOUND covers a missing user, a user outside the key's data reach, or a missing location. 404 ROLE_NOT_FOUND means the Location Admin role itself cannot be found. The Idempotency-Key codes include 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_REQUEST_IN_PROGRESS and 400 INVALID_IDEMPOTENCY_KEY. 429 RATE_LIMITED asks you to wait and retry with the same key for writes. 500 INTERNAL_ERROR should be retried later, quoting the requestId if it persists.
Decision checklist before you send
Confirm the goal is Location Admin, not Admin; if full admin rights are needed, use the profile update endpoint with isAdmin: true. 2. Collect the complete final list of locations, not just the additions. 3. Remove duplicates and ensure at least one entry. 4. Check that the key owner, or the X-On-Behalf-Of user, manages every location in the list. 5. Decide whether the list shrinks; if so, warn anyone relying on the user's API keys or webhooks. 6. Attach an Idempotency-Key if the call may be retried. 7. Handle 200 directly and poll 202 operations until SUCCEEDED or FAILED.
Location Admin versus Admin
Capability
Location Admin
Admin
Manages users, leaves and settings of listed locations
Yes
Yes
Full administrative rights across the company
No
Yes
Granted by this endpoint
Yes
No
Granted by PATCH /v2/users/{id} with isAdmin: true
No
Yes
Role descriptions reflect the captured endpoint documentation; confirm current role behavior in your own environment.
Error code quick map
Status
Code
Typical cause
400
VALIDATION_ERROR
locationIds missing, empty or duplicated
400
ROLE_SCOPE_MISMATCH
Role and scope conflict
400
INVALID_IDEMPOTENCY_KEY
Malformed Idempotency-Key
403
ON_BEHALF_OF_NOT_ALLOWED
Acting user not permitted for on-behalf-of
403
FORBIDDEN
A listed location is outside the acting user's reach
404
RESOURCE_NOT_FOUND
User missing or outside data reach, or location missing
404
ROLE_NOT_FOUND
Location Admin role cannot be found
409
IDEMPOTENCY_REQUEST_IN_PROGRESS
First request with this key still running
422
IDEMPOTENCY_KEY_REUSED
Key reused with a different request
429
RATE_LIMITED
Too many requests in a short time
500
INTERNAL_ERROR
Server-side failure
Error codes and statuses are taken from the endpoint contract; always handle unexpected codes defensively.
Frequently asked questions
Does locationIds add locations or replace them?
It replaces them. The array is the complete set of locations the user manages after the call, so any location you leave out is removed.
How is a Location Admin different from an Admin?
A Location Admin manages the users, leaves and settings of the listed locations but does not hold full Admin rights. To grant Admin, use PATCH /v2/users/{id} with isAdmin: true.
What happens to the user's API keys when their location list shrinks?
Their reach is reduced and their API keys and webhooks are revoked within about 60 seconds.
What should I do with a 202 response?
Poll the operation URL until the status is SUCCEEDED or FAILED. If the status is UNKNOWN, no result arrived within 15 minutes; read the user resource to check whether the change applied.
{
"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": "CONFLICT",
"name": "Conflict",
"description": "Example post details.",
"resolution": "Read the resource again and retry with up-to-date values.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}
{
"error": {
"code": "LEAVE_NEGATIVE_BALANCE",
"name": "LeaveNegativeBalance",
"description": "Example post details.",
"resolution": "Shorten the leave, use a different leave type, or ask an admin to adjust the quota.",
"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.
Idempotency-Key
Field
Type
Required
Description
Constraints
Idempotency-Key
string
No
optional key (1 to 255 printable ASCII characters) that makes a write request safe to retry. Keys are retained for 24 hours per API key. Retrying with the same key and the same request within those 24 hours replays the original response (with the Idempotent-Replayed header). Reusing the key with a different request returns 422 IDEMPOTENCY_KEY_REUSED ; retrying while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS ; an invalid key returns 400 INVALID_IDEMPOTENCY_KEY .
1 <= length <= 255
X-On-Behalf-Of
Field
Type
Required
Description
Constraints
X-On-Behalf-Of
string
No
ID of the user the write is performed for. Requires the users:act-on-behalf scope, and the key owner must manage the target user; otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED . Ignored on GET requests.
body
Field
Type
Required
Description
Constraints
body
object
Yes
body.locationIds
array<string>
Yes
the full list of locations the user manages as Location Admin, without duplicates
1 <= items
body.locationIds[]
string
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
Returned with HTTP 202 when a write operation is still running, or succeeded but its result could not be read back yet. The Location header carries the same URL as operation.url . Poll it until the status is SUCCEEDED or FAILED .
response.operation
object
Yes
response.operation.id
string
Yes
response.operation.status
string
Yes
operation status. UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the resource to check. A result that arrives later still changes it to SUCCEEDED or FAILED.