Skip to content

Update a location leave policy for one leave type

Use this endpoint when an active location policy needs a targeted adjustment without replacing the whole policy. It is suited to quota changes, approval or visibility toggles, accrual changes, rollover expiry, TOIL settings, and one-time cleanup of per-user overrides.

Who can make the change

Send a PATCH request for the location and leave type. The key needs the leave-policies:write scope, and the acting user is either the key owner or the user named by X-On-Behalf-Of. That header also needs the users:act-on-behalf scope and a key owner who manages the target user.

Partial updates are merged, then fully validated

Include only the settings you want to alter. Top-level values replace their current counterparts, while accrual, broughtForwardExpiration and toil are combined one field at a time. Types are strict, so a number supplied as text will not pass. After merging, the complete policy faces the same checks as a full PUT, meaning a seemingly small change can fail because the resulting combination is incomplete or inconsistent.

Accrual changes need extra care

Changing accrual.type away from NONE requires the dates that type needs. Moving to NONE removes the stored period start. Starting an accruing type also switches allowAdvanceUsage on unless your request explicitly sets it. Older accruing policies may lack periodStart: MONTHLY and SEMI-MONTHLY policies derive the current period from the location time zone and year-start day and move firstEarningDate into that period, whereas WEEKLY and BI-WEEKLY policies require you to provide periodStart or they return a validation error.

One-time actions are not saved settings

resetUserOverrides and broughtForwardExpiration.applyToPastYear are single-request actions. They are not stored or returned, and they do nothing unless present in the current request. Setting resetUserOverrides to true clears every per-user override for this policy in this location.

200, 202 and safe retries

A 200 response returns the updated policy. A 202 response means the write is still running or its result is not yet readable, so poll the operation URL until it succeeds or fails. An UNKNOWN operation status means no result arrived within 15 minutes; read the policy to determine whether the change landed, because a later result can still update the status. Use an Idempotency-Key for safe retries: the same key with the same request replays the original response for 24 hours, reuse with a different request returns 422, and retrying while the first attempt is running returns 409.

Diagnosing failures

Check the error code and details before changing your request. Validation failures list the offending fields. A 404 can mean the location is missing or outside the key's reach, the leave type is missing or deleted, or there is no active policy; details.resource distinguishes location, leaveType and leavePolicy. A 403 FEATURE_NOT_IN_PLAN response lists settings the current plan does not include, such as an accruing type, enabled TOIL, or sub-day leave intervals, although settings already present on the policy remain acceptable. Separate 403 responses cover forbidden actions and disallowed on-behalf use.

Pre-flight checklist and captured examples

Before sending: confirm the policy is already active; send only intended fields; include accrual dates when changing accrual type; supply periodStart for WEEKLY or BI-WEEKLY policies without one; check plan availability for TOIL and short intervals; add an Idempotency-Key for retryable writes; and handle both immediate and asynchronous outcomes. The quota example in code0001 raises daysPerYear and clears overrides, while code0002 shows the shape of a successful policy response and code0003 shows a pending operation response.

Decision map
SituationWhat to send or expect
Quota increase plus override cleanupSend the new yearly quota and resetUserOverrides in one request; see code0001.
TOIL in hourly stepsSend the toil settings; plan availability may apply; see hidden-sdk-0-toil.
No active policyExpect 404 and enable the policy with PUT first.
Long-running writeExpect 202 and poll the operation URL; see code0003.

PATCH requires an already active policy; use PUT to enable or replace one.

Frequently asked questions

Can PATCH create a policy for a leave type that is not active in the location?

No. PATCH only edits a policy that is already active for that leave type in that location. A missing active policy returns 404, so create or enable it first with PUT.

Why did a WEEKLY accrual update fail on accrual.periodStart?

Send accrual.periodStart with the update. Without it, a WEEKLY or BI-WEEKLY policy fails with 400 VALIDATION_ERROR on that field, unlike MONTHLY or SEMI-MONTHLY policies where the current period is derived.

What should I do after a 202 response?

Poll the returned operation URL until it reaches SUCCEEDED or FAILED. If it becomes UNKNOWN, read the policy again because the change may or may not have been applied.

How are nested fields handled in a partial update?

Include only the fields you intend to change. Nested accrual, broughtForwardExpiration and toil values are combined field by field with the existing policy, then the combined result is validated like a PUT.

curl -X PATCH "$API_BASE_URL/v2/locations/string/leave-policies/string" \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "daysPerYear": 25,
    "resetUserOverrides": true
  }'
{
  "data": {
    "locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
    "leaveTypeId": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
    "isActive": true,
    "quotaUnit": "days",
    "daysPerYear": 20,
    "hoursPerYear": 160,
    "maxRolloverDays": 5,
    "maxRolloverHours": 40,
    "hasUnlimitedDays": false,
    "isApprovalRequired": true,
    "isReasonRequired": false,
    "hideLeaveType": false,
    "allowLeaveInPast": false,
    "negativeBalanceAllowed": false,
    "shortestLeaveInterval": "HALF-DAY",
    "negativeBroughtForwardAllowed": false,
    "accrual": {
      "type": "MONTHLY",
      "capRate": 2,
      "firstEarningDate": "2026-01-01",
      "periodStart": "2026-01-01",
      "allowAdvanceUsage": false,
      "pauseWhenUserDeactivated": true
    },
    "broughtForwardExpiration": {
      "enabled": true,
      "month": 3,
      "day": 31
    },
    "toil": {
      "enabled": false
    }
  }
}
{
  "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.

leaveTypeId

FieldTypeRequiredDescriptionConstraints
leaveTypeIdstringYesleave type 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
bodyobjectYesTypes are strict (for example, a number sent as a string fails validation). Every field is optional; nested objects are merged field by field with the current policy.
body.quotaUnitstringNothe unit the quota is set inAllowed values: "days" | "hours"
body.daysPerYearnumberNothe yearly quota in days0 <= value <= 365
body.hoursPerYearnumberNothe yearly quota in hours0 <= value <= 2920
body.maxRolloverDaysnumberNothe maximum number of unused days that roll over into the next leave year0 <= value <= 365
body.maxRolloverHoursnumberNothe maximum number of unused hours that roll over into the next leave year0 <= value <= 2920
body.hasUnlimitedDaysbooleanNowhether the leave type grants unlimited leave in this location
body.isApprovalRequiredbooleanNowhether leaves of this type need approval in this location
body.isReasonRequiredbooleanNowhether a reason is required
body.hideLeaveTypebooleanNowhether the leave type is hidden from users in this location when they request leave
body.allowLeaveInPastbooleanNowhether users can request leave for past dates
body.negativeBalanceAllowedbooleanNowhether a user's balance can go negative
body.negativeBroughtForwardAllowedbooleanNowhether a negative balance is brought forward into the next leave year
body.shortestLeaveIntervalstringNothe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
body.accrualobjectNoaccrual fields to change, merged field by field with the current accrual. The merged accrual must meet the same rules as in PUT; switching to NONE drops the stored periodStart.
body.accrual.typestringNothe accrual type, for example NONE , WEEKLY or MONTHLY ; unknown values fail validation
body.accrual.capRateNothe accrual cap rate, 0 (no cap) or from 0.1 to 10
body.accrual.capRate[variant1]numberthe accrual cap rate, 0 (no cap) or from 0.1 to 10
body.accrual.capRate[variant2]numberthe accrual cap rate, 0 (no cap) or from 0.1 to 100.1 <= value <= 10
body.accrual.firstEarningDatestringNoa date in YYYY-MM-DD format^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
body.accrual.periodStartstringNoa date in YYYY-MM-DD format^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
body.accrual.allowAdvanceUsagebooleanNowhether users can use leave before it is accrued
body.accrual.pauseWhenUserDeactivatedbooleanNowhether accrual pauses while the user is deactivated
body.broughtForwardExpirationobjectNo
body.broughtForwardExpiration.enabledbooleanNowhether rolled-over leave expires. Required in PUT when broughtForwardExpiration is sent.
body.broughtForwardExpiration.monthintegerNomonth rolled-over leave expires in, for a fixed expiry date1 <= value <= 12
body.broughtForwardExpiration.dayintegerNoday of the month rolled-over leave expires on, for a fixed expiry date1 <= value <= 31
body.broughtForwardExpiration.afterDaysintegerNonumber of days after the leave year starts that rolled-over leave expires, instead of a fixed date0 <= value <= 364
body.broughtForwardExpiration.applyToPastYearbooleanNoone-time action, never stored or returned. When true, the expiry settings also apply to leave rolled over from the previous year.
body.toilobjectNo
body.toil.enabledbooleanNowhether users can request TOIL for this leave type in this location. Required in PUT. true needs a plan that includes TOIL.
body.toil.shortestIntervalstringNothe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
body.toil.requestsAllowedForUsersbooleanNowhether users can request TOIL themselves, not only approvers
body.toil.expirationbooleanNowhether earned TOIL expires
body.toil.expirationDateLeavePolicyDateNothe date earned TOIL expires; an empty string means none
body.toil.expirationDate[variant1]stringa date in YYYY-MM-DD format^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
body.toil.expirationDate[variant2]unknownthe date earned TOIL expires; an empty string means none
body.toil.expirationMonthsintegerNothe number of months after which earned TOIL expires; 0 means none0 <= value <= 12
body.resetUserOverridesbooleanNoone-time action, never stored or returned. When true, clears every per-user override of this policy in this location.

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataobjectYes
response.data.locationIdstringYesthe ID of the location this policy applies to
response.data.leaveTypeIdstringYesthe ID of the leave type this policy belongs to
response.data.isActivebooleanYesalways true, because only active policies are returned
response.data.quotaUnitstringYesthe unit the quota is set inAllowed values: "days" | "hours"
response.data.daysPerYearnumberYesthe yearly quota in days
response.data.hoursPerYearnumberNothe yearly quota in hours
response.data.maxRolloverDaysnumberYesthe maximum number of unused days that roll over into the next leave year
response.data.maxRolloverHoursnumberNothe maximum number of unused hours that roll over into the next leave year
response.data.hasUnlimitedDaysbooleanYeswhether the leave type grants unlimited leave in this location
response.data.isApprovalRequiredbooleanYeswhether leaves of this type need approval in this location
response.data.isReasonRequiredbooleanYeswhether a reason is required
response.data.hideLeaveTypebooleanYeswhether the leave type is hidden from users in this location when they request leave
response.data.allowLeaveInPastbooleanYeswhether users can request leave for past dates
response.data.negativeBalanceAllowedbooleanYeswhether a user's balance can go negative
response.data.shortestLeaveIntervalstringYesthe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
response.data.negativeBroughtForwardAllowedbooleanYeswhether a negative balance is brought forward into the next leave year
response.data.accrualobjectYesaccrual settings. Fields that are not set are left out.
response.data.accrual.typestringYesthe accrual type, for example NONE , WEEKLY or MONTHLY . NONE means the full quota is available at the start of the leave year.
response.data.accrual.capRatenumberNothe accrual cap rate, from 0.1 to 10
response.data.accrual.firstEarningDatestringNothe date accrual startsFormat: date
response.data.accrual.periodStartstringNothe start of the first accrual perioddate
response.data.accrual.allowAdvanceUsagebooleanYeswhether users can use leave before it is accrued
response.data.accrual.pauseWhenUserDeactivatedbooleanYeswhether accrual pauses while the user is deactivated
response.data.broughtForwardExpirationobjectYeswhen rolled-over leave expires. A policy with no expiry of its own follows its location's; enabled true with neither a date nor afterDays means rolled-over leave expires at the end of the leave year.
response.data.broughtForwardExpiration.enabledbooleanYeswhether rolled-over (brought forward) leave expires
response.data.broughtForwardExpiration.monthintegerNomonth rolled-over leave expires in, for a fixed expiry date; present only when enabled
response.data.broughtForwardExpiration.dayintegerNoday of the month rolled-over leave expires on, for a fixed expiry date; present only when enabled
response.data.broughtForwardExpiration.afterDaysintegerNonumber of days after the leave year starts that rolled-over leave expires, instead of a fixed date; present only when enabled
response.data.toilobjectYesTOIL settings. Fields that are not set are left out.
response.data.toil.enabledbooleanYeswhether users can request TOIL (time off in lieu) for this leave type in this location
response.data.toil.shortestIntervalstringNothe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
response.data.toil.requestsAllowedForUsersbooleanNowhether users can request TOIL themselves, not only approvers
response.data.toil.expirationbooleanNowhether earned TOIL expires
response.data.toil.expirationDatestringNothe date earned TOIL expiresdate
response.data.toil.expirationMonthsintegerNothe number of months after which earned TOIL expires

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.Allowed values: "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