Update a leave type
This endpoint edits an existing leave type. You send a partial body: include at least one field, and anything you leave out stays as it is. The key needs the leave-types:write scope, and the write is attributed to the key owner unless you name another user in X-On-Behalf-Of. The call blocks until the change settles, then answers either with the updated leave type and a 200, or with a 202 Accepted carrying an operation you can poll.
Endpoint at a glance
Method and path: PATCH /v2/leave-types/{id}. The id path parameter is required and identifies the leave type to change. The request body is application/json and must contain at least one changeable field. The leave policies attached to a leave type are not edited here; they are changed through /v2/locations/{id}/leave-policies/{leaveTypeId}.
Authorization and headers
Send the API key as Authorization: Bearer vt_live_<secret>. The key must carry leave-types:write. Two optional headers change how the write behaves. Idempotency-Key makes a write safe to retry. X-On-Behalf-Of names the user the write is performed for; that header only works when the key also holds users:act-on-behalf and its owner has management rights over the named user, and a request that fails those conditions comes back as 403 ON_BEHALF_OF_NOT_ALLOWED. On GET requests the header has no effect.
Request body fields
All body fields are optional individually, but the body as a whole must contain at least one of them. name is the leave type name, 1 to 32 characters after trimming leading and trailing spaces. color is a hex value in #RRGGBB format, matching ^#[A-Fa-f0-9]{6}$. isActive is a boolean for whether the leave type is active. calendarStatus controls how leaves of this type appear on connected calendars (Outlook, Google) and accepts only "Busy" or "Free". awayStatus is a boolean for whether users on leave of this type get an away status in Slack. awayStatusIcon is the Slack status emoji and may be empty. awayStatusMessage is the Slack status text and may be empty.
Response paths: 200, 202 and errors
A successful synchronous update returns 200 with the leave type in the data object: id, name, isActive, color, position and calendarStatus. position is read-only and set in the dashboard, so it is not a request field. If the write is still running, or succeeded but its result could not be read back yet, the response is 202 Accepted with an operation object. The Location header carries the same URL as operation.url. Poll that URL until status is SUCCEEDED or FAILED. A status of 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 the status to SUCCEEDED or FAILED.
Error codes and what they mean
400 VALIDATION_ERROR lists the failing fields in details.fields. 400 INVALID_REQUEST_BODY means the body itself could not be parsed or accepted. 403 ON_BEHALF_OF_NOT_ALLOWED means the on-behalf header was used without the required scope or without management of the target user. 403 FORBIDDEN means the acting user may not perform the action. 404 RESOURCE_NOT_FOUND means the leave type does not exist or was deleted. 409 DUPLICATE_NAME means the requested name is already in use. The Idempotency-Key codes also apply: 422 IDEMPOTENCY_KEY_REUSED when the key is reused with a different request, 409 IDEMPOTENCY_REQUEST_IN_PROGRESS while the first request is still running, and 400 INVALID_IDEMPOTENCY_KEY for an invalid key. 401 UNAUTHORIZED, 403 INSUFFICIENT_SCOPE, 429 RATE_LIMITED and 500 INTERNAL_ERROR are also possible.
Decision checklist before you send
- Confirm the key has leave-types:write. 2. If you are acting for another user, confirm the key also has users:act-on-behalf and that the key owner manages that user. 3. Send only the fields you intend to change. 4. If you may retry, generate an Idempotency-Key of 1 to 255 printable ASCII characters and reuse the same key only for the same request. 5. Decide how your client will handle 202: store operation.url and poll until SUCCEEDED or FAILED, and treat UNKNOWN as needing a read-back. 6. If you get 409 DUPLICATE_NAME, choose a different name rather than retrying unchanged.
Worked example: deactivate a leave type
The deactivate example sends a body of {"isActive": false} to PATCH /v2/leave-types/string. That is the smallest useful partial update: it changes only the active flag and leaves name, color, calendarStatus and Slack away settings untouched. If the response is 200, the returned data shows isActive as false. If the response is 202, follow operation.url and poll until the status resolves. The second example shows a Slack away status update with awayStatus true, awayStatusIcon :palm_tree: and awayStatusMessage "On vacation".
| Field or control | Type | Required | Rule or note |
|---|---|---|---|
| id (path) | string | Yes | resource ID. |
| Idempotency-Key (header) | string | No | 1 to 255 printable ASCII characters; retained 24 hours per API key. |
| X-On-Behalf-Of (header) | string | No | Requires users:act-on-behalf and management of the target user. |
| name | string | No | 1 to 32 characters after trimming leading and trailing spaces. |
| color | string | No | Matches ^#[A-Fa-f0-9]{6}$. |
| isActive | boolean | No | Whether the leave type is active. |
| calendarStatus | LeaveTypeCalendarStatus | No | "Busy" or "Free". |
| awayStatus | boolean | No | Whether users get a Slack away status. |
| awayStatusIcon | string | No | Slack status emoji; may be empty. |
| awayStatusMessage | string | No | Slack status text; may be empty. |
All body fields are optional individually; the body as a whole must contain at least one field.
| Status | Meaning | What to do |
|---|---|---|
| 200 | Leave type updated synchronously. | Read data in the response. |
| 202 | Write still running, or succeeded but result not readable yet. | Poll operation.url until SUCCEEDED or FAILED. |
| 400 VALIDATION_ERROR | A query parameter, body field or header failed validation. | Fix fields listed in details.fields and resend. |
| 400 INVALID_REQUEST_BODY | The request body is invalid. | Correct the body and resend. |
| 403 ON_BEHALF_OF_NOT_ALLOWED | On-behalf header not permitted. | Check users:act-on-behalf scope and target user management. |
| 403 FORBIDDEN | Acting user may not perform the action. | Use a key owner with the required role. |
| 404 RESOURCE_NOT_FOUND | Leave type does not exist or was deleted. | Check the id. |
| 409 DUPLICATE_NAME | Requested name is already in use. | Choose a different name. |
| 422 IDEMPOTENCY_KEY_REUSED | Key reused with a different request. | Use a new key for a different request. |
| 409 IDEMPOTENCY_REQUEST_IN_PROGRESS | First request with this key is still running. | Wait and retry with the same key. |
| 400 INVALID_IDEMPOTENCY_KEY | Key is invalid. | Use 1 to 255 printable ASCII characters. |
The 202 response body carries operation.id, operation.status and operation.url. UNKNOWN means no result arrived within 15 minutes; read the resource to check.
Frequently asked questions
Can I send an empty body to update a leave type?
No. At least one field is required. Fields you do not send keep their current values, so send only the fields you want to change.
What is the difference between 400 VALIDATION_ERROR and 400 INVALID_REQUEST_BODY?
VALIDATION_ERROR means a specific field or header failed validation and details.fields lists the failing paths. INVALID_REQUEST_BODY means the body itself is invalid, so there may be no field-level list to inspect.
Does X-On-Behalf-Of work on this PATCH request?
Yes. Use the header to attribute the write to a specific user. Your key needs the users:act-on-behalf scope, and whoever owns the key must have management rights over that user. If either condition is missing, the call is rejected with 403 ON_BEHALF_OF_NOT_ALLOWED. GET requests disregard the header entirely.
How long does a retry key stay usable?
Each API key keeps its Idempotency-Key values for 24 hours. Inside that window, a repeat of the identical request with the same key returns the stored original response and marks it with the Idempotent-Replayed header instead of applying the change twice.
What does operation status UNKNOWN mean?
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 the status to SUCCEEDED or FAILED.
Can I change the leave type's position through this endpoint?
No. position is returned in the response but is read-only here; it is set in the dashboard.
curl -X PATCH "$API_BASE_URL/v2/leave-types/string" \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"isActive": false
}'{
"data": {
"id": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
"name": "Vacation",
"isActive": true,
"color": "#1E90FF",
"position": 0,
"calendarStatus": "Busy"
}
}{
"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
| 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 | leave type name, 1 to 32 characters after trimming leading and trailing spaces | 1 <= length <= 32 |
| body.color | string | No | leave type color in #RRGGBB format | ^#[A-Fa-f0-9]{6}$ |
| body.isActive | boolean | No | whether the leave type is active | |
| body.calendarStatus | string | No | how leaves of this type appear on connected calendars (Outlook, Google) | Allowed values: "Busy" | "Free" |
| body.awayStatus | boolean | No | whether users on leave of this type get an away status in Slack | |
| body.awayStatusIcon | string | No | the Slack status emoji; may be empty | |
| body.awayStatusMessage | string | No | the Slack status text; may be empty |
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. | Allowed values: "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 | |
| response.error.details.[key: string] | any | No |