This endpoint modifies a single location. Send a PATCH to /v2/locations/{id} with the fields you want to change; anything you leave out stays as it is. The call needs the locations:write scope, and the acting user is either the API key owner or the user named in X-On-Behalf-Of. The response is either the updated location (200) or a 202 Accepted carrying an operation you poll until it finishes.
Request shape and authorization
The method is PATCH on /v2/locations/{id}. The path parameter id is a required string identifying the location. Authentication uses a bearer token sent as Authorization: Bearer <token>, and the key must carry the locations:write scope. Two optional headers matter here: Idempotency-Key makes the write safe to retry, and X-On-Behalf-Of names the user the write is performed for (it needs the users:act-on-behalf scope, and the key owner must manage that user). Full header and path contracts are in the protected modules referenced below.
Merge semantics: what changes and what stays
At least one field is required, and the request is merged with the location's current state and members. Fields you omit are preserved. Two exceptions deserve attention. First, userIds is a full replacement: any user currently in the location whose ID is missing from the list is moved to the company's default location. Second, isDefault: false on the current default location fails with 409 DEFAULT_LOCATION_UNSET_FORBIDDEN — to move the default, set another location's isDefault to true instead. yearStartMonth and yearStartDay are validated together against current values, and the day must exist in the month every year. Brought-forward expiration is configured per leave policy (broughtForwardExpiration), not on the location.
Field map and controls
The request body is application/json and accepts these fields: name (string, trimmed, minimum length 1), timezone (IANA name), firstDayOfWeek (integer 0–6, Sunday to Saturday), resetQuotas (FISCAL_YEAR or USER_YEAR), yearStartMonth (integer 1–12), yearStartDay (integer 1–31), isDefault (boolean), and userIds (array of strings, full replacement membership). The exact schema, enum values and constraints live in the protected schema modules; use those as the source of truth when generating clients.
Responses: 200 vs 202
A 200 response returns the location object with id, name, timezone (omitted when none is stored), isDefault and createdAt. A 202 response returns an operation object with id, status and url; the Location header carries the same URL. Poll that URL until status is SUCCEEDED or FAILED. UNKNOWN means no result arrived within 15 minutes — the change may or may not have been applied, so read the resource to check; a later result still updates the status. The exact response shapes are in the protected schema modules.
Error outcomes and how to resolve them
The endpoint can return: 400 VALIDATION_ERROR (details.fields lists the failing fields), 400 INVALID_REQUEST_BODY, 403 ON_BEHALF_OF_NOT_ALLOWED, 403 FORBIDDEN, 404 RESOURCE_NOT_FOUND (the location does not exist or is outside the key's data reach), 409 DEFAULT_LOCATION_UNSET_FORBIDDEN, 409 DUPLICATE_NAME, 422 UNKNOWN_USER_IDS, and the Idempotency-Key codes (422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, 400 INVALID_IDEMPOTENCY_KEY). The error envelope carries code, name, description, resolution and requestId; include requestId when contacting support. Exact error bodies are in the protected code modules.
Retry decision table
Use this table to decide what a repeated Idempotency-Key will do before you resend a PATCH. The key is scoped per API key and kept for 24 hours.
Pre-flight checklist
Before sending the PATCH, confirm: (1) the key has locations:write; (2) if using X-On-Behalf-Of, the key also has users:act-on-behalf and the owner manages the target user; (3) the body contains at least one field; (4) if sending userIds, the list is the complete intended membership, because omitted users are moved to the default location; (5) you are not sending isDefault:false for the current default; (6) yearStartMonth and yearStartDay form a date that exists every year; (7) you have an Idempotency-Key if you plan to retry.
What happens when you resend with the same Idempotency-Key
Retry situation
Outcome
What to do
Same key, identical request, within 24 hours
Original response is replayed, marked with the Idempotent-Replayed header
Treat the replayed response as the result; no second change is applied
Same key, but the request body or parameters differ
422 IDEMPOTENCY_KEY_REUSED
Generate a new key for the changed request instead of reusing the old one
Same key, first request still running
409 IDEMPOTENCY_REQUEST_IN_PROGRESS
Wait for the in-flight request to finish, then retry with the same key
Key outside the allowed format
400 INVALID_IDEMPOTENCY_KEY
Send 1 to 255 printable ASCII characters
Outcomes reflect the captured source contract; key retention is 24 hours per API key.
Frequently asked questions
Does PATCH replace the whole location or only the fields I send?
Only the fields you send change; everything else is merged with the current state. The exception is userIds, which replaces the full membership — any current member whose ID is missing is moved to the company's default location.
How do I change the default location?
Set another location's isDefault to true. Sending isDefault: false for the current default location fails with 409 DEFAULT_LOCATION_UNSET_FORBIDDEN.
What should I do when the API returns 202?
Read the operation.url from the response (also in the Location header) and poll it until status is SUCCEEDED or FAILED. If status is UNKNOWN, no result arrived within 15 minutes; read the location to check whether the change applied.
Can I safely retry an update?
Yes, if you attach an Idempotency-Key of 1 to 255 printable ASCII characters. Each key is kept for 24 hours per API key. Resending the identical request with that key within the window returns the original response again, flagged by the Idempotent-Replayed header. If the body or parameters differ, the API rejects the reuse with 422 IDEMPOTENCY_KEY_REUSED. If the earlier attempt has not finished yet, the retry is refused with 409 IDEMPOTENCY_REQUEST_IN_PROGRESS. A key that breaks the character or length rule returns 400 INVALID_IDEMPOTENCY_KEY.
Where do I configure when brought-forward days expire?
That setting lives on the leave policy (broughtForwardExpiration), not on the location. Use the leave policy endpoints to change it.
{
"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
1 <= properties
body.name
string
No
location name; leading and trailing spaces are trimmed
1 <= length
body.timezone
string
No
an IANA time zone name
body.firstDayOfWeek
integer
No
first day of the week, 0 (Sunday) to 6 (Saturday)
0 <= value <= 6
body.resetQuotas
string
No
whether leave quotas reset at the start of the fiscal year or on each user's employment anniversary
Allowed values: "FISCAL_YEAR" | "USER_YEAR"
body.yearStartMonth
integer
No
month the fiscal leave year starts in, used when resetQuotas is FISCAL_YEAR
1 <= value <= 12
body.yearStartDay
integer
No
day of the month the fiscal leave year starts on; together with the new or current yearStartMonth it must exist every year
1 <= value <= 31
body.isDefault
boolean
No
whether this is the company's default location. Sending false for the current default location fails with 409 DEFAULT_LOCATION_UNSET_FORBIDDEN .
body.userIds
array<string>
No
the full replacement membership. Any user currently in this location whose ID is missing here is moved to the company's default location. When omitted, the current members are kept.
body.userIds[]
string
response
Field
Type
Required
Description
Constraints
response
object
response.data
object
Yes
response.data.id
string
Yes
location ID
response.data.name
string
Yes
location name
response.data.timezone
string
No
the location's IANA time zone, left out when none is stored
response.data.isDefault
boolean
Yes
whether this is the company's default location
response.data.createdAt
string
Yes
a timestamp in the ISO 8601 format
Format: date-time
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.
"PENDING" | "SUCCEEDED" | "FAILED" | "UNKNOWN"
response.operation.url
string
Yes
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
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