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 | Effect on the response |
|---|---|
| toil:read | Base access to the TOIL request record. |
| toil:read + leaves:read-reason | reason and statusReason can return text. |
| toil:read without leaves:read-reason | reason and statusReason return null; all other fields are unchanged. |
Field-level scope behavior applies to the reason and statusReason fields only.
| Status | Meaning |
|---|---|
| 200 | The TOIL request is returned. |
| 401 | The API key is missing, malformed or not recognized. |
| 403 | The key lacks a required scope, the key was revoked, or the acting user may not perform the action. |
| 404 | The TOIL request does not exist or is outside the key's data reach. |
| 429 | Too many requests were sent in a short time. |
| 500 | Something 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
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| id | string | Yes | resource ID. |
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 | |
| response.data.status | string | Yes | TOIL request status | "OPEN" | "APPROVED" | "DENIED" | "CANCELLED" | "EXPIRED" | "DELETED" |
| response.data.reason | string | null | Yes | 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 | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |