Skip to content

Delete a TOIL request

Remove a TOIL request for a user you manage with a single DELETE call. The endpoint needs the toil:write scope, takes no request body, and either returns the deleted record or gives you an operation to poll when the write is still running.

Call shape and authorization

Send DELETE to $API_BASE_URL/v2/toil/{id}, where id is the required TOIL request resource ID in the path. There is no request body. Authenticate with Authorization: Bearer <token> using an API key that carries toil:write; the key owner's role also limits what the key can reach.

Who may act, and on whose behalf

Only approvers, location admins and admins may delete a TOIL request for a user they manage. The acting user is normally the key owner. To act for someone else, send X-On-Behalf-Of with that user's ID; this needs the users:act-on-behalf scope and a management relationship with the target user, otherwise the call fails with 403 ON_BEHALF_OF_NOT_ALLOWED. The header is ignored on GET requests.

Pre-flight checklist

Before you send: 1) Confirm the key has toil:write and, for on-behalf calls, users:act-on-behalf. 2) Confirm the acting user manages the TOIL owner. 3) Copy the exact TOIL request ID into the path. 4) Decide whether to add an Idempotency-Key for safe retries. 5) After sending, branch on the status: 200 means done, 202 means poll the operation URL.

Reading the result: 200 versus 202

A 200 response contains the deleted TOIL request under data, including its id, userId, approverId, leaveTypeId, startDate, endDate, isFullDayLeave, durationWorkingDays, locationId, departmentId, status, reason, statusReason, approvalDate and createdAt. A 202 response instead contains an operation with id, status and url; poll that URL until the status is SUCCEEDED or FAILED. UNKNOWN means no result arrived within 15 minutes and the change may or may not have been applied, so read the resource to check before retrying.

Failure distinctions that change your fix

Treat 404 RESOURCE_NOT_FOUND as 'missing or out of reach' rather than proof the ID is wrong: check both the ID and whether the key owner can see the record. Treat 403 FORBIDDEN as a role or management problem, and 403 ON_BEHALF_OF_NOT_ALLOWED as a missing on-behalf scope or management link. For 400, 401, 409, 422, 429 and 500, use the error envelope's code, name, description, resolution and requestId; include the requestId when contacting support. The example INSUFFICIENT_SCOPE response lists required scopes under details.requiredScopes.

Outcome map for deleteToil
OutcomeWhat it meansYour next step
200Deletion completed and the deleted TOIL request is returnedUse the returned record; no polling needed
202Write is still running or its result cannot yet be read backPoll operation.url until SUCCEEDED or FAILED
403 ON_BEHALF_OF_NOT_ALLOWEDOn-behalf scope or management relationship is missingAdd users:act-on-behalf and confirm the key owner manages the target user
403 FORBIDDENActing user may not perform the actionCheck approver, location admin or admin role
404 RESOURCE_NOT_FOUNDTOIL request does not exist or is outside the key's data reachCheck the ID and the key owner's visibility
422 IDEMPOTENCY_KEY_REUSEDIdempotency-Key was used with a different requestUse a new key for the changed request

Statuses and error codes are taken from the endpoint contract for this operation.

Frequently asked questions

What should I check before deleting a TOIL request?

Use a key with toil:write, confirm the acting user manages the request owner, and send the request without a body. If you receive 202, poll the operation URL until it reaches SUCCEEDED or FAILED; if it becomes UNKNOWN, read the TOIL request again before retrying.

How do I tell whether deletion finished?

A 200 response returns the deleted TOIL request. A 202 response returns an operation object with an id, status and url to poll. The operation can be PENDING, SUCCEEDED, FAILED or UNKNOWN; UNKNOWN means no result arrived within 15 minutes, so verify the resource state rather than assuming success or failure.

How does the idempotency key affect a retry?

Send an Idempotency-Key of 1 to 255 printable ASCII characters. Reusing it with the same request within 24 hours replays the original response, while reusing it with a different request returns 422 IDEMPOTENCY_KEY_REUSED, retrying while the first request runs returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, and an invalid key returns 400 INVALID_IDEMPOTENCY_KEY.

What do the main 403 and 404 errors mean?

403 ON_BEHALF_OF_NOT_ALLOWED means the on-behalf scope or management relationship is missing. 403 FORBIDDEN means the acting user may not perform the action. 404 RESOURCE_NOT_FOUND means the TOIL request does not exist or is outside the key's data reach.

curl -X DELETE "$API_BASE_URL/v2/toil/string" \
  -H "Authorization: Bearer "
{
  "data": {
    "id": "toilRequest-3b8e6c1a-2d4f-4b7a-9c5e-8f1a2b3c4d5e",
    "userId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
    "approverId": "user-0f3a9c1e-6c2b-4a5d-9e7f-1b2c3d4e5f60",
    "leaveTypeId": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
    "startDate": "2026-11-07",
    "endDate": "2026-11-07",
    "isFullDayLeave": true,
    "durationWorkingDays": 1,
    "locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
    "departmentId": "team-0a21c25e-6925-4a5b-90ee-ecf82096c4f6",
    "status": "APPROVED",
    "reason": "Worked on the weekend release",
    "statusReason": null,
    "approvalDate": "2026-11-09T08:30:00.000Z",
    "createdAt": "2026-11-08T17:45:12.000Z"
  }
}
{
  "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.

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
responseobject
response.dataobjectNo
response.data.idstringYesTOIL request ID
response.data.userIdstringYesan ID of the user who earned the TOIL
response.data.approverIdstring | nullYesan ID of the approver, null until the request is approved
response.data.approverId[variant1]stringan ID of the approver, null until the request is approved
response.data.approverId[variant2]nullan ID of the approver, null until the request is approved
response.data.leaveTypeIdstringYesthe ID of the leave type the TOIL is added to
response.data.startDatestringYesdate in YYYY-MM-DD formatdate
response.data.endDatestringYesdate in YYYY-MM-DD formatdate
response.data.isFullDayLeavebooleanYestrue if the TOIL covers full days, false if it covers part of a day
response.data.startHournumberNostart hour in the user's time zone (in 24h format), returned only when isFullDayLeave is false
response.data.endHournumberNoend hour in the user's time zone (in 24h format), returned only when isFullDayLeave is false
response.data.startMinutenumberNostart minutes in the user's time zone, returned only when isFullDayLeave is false
response.data.endMinutenumberNoend minutes in the user's time zone, returned only when isFullDayLeave is false
response.data.durationWorkingDaysnumberNothe duration of the TOIL in days. A full-day TOIL counts each day it covers; a part-day TOIL converts its hours using an 8-hour day, whatever the user's working hours.
response.data.locationIdstringYesthe ID of the user's location when the TOIL request was sent
response.data.departmentIdstringYesthe ID of the user's department when the TOIL request was sent
response.data.statusstringYesTOIL request status"OPEN" | "APPROVED" | "DENIED" | "CANCELLED" | "EXPIRED" | "DELETED"
response.data.reasonstring | nullYesthe reason the user gave for the TOIL. Requires the leaves:read-reason scope, which covers leaves and TOIL alike; without it the value is null .
response.data.reason[variant1]stringthe reason the user gave for the TOIL. Requires the leaves:read-reason scope, which covers leaves and TOIL alike; without it the value is null .
response.data.reason[variant2]nullthe reason the user gave for the TOIL. Requires the leaves:read-reason scope, which covers leaves and TOIL alike; without it the value is null .
response.data.statusReasonstring | nullYesthe reason given when the TOIL request was denied or cancelled, null when none was given. Requires the leaves:read-reason scope; without it the value is null .
response.data.statusReason[variant1]stringthe reason given when the TOIL request was denied or cancelled, null when none was given. Requires the leaves:read-reason scope; without it the value is null .
response.data.statusReason[variant2]nullthe reason given when the TOIL request was denied or cancelled, null when none was given. Requires the leaves:read-reason scope; without it the value is null .
response.data.approvalDatestring | nullYesa timestamp in the ISO 8601 format, null until the request is approveddate-time
response.data.approvalDate[variant1]stringa timestamp in the ISO 8601 format, null until the request is approveddate-time
response.data.approvalDate[variant2]nulla timestamp in the ISO 8601 format, null until the request is approveddate-time
response.data.createdAtstringYesa timestamp in the ISO 8601 formatdate-time

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