Skip to content

Deny a TOIL request

Use this endpoint to reject a TOIL request that is still awaiting a decision. It records an optional explanation for the employee, checks that the caller is authorised to decide, and either returns the updated request or hands you an operation to poll when the write has not finished yet.

Before you call

Send a POST request to /v2/toil/{id}/deny, where id is the TOIL request identifier. Authenticate with a Bearer API key that carries the leaves:approve scope. Before calling, confirm three things: the target request is still OPEN, the acting user holds an approver, location-admin, or admin role for the requester, and you have decided what explanation — if any — the employee should see. A practical checklist is: resolve the request ID, verify its current status, confirm the caller's role and scope, choose a reason, add an Idempotency-Key if you may need to retry, then send the request and branch on the status code.

Parameters and headers

The path parameter id is required and identifies the TOIL request. Two optional headers change how the call behaves. Idempotency-Key, between 1 and 255 printable ASCII characters, makes the write safe to retry: the same key with the same request within 24 hours replays the original response, reusing it with a different request returns 422 IDEMPOTENCY_KEY_REUSED, retrying while the first attempt is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS, and an invalid key returns 400 INVALID_IDEMPOTENCY_KEY. X-On-Behalf-Of names the user the write is performed for; it requires the users:act-on-behalf scope and the key owner must manage that user, otherwise the call fails with 403 ON_BEHALF_OF_NOT_ALLOWED.

Optional denial reason

The JSON body is optional. Its only field is reason, an optional string that may be empty. Whatever you send is persisted as the request's statusReason and displayed to the user, so phrase it as a clear explanation rather than an internal note. Text that looks like HTML or script is rejected by validation on leave-related decisions, so send plain text. For example, an approver might explain that a release moved to a weekday, giving the employee a concrete reason for the denial.

Reading the response: 200 versus 202

The endpoint waits for the denial to complete when it can. A 200 response returns the denied TOIL request, including its status and statusReason. A 202 Accepted response means the write is still running or its result cannot yet be read back; the body contains an operation with an id, a status, and a url, and the Location header carries the same URL. Poll that URL until the operation reports SUCCEEDED or FAILED. If the status is UNKNOWN, no result arrived within 15 minutes and the change may or may not have been applied, so read the TOIL request itself before deciding whether to retry.

Telling failures apart

Distinguish failures by cause rather than treating every error the same. A 400 VALIDATION_ERROR points at specific fields listed in details.fields. A 403 FORBIDDEN means the acting user is not an approver of the requester, which is different from 403 ON_BEHALF_OF_NOT_ALLOWED, where the on-behalf arrangement itself is not permitted. A 404 RESOURCE_NOT_FOUND means the request does not exist or sits outside the key's data reach. A 422 TOIL_REQUEST_NOT_OPEN means the decision window has closed. Authentication and scope problems surface as 401 or INSUFFICIENT_SCOPE, rate limiting as 429, and unexpected server faults as 500; error bodies include a requestId to quote when seeking help.

Deny endpoint responses at a glance
StatusMeaningWhat to do next
200Denial completed; the denied TOIL request is returnedUse the returned request, including statusReason
202Write still running or result not yet readablePoll operation.url until SUCCEEDED or FAILED
400Validation failed, including invalid Idempotency-KeyFix the fields named in details.fields and resend
403Acting user is not an approver, or on-behalf use is not allowedCheck the acting user's role and users:act-on-behalf scope
404TOIL request missing or outside the key's data reachCheck the ID and that the key owner can see the request
422TOIL request is not OPEN, or Idempotency-Key reusedRe-read the request; use a fresh key for a different request

Response behaviour for the deny operation; operation polling details are in the protected contract modules.

Frequently asked questions

Who is allowed to deny a TOIL request through this endpoint?

The acting user — either the API key owner or the user named in X-On-Behalf-Of — must be an approver for that person's department, a location admin, or an admin, and the key needs the leaves:approve scope.

Is a denial reason required?

No. You may omit the body entirely, or send an empty reason. When you do supply a reason, it is saved as statusReason and shown to the requesting user, so write it for that audience.

What is the difference between a 200 and a 202 response?

A 200 response returns the denied TOIL request directly. A 202 response means the write is still running; it returns an operation object with an id, status, and url that you poll until the status becomes SUCCEEDED or FAILED.

What happens if the TOIL request is no longer open?

Only a request still in OPEN status can be denied. If it has already been approved, denied, or cancelled, the call fails with 422 TOIL_REQUEST_NOT_OPEN, so read the request first and retry only if it is still open.

curl -X POST "$API_BASE_URL/v2/toil/string/deny" \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "The release was moved to a weekday"
  }'
{
  "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.

body

FieldTypeRequiredDescriptionConstraints
bodyobjectNo
body.reasonstringNooptional reason for the decision, may be empty; stored as statusReason. On leaves, text that looks like HTML or script fails validation.

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