Skip to content

Update a location

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 situationOutcomeWhat to do
Same key, identical request, within 24 hoursOriginal response is replayed, marked with the Idempotent-Replayed headerTreat the replayed response as the result; no second change is applied
Same key, but the request body or parameters differ422 IDEMPOTENCY_KEY_REUSEDGenerate a new key for the changed request instead of reusing the old one
Same key, first request still running409 IDEMPOTENCY_REQUEST_IN_PROGRESSWait for the in-flight request to finish, then retry with the same key
Key outside the allowed format400 INVALID_IDEMPOTENCY_KEYSend 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.

curl -X PATCH "$API_BASE_URL/v2/locations/string" \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "timezone": "America/Denver"
  }'
{
  "data": {
    "id": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
    "name": "Los Angeles",
    "timezone": "America/Los_Angeles",
    "isDefault": false,
    "createdAt": "2022-08-22T15:00:00.000Z"
  }
}
{
  "operation": {
    "id": "pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93",
    "status": "PENDING",
    "url": "/v2/operations/pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93"
  }
}
{
  "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

FieldTypeRequiredDescriptionConstraints
idstringYesresource ID.

Idempotency-Key

FieldTypeRequiredDescriptionConstraints
Idempotency-KeystringNooptional 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

FieldTypeRequiredDescriptionConstraints
X-On-Behalf-OfstringNoID 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

FieldTypeRequiredDescriptionConstraints
bodyobjectYes1 <= properties
body.namestringNolocation name; leading and trailing spaces are trimmed1 <= length
body.timezonestringNoan IANA time zone name
body.firstDayOfWeekintegerNofirst day of the week, 0 (Sunday) to 6 (Saturday)0 <= value <= 6
body.resetQuotasstringNowhether leave quotas reset at the start of the fiscal year or on each user's employment anniversaryAllowed values: "FISCAL_YEAR" | "USER_YEAR"
body.yearStartMonthintegerNomonth the fiscal leave year starts in, used when resetQuotas is FISCAL_YEAR1 <= value <= 12
body.yearStartDayintegerNoday of the month the fiscal leave year starts on; together with the new or current yearStartMonth it must exist every year1 <= value <= 31
body.isDefaultbooleanNowhether this is the company's default location. Sending false for the current default location fails with 409 DEFAULT_LOCATION_UNSET_FORBIDDEN .
body.userIdsarray<string>Nothe 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

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataobjectYes
response.data.idstringYeslocation ID
response.data.namestringYeslocation name
response.data.timezonestringNothe location's IANA time zone, left out when none is stored
response.data.isDefaultbooleanYeswhether this is the company's default location
response.data.createdAtstringYesa timestamp in the ISO 8601 formatFormat: date-time

response

FieldTypeRequiredDescriptionConstraints
responseobjectReturned 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.operationobjectYes
response.operation.idstringYes
response.operation.statusstringYesoperation 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.urlstringYes

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

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