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
Outcome
What it means
Your next step
200
Deletion completed and the deleted TOIL request is returned
Use the returned record; no polling needed
202
Write is still running or its result cannot yet be read back
Poll operation.url until SUCCEEDED or FAILED
403 ON_BEHALF_OF_NOT_ALLOWED
On-behalf scope or management relationship is missing
Add users:act-on-behalf and confirm the key owner manages the target user
403 FORBIDDEN
Acting user may not perform the action
Check approver, location admin or admin role
404 RESOURCE_NOT_FOUND
TOIL request does not exist or is outside the key's data reach
Check the ID and the key owner's visibility
422 IDEMPOTENCY_KEY_REUSED
Idempotency-Key was used with a different request
Use 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.
{
"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.
response
Field
Type
Required
Description
Constraints
response
object
response.data
object
No
response.data.id
string
Yes
TOIL request ID
response.data.userId
string
Yes
an ID of the user who earned the TOIL
response.data.approverId
string | null
Yes
an ID of the approver, null until the request is approved
response.data.approverId[variant1]
string
an ID of the approver, null until the request is approved
response.data.approverId[variant2]
null
an ID of the approver, null until the request is approved
response.data.leaveTypeId
string
Yes
the ID of the leave type the TOIL is added to
response.data.startDate
string
Yes
date in YYYY-MM-DD format
date
response.data.endDate
string
Yes
date in YYYY-MM-DD format
date
response.data.isFullDayLeave
boolean
Yes
true if the TOIL covers full days, false if it covers part of a day
response.data.startHour
number
No
start hour in the user's time zone (in 24h format), returned only when isFullDayLeave is false
response.data.endHour
number
No
end hour in the user's time zone (in 24h format), returned only when isFullDayLeave is false
response.data.startMinute
number
No
start minutes in the user's time zone, returned only when isFullDayLeave is false
response.data.endMinute
number
No
end minutes in the user's time zone, returned only when isFullDayLeave is false
response.data.durationWorkingDays
number
No
the 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.locationId
string
Yes
the ID of the user's location when the TOIL request was sent
response.data.departmentId
string
Yes
the ID of the user's department when the TOIL request was sent
the 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]
string
the 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]
null
the 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.statusReason
string | null
Yes
the 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]
string
the 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]
null
the 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.approvalDate
string | null
Yes
a timestamp in the ISO 8601 format, null until the request is approved
date-time
response.data.approvalDate[variant1]
string
a timestamp in the ISO 8601 format, null until the request is approved
date-time
response.data.approvalDate[variant2]
null
a timestamp in the ISO 8601 format, null until the request is approved
date-time
response.data.createdAt
string
Yes
a timestamp in the ISO 8601 format
date-time
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.