Delete an Automation
The delete automation endpoint removes one existing automation identified by its type and resource ID. It is a write request that needs the automations:write scope, carries no request body, and returns either an immediate 204 or a 202 Accepted with an operation you poll. This guide maps the inputs, the one optional query parameter, and the error codes you are most likely to meet.
Endpoint and authorization
The request is a DELETE to /v2/automations/{type}/{id}. Authentication uses a bearer API key sent in the Authorization header. The key must carry the automations:write scope; the acting user is either the key owner or the user named in the X-On-Behalf-Of header. No request body is sent. The automation's add-on does not need to be active for the deletion to proceed.
Path parameters
Two path values are required. The type segment must be one of the supported automation types: blackout-period, seniority-entitlement, entitlement-by-role, maximum-users-away, probation-period, leave-duration-limit, or leave-request-notice-period. Any other value returns 404 AUTOMATION_TYPE_NOT_FOUND. The id segment is the resource ID of the automation you want to remove; if no automation of that type has this ID, the response is 404 RESOURCE_NOT_FOUND.
The deleteAddedDays query option
deleteAddedDays is an optional boolean query parameter and applies only to the seniority-entitlement type. Its default is false, which keeps the days the automation awarded. Setting it to true also removes those awarded days, in the background. Sending this parameter for any other automation type, or sending a value other than true or false, fails with 400 VALIDATION_ERROR. Use the decision table below to pick the right value before you send the request.
Choosing deleteAddedDays
The table below summarizes the only valid combinations. Anything outside these rows is a validation failure, not a partial success.
Optional headers
Idempotency-Key is an optional header of 1 to 255 printable ASCII characters. Each key belongs to one API key and stays usable for 24 hours. If you resend the identical request with that key inside the window, the server returns the stored response instead of acting twice, and marks it with the Idempotent-Replayed header. Three failures surround the key: pairing it with a different request yields 422 IDEMPOTENCY_KEY_REUSED, sending it again while the first attempt is still in flight yields 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, and a malformed key yields 400 INVALID_IDEMPOTENCY_KEY. X-On-Behalf-Of names the user the write is performed for, requires the users:act-on-behalf scope, and requires the key owner to manage the target user; otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED. The header is ignored on GET requests.
Responses: 204 or 202 Accepted
A completed deletion returns 204 with an empty body. When the write is still running, or succeeded but its result could not be read back yet, the response is 202 application/json with an operation object containing id, status and url. The Location header carries the same URL as operation.url. Poll that URL until the 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 it to SUCCEEDED or FAILED.
Documented error codes
The endpoint documents these failure codes. Each error envelope includes a stable code, a short name, a description, a resolution and a requestId to quote when contacting support.
Telling the 403 and 404 failures apart
Three different 403 codes can appear, and they point at different fixes. ON_BEHALF_OF_NOT_ALLOWED means the X-On-Behalf-Of header was used without the users:act-on-behalf scope or without the key owner managing the target user. FORBIDDEN is the general permission failure. AUTOMATION_ADMIN_REQUIRED means the acting user may not delete this particular automation. On the 404 side, AUTOMATION_TYPE_NOT_FOUND means the type segment is not one of the supported values, while RESOURCE_NOT_FOUND means the type is valid but no automation of that type has the supplied ID. Fixing the type will not help a RESOURCE_NOT_FOUND, and fixing the ID will not help an AUTOMATION_TYPE_NOT_FOUND.
Worked example: removing a seniority-entitlement automation and its awarded days
Suppose you want to remove a seniority-entitlement automation and also take back the days it granted. Send DELETE to /v2/automations/seniority-entitlement/{id} with deleteAddedDays=true and an Idempotency-Key header. If the server finishes synchronously, you receive 204 and an empty body. If it returns 202, the body contains an operation object with a PENDING status and a url such as /v2/operations/pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93; poll that URL until the status becomes SUCCEEDED or FAILED. If you accidentally send deleteAddedDays=true against a blackout-period automation, the request fails with 400 VALIDATION_ERROR and nothing is deleted.
Retry checklist
Before retrying a delete, confirm four things. First, reuse the same Idempotency-Key and the same request so the original response is replayed rather than a second deletion attempted. Second, if the first response was 202, poll the operation URL rather than resending the DELETE. Third, if you receive 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, wait for the first request to finish instead of starting a parallel one. Fourth, if you receive 422 IDEMPOTENCY_KEY_REUSED, the key was already used with a different request, so generate a new key for the new request.
| Automation type | deleteAddedDays value | Effect | Result |
|---|---|---|---|
| seniority-entitlement | omitted (default false) | Keeps the days the automation awarded | Deletion proceeds |
| seniority-entitlement | true | Also removes the awarded days, in the background | Deletion proceeds |
| seniority-entitlement | false | Keeps the days the automation awarded | Deletion proceeds |
| any other supported type | omitted | Parameter does not apply | Deletion proceeds |
| any other supported type | true or false | Parameter is not valid for this type | 400 VALIDATION_ERROR |
| any supported type | any value other than true or false | Value fails validation | 400 VALIDATION_ERROR |
The table reflects the documented behavior of the delete automation endpoint and does not cover server-side conditions outside the supplied contract.
Frequently asked questions
Which scope does the delete automation endpoint require?
The key must carry the automations:write scope. The acting user is the key owner, or the user named in X-On-Behalf-Of when that header is supplied.
Does the delete request need a body?
No. The request has no body. The only input beyond the path is the optional deleteAddedDays query parameter and the optional headers.
Does the automation's add-on need to be active to delete it?
No. The automation's add-on does not need to be active for the deletion to proceed.
What should I do when the delete returns 202 instead of 204?
Read the operation object in the body and poll its url until the status is SUCCEEDED or FAILED. The Location header carries the same URL. Do not resend the DELETE while the operation is still running.
What does an operation status of 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.
How do I tell AUTOMATION_TYPE_NOT_FOUND from RESOURCE_NOT_FOUND?
AUTOMATION_TYPE_NOT_FOUND means the type segment is not one of the supported automation types. RESOURCE_NOT_FOUND means the type is valid but no automation of that type has the supplied ID. Correct the segment named by the code.
When can I use deleteAddedDays?
Only with the seniority-entitlement type. true also removes the days the automation awarded, in the background; false, the default, keeps them. Sending it for any other type, or with a value other than true or false, fails with 400 VALIDATION_ERROR.
How long is an Idempotency-Key retained?
A key stays usable for 24 hours per API key. Resending the same request with it inside that window replays the stored response with the Idempotent-Replayed header; pairing the key with a different request returns 422 IDEMPOTENCY_KEY_REUSED.
curl -X DELETE "$API_BASE_URL/v2/automations/blackout-period/string" \
-H "Authorization: Bearer "{
"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": "AUTOMATION_TYPE_NOT_FOUND",
"name": "Automation type not found",
"description": "Example post details.",
"resolution": "Use one of the automation types listed in the API reference.",
"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"
}
}type
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| type | string | Yes | automation type. Any other value returns 404 AUTOMATION_TYPE_NOT_FOUND . | Allowed values: "blackout-period" | "seniority-entitlement" | "entitlement-by-role" | "maximum-users-away" | "probation-period" | "leave-duration-limit" | "leave-request-notice-period" |
id
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| id | string | Yes | resource ID. |
deleteAddedDays
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| deleteAddedDays | boolean | No | only for seniority-entitlement . true also removes the days the automation awarded; false , the default, keeps them. Any other type fails with 400 VALIDATION_ERROR . | false |
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. |
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 |