Skip to content

Get a TOIL request

This endpoint returns one TOIL (time off in lieu) request identified by its resource ID. It is a read-only call: the key needs toil:read, and two text fields depend on a separate scope.

Request and authorization

The call is GET /v2/toil/{id}. The only path parameter is id, a required string holding the resource ID. The key is sent in the Authorization header as a Bearer token. The base scope is toil:read. The reason and statusReason fields also require leaves:read-reason, the same scope that unmasks those fields on leaves. Without that extra scope both fields come back as null, and every other field is unchanged.

What the response contains

A successful response wraps the TOIL record in a data object. The record carries identifiers for the request, the user who earned the TOIL, the approver, the leave type, the location and the department. Dates use YYYY-MM-DD; timestamps use ISO 8601. The status is one of OPEN, APPROVED, DENIED, CANCELLED, EXPIRED or DELETED. approverId and approvalDate are null until the request is approved. startHour, endHour, startMinute and endMinute appear only when isFullDayLeave is false. durationWorkingDays counts each full day, and for a part-day request it converts hours using an 8-hour day regardless of the user's working hours.

Scope checklist before you call

Check the key's scopes before debugging the response. With toil:read alone, the request succeeds and reason plus statusReason are null. With toil:read and leaves:read-reason, those two fields can carry text. If the key lacks toil:read, the call fails with an authorization or scope error rather than returning a partial record. A 404 RESOURCE_NOT_FOUND means the TOIL request does not exist or belongs to a user outside the key's data reach.

Reading a sample record

In the sample 200 response, the record has status APPROVED, a full-day flag of true, and durationWorkingDays of 1. reason contains the user's explanation, while statusReason is null because no denial or cancellation reason was recorded. approvalDate is populated because the request was approved. If the same record were fetched with a key that has toil:read but not leaves:read-reason, reason would also read null while the status, dates and identifiers stayed the same.

Error responses

Errors use a shared envelope with error.code, error.name, error.description, error.resolution and error.requestId. The documented statuses are 401 for a missing, malformed or unrecognized key; 403 for a key lacking a required scope, a revoked key, or an acting user who may not perform the action; 404 for a missing or out-of-reach resource; 429 when too many requests arrive in a short time; and 500 for an internal failure. Keep the requestId when contacting support.

Scope-to-field map
ScopeEffect on the response
toil:readBase access to the TOIL request record.
toil:read + leaves:read-reasonreason and statusReason can return text.
toil:read without leaves:read-reasonreason and statusReason return null; all other fields are unchanged.

Field-level scope behavior applies to the reason and statusReason fields only.

Status codes and meaning
StatusMeaning
200The TOIL request is returned.
401The API key is missing, malformed or not recognized.
403The key lacks a required scope, the key was revoked, or the acting user may not perform the action.
404The TOIL request does not exist or is outside the key's data reach.
429Too many requests were sent in a short time.
500Something went wrong on the server side.

Status codes are documented for this endpoint; error bodies share the common envelope.

Frequently asked questions

Why are reason and statusReason null even though the call succeeds?

Those two fields require leaves:read-reason in addition to toil:read. Without it they return null while every other field is unchanged.

What does a 404 mean for this endpoint?

It means the TOIL request does not exist or belongs to a user outside the key's data reach. Check the ID and the key owner's visibility.

How is durationWorkingDays calculated for a part-day TOIL?

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.

Why are approverId and approvalDate null?

They remain null until the request is approved. Once approved, both can be populated.

curl -X GET "$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"
  }
}
{
  "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": "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.

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
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