Skip to content

Disable a location's leave policy for a leave type

This endpoint turns off a leave type's policy for one location. Once it succeeds, people in that location can no longer request that leave type. The leave type itself is not removed, and you can turn the policy back on with the PUT endpoint. The request has no body and needs the leave-policies:write scope.

What this call changes

The DELETE call targets a specific pairing: one location ID and one leave type ID. It disables the active policy for that pair, so the leave type stops being available to request in that location. It does not delete the leave type from the account. To restore availability, use the enable-or-replace endpoint (PUT). The acting user is the API key owner, or the user named in X-On-Behalf-Of when that header is supplied.

Request shape and required inputs

The method is DELETE and the path is /v2/locations/{id}/leave-policies/{leaveTypeId}. Both path parameters are required strings: id is the resource ID of the location, and leaveTypeId is the ID of the leave type. There is no request body. The Authorization header carries the API key as a Bearer token. The full contract for the path parameters, headers, and response bodies is delivered in the accompanying protected modules; the table below is a reader map, not a replacement for those exact definitions.

Optional headers that change behavior

Idempotency-Key is optional and accepts 1 to 255 printable ASCII characters. Each key is stored for 24 hours per API key. If you send the same request again with the same key inside that window, the server returns the original response and adds the Idempotent-Replayed header. Three failure modes are documented: using the key for a different request returns 422 IDEMPOTENCY_KEY_REUSED; sending a retry while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS; and a key that fails validation returns 400 INVALID_IDEMPOTENCY_KEY. X-On-Behalf-Of is optional too, and it identifies whose behalf the write runs on. The key must carry the users:act-on-behalf scope, and whoever owns the key has to be able to manage that target user; if either condition is missing, the call comes back as 403 ON_BEHALF_OF_NOT_ALLOWED. GET requests disregard this header.

Reading the response: 204 vs 202

A 204 response means the change is complete and there is no body to read. A 202 response means the write is still running, or it finished but the result could not be read back yet. In the 202 case the body contains an operation object with id, status, and url. The Location header carries the same URL as operation.url. Poll that URL until status becomes SUCCEEDED or FAILED. If status is UNKNOWN, 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.

Documented error cases

The endpoint documents 403 ON_BEHALF_OF_NOT_ALLOWED, 403 FORBIDDEN, 404 RESOURCE_NOT_FOUND, and the Idempotency-Key error codes. The 404 case is important for troubleshooting: it covers a location that does not exist or is outside the key's data reach, and also a leave type that has no active policy in that location. The response-body sections also list 400, 401, 409, 422, 429, and 500 envelopes. The exact error envelopes are supplied in the protected modules; use the error.code and requestId fields when diagnosing or contacting support.

Pre-flight checklist

  1. Confirm the key has leave-policies: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. Confirm the location ID is within the key's data reach. 4. Confirm the leave type currently has an active policy in that location; otherwise expect 404 RESOURCE_NOT_FOUND. 5. If you plan to retry, generate an Idempotency-Key and reuse it only for the identical request. 6. On 202, poll operation.url until SUCCEEDED or FAILED; on UNKNOWN, re-read the resource rather than assuming success.

Example: a 202 response and how to poll it

The supplied cURL example calls DELETE on /v2/locations/string/leave-policies/string with a Bearer Authorization header. If the server returns 202, the body looks like the operation object in the protected JSON module: an operation with id, status PENDING, and a url such as /v2/operations/pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93. Poll that URL until status changes. If it becomes SUCCEEDED, the policy is disabled. If it becomes FAILED, inspect the error. If it stays UNKNOWN, read the location's leave policies to see whether the policy is still active before retrying.

Field and control map
ItemLocationRequiredNotes
idpathyesLocation resource ID (string).
leaveTypeIdpathyesLeave type ID (string).
AuthorizationheaderyesBearer token carrying the API key.
Idempotency-Keyheaderno1–255 printable ASCII characters; retained 24 hours per API key.
X-On-Behalf-OfheadernoUser ID; requires users:act-on-behalf and key-owner management of that user.
operation.id202 bodyyes on 202Operation identifier.
operation.status202 bodyyes on 202PENDING, SUCCEEDED, FAILED, or UNKNOWN.
operation.url202 bodyyes on 202Poll this URL; same value as the Location header.

This map is a reader aid. The exact schema definitions, requiredness, and enum values are supplied in the protected contract modules and take precedence.

Frequently asked questions

Does this delete the leave type?

No. It disables the leave type's policy in that one location. The leave type itself remains, and you can enable the policy again with the PUT endpoint.

Why do I get 404 RESOURCE_NOT_FOUND?

The documented causes are: the location does not exist, the location is outside the key's data reach, or the leave type has no active policy in that location. Check the IDs and the key's access before retrying.

What should I do after a 202 response?

Read operation.url from the body (or the Location header) and poll it until status is SUCCEEDED or FAILED. If status is UNKNOWN, no result arrived within 15 minutes; read the resource to check whether the change was applied.

Can I safely retry this DELETE?

Yes, if you send an Idempotency-Key and reuse the same key only for the identical request. Reusing the key for a different request returns 422 IDEMPOTENCY_KEY_REUSED; retrying while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS.

How does X-On-Behalf-Of work here?

It names the user the write is performed for. The key needs the users:act-on-behalf scope, and the key owner must manage that user. Otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED.

curl -X DELETE "$API_BASE_URL/v2/locations/string/leave-policies/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": "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.

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