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
Situation
What to send or expect
Quota increase plus override cleanup
Send the new yearly quota and resetUserOverrides in one request; see code0001.
TOIL in hourly steps
Send the toil settings; plan availability may apply; see hidden-sdk-0-toil.
No active policy
Expect 404 and enable the policy with PUT first.
Long-running write
Expect 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.
{
"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.
leaveTypeId
Field
Type
Required
Description
Constraints
leaveTypeId
string
Yes
leave type 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
Types 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.quotaUnit
string
No
the unit the quota is set in
Allowed values: "days" | "hours"
body.daysPerYear
number
No
the yearly quota in days
0 <= value <= 365
body.hoursPerYear
number
No
the yearly quota in hours
0 <= value <= 2920
body.maxRolloverDays
number
No
the maximum number of unused days that roll over into the next leave year
0 <= value <= 365
body.maxRolloverHours
number
No
the maximum number of unused hours that roll over into the next leave year
0 <= value <= 2920
body.hasUnlimitedDays
boolean
No
whether the leave type grants unlimited leave in this location
body.isApprovalRequired
boolean
No
whether leaves of this type need approval in this location
body.isReasonRequired
boolean
No
whether a reason is required
body.hideLeaveType
boolean
No
whether the leave type is hidden from users in this location when they request leave
body.allowLeaveInPast
boolean
No
whether users can request leave for past dates
body.negativeBalanceAllowed
boolean
No
whether a user's balance can go negative
body.negativeBroughtForwardAllowed
boolean
No
whether a negative balance is brought forward into the next leave year
accrual 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.type
string
No
the accrual type, for example NONE , WEEKLY or MONTHLY ; unknown values fail validation
body.accrual.capRate
No
the accrual cap rate, 0 (no cap) or from 0.1 to 10
body.accrual.capRate[variant1]
number
the accrual cap rate, 0 (no cap) or from 0.1 to 10
body.accrual.capRate[variant2]
number
the accrual cap rate, 0 (no cap) or from 0.1 to 10
0.1 <= value <= 10
body.accrual.firstEarningDate
string
No
a date in YYYY-MM-DD format
^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
body.accrual.periodStart
string
No
a date in YYYY-MM-DD format
^[12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
body.accrual.allowAdvanceUsage
boolean
No
whether users can use leave before it is accrued
body.accrual.pauseWhenUserDeactivated
boolean
No
whether accrual pauses while the user is deactivated
body.broughtForwardExpiration
object
No
body.broughtForwardExpiration.enabled
boolean
No
whether rolled-over leave expires. Required in PUT when broughtForwardExpiration is sent.
body.broughtForwardExpiration.month
integer
No
month rolled-over leave expires in, for a fixed expiry date
1 <= value <= 12
body.broughtForwardExpiration.day
integer
No
day of the month rolled-over leave expires on, for a fixed expiry date
1 <= value <= 31
body.broughtForwardExpiration.afterDays
integer
No
number of days after the leave year starts that rolled-over leave expires, instead of a fixed date
0 <= value <= 364
body.broughtForwardExpiration.applyToPastYear
boolean
No
one-time action, never stored or returned. When true, the expiry settings also apply to leave rolled over from the previous year.
body.toil
object
No
body.toil.enabled
boolean
No
whether users can request TOIL for this leave type in this location. Required in PUT. true needs a plan that includes TOIL.
whether a negative balance is brought forward into the next leave year
response.data.accrual
object
Yes
accrual settings. Fields that are not set are left out.
response.data.accrual.type
string
Yes
the 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.capRate
number
No
the accrual cap rate, from 0.1 to 10
response.data.accrual.firstEarningDate
string
No
the date accrual starts
Format: date
response.data.accrual.periodStart
string
No
the start of the first accrual period
date
response.data.accrual.allowAdvanceUsage
boolean
Yes
whether users can use leave before it is accrued
response.data.accrual.pauseWhenUserDeactivated
boolean
Yes
whether accrual pauses while the user is deactivated
response.data.broughtForwardExpiration
object
Yes
when 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.
whether users can request TOIL themselves, not only approvers
response.data.toil.expiration
boolean
No
whether earned TOIL expires
response.data.toil.expirationDate
string
No
the date earned TOIL expires
date
response.data.toil.expirationMonths
integer
No
the number of months after which earned TOIL expires
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.