Skip to content

List TOIL requests between two dates

This endpoint returns a paginated set of TOIL (time off in lieu) requests that overlap the date window you supply. Access is limited to users within the API key's data reach, and the key must carry the toil:read scope. Use it when you need an audit, a reconciliation export, or a dashboard view of TOIL activity across a period.

Endpoint and authorization

Send a GET request to /v2/toil. The request must include an Authorization header in the form Authorization: Bearer <token>, where the token is an API key beginning with vt_live_. The key needs the toil:read scope. The key owner's role further limits which users' TOIL requests are visible. Because that visibility filter is applied only after a page has been assembled, a response can carry fewer entries than your limit — or none at all — and still hand back a nextToken.

Query parameters

The table below maps each parameter to its role. startDate and endDate are required and use YYYY-MM-DD; endDate cannot be earlier than startDate. status is optional and, when omitted, requests in every status are returned. Unlike GET /v2/leaves, the status value is case-sensitive. limit is an integer from 1 to 1000 and defaults to 200. nextToken is the cursor returned by the previous call; send the same filters alongside it.

Status values

The status filter accepts one of these exact strings: "OPEN", "APPROVED", "DENIED", "CANCELLED", "EXPIRED", "DELETED". Because the comparison is case-sensitive, sending "open" instead of "OPEN" will not match. When you need every status, omit the parameter rather than sending an empty value.

Pagination behavior

Pagination here is cursor-based, not offset-based. Read the nextToken from the response and send it on the next call with the same startDate, endDate, status, and limit. Stop when the response has no nextToken. A page may hold fewer than limit items even when more pages exist, because the key's data reach is applied after the page is read. A token that was not issued by this API fails with 400 INVALID_PAGINATION_TOKEN.

Reading the response

A 200 response contains a data array of TOIL objects and an optional nextToken. Each TOIL object carries an id, the userId who earned the TOIL, an approverId (null until approval), the leaveTypeId the TOIL is added to, startDate and endDate, and isFullDayLeave. For part-day TOIL, startHour, endHour, startMinute, and endMinute are returned in the user's time zone in 24-hour format. durationWorkingDays expresses the duration in days: a full-day TOIL counts each day it covers, while a part-day TOIL converts its hours using an 8-hour day regardless of the user's working hours. locationId and departmentId reflect the user's location and department at the time the request was sent. status, reason, statusReason, approvalDate, and createdAt complete the object.

Reason fields and the leaves:read-reason scope

reason is the explanation the user gave; statusReason is the explanation the approver gave when denying or cancelling. Both require the leaves:read-reason scope in addition to toil:read. That single scope covers leaves and TOIL alike. Without it, both fields come back as null and every other field is unchanged — so a null reason does not necessarily mean no reason was recorded.

Error responses

A 400 VALIDATION_ERROR means a query parameter failed validation — for example a missing or malformed startDate or endDate, an invalid status or limit, or an endDate earlier than startDate. The details.fields array lists the offending fields. A 400 INVALID_PAGINATION_TOKEN means the token was not issued by this API. A 401 UNAUTHORIZED means the key is missing, malformed, or not recognized. A 403 INSUFFICIENT_SCOPE means the key lacks a required scope; the response lists the scopes to add in the dashboard. A 429 RATE_LIMITED means too many requests were sent in a short time; wait and retry. A 500 INTERNAL_ERROR means something failed on the server side; retry later and quote the requestId if the problem persists.

Worked example

The captured request below asks for TOIL requests overlapping 2023-02-03 through 2023-03-03. The sample response shows a single OPEN request for a half-day on 2026-11-07, from 10:00 to 14:00, with a reason and a nextToken. Treat the sample values as illustrative rather than as a live result. To reproduce the shape, send the same date window with your own key and follow nextToken until it is absent.

Pre-flight checklist

Before you send the request, confirm: (1) the key carries toil:read, and leaves:read-reason if you need reason fields; (2) startDate and endDate are in YYYY-MM-DD and endDate is not earlier than startDate; (3) status, if used, is one of the six uppercase values; (4) limit is between 1 and 1000; (5) on subsequent pages you resend the same filters with the new nextToken; (6) you stop when nextToken is absent, not when a page is short.

Query parameter map
ParameterRequiredTypeDefault / rangeNotes
startDateYesstring (date)—YYYY-MM-DD
endDateYesstring (date)—YYYY-MM-DD; cannot be before startDate
statusNostring enum—Case-sensitive; omit to return all statuses
limitNointeger200; 1–1000Returned items may be fewer than limit
nextTokenNostring—Cursor from previous call; resend same filters

Values reflect the endpoint reference as documented; behavior of the key's data reach can reduce page size below limit.

Error decision table
StatusCodeLikely causeFirst check
400VALIDATION_ERRORMissing or invalid startDate, endDate, status, or limit; endDate before startDatedetails.fields
400INVALID_PAGINATION_TOKENToken not issued by this APIReuse the exact nextToken from the prior response
401UNAUTHORIZEDKey missing, malformed, or unrecognizedAuthorization: Bearer vt_live_<secret>
403INSUFFICIENT_SCOPEKey lacks a required scopedetails.requiredScopes; add in dashboard
429RATE_LIMITEDToo many requests in a short timeWait and retry
500INTERNAL_ERRORServer-side failureRetry later; quote requestId to support

Error envelope fields are stable; the exact description text may vary.

Frequently asked questions

Does the endpoint return only requests fully inside the date window?

No. It returns TOIL requests that overlap the window between startDate and endDate, so a request that starts before startDate or ends after endDate can still appear.

Why does my status filter return nothing?

The status filter is case-sensitive, unlike GET /v2/leaves. Use one of the exact uppercase values: OPEN, APPROVED, DENIED, CANCELLED, EXPIRED, DELETED.

Why did I get fewer results than my limit?

Visibility is trimmed per page after the page is built, so the count you receive can fall below your limit — sometimes to zero — even though more pages remain. The presence of a nextToken, not the page size, tells you whether to continue.

Why are reason and statusReason null?

Both fields require the leaves:read-reason scope in addition to toil:read. Without it they come back as null and every other field is unchanged.

How is durationWorkingDays calculated for part-day TOIL?

A full-day TOIL counts each day it covers. A part-day TOIL converts its hours using an 8-hour day, regardless of the user's working hours.

What does INVALID_PAGINATION_TOKEN mean?

The token was not issued by this API. Use the exact nextToken returned by the previous call and resend the same filters.

curl -X GET "$API_BASE_URL/v2/toil?startDate=2023-02-03&endDate=2023-03-03" \
  -H "Authorization: Bearer "
{
  "data": [
    {
      "id": "toilRequest-3b8e6c1a-2d4f-4b7a-9c5e-8f1a2b3c4d5e",
      "userId": "user-63b17e97-d38b-4586-8498-bb4f5d2e2c14",
      "approverId": null,
      "leaveTypeId": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
      "startDate": "2026-11-07",
      "endDate": "2026-11-07",
      "isFullDayLeave": false,
      "startHour": 10,
      "endHour": 14,
      "startMinute": 0,
      "endMinute": 0,
      "durationWorkingDays": 0.5,
      "locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
      "departmentId": "team-0a21c25e-6925-4a5b-90ee-ecf82096c4f6",
      "status": "OPEN",
      "reason": "Covered the Saturday on-call shift",
      "statusReason": null,
      "approvalDate": null,
      "createdAt": "2026-11-08T17:45:12.000Z"
    }
  ],
  "nextToken": "eyJjb21wYW55SWQiOiJjNmFmOWFjNiJ9"
}
{
  "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": "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"
  }
}

startDate

FieldTypeRequiredDescriptionConstraints
startDatestringYesdate in YYYY-MM-DD format.Format: date

endDate

FieldTypeRequiredDescriptionConstraints
endDatestringYesdate in YYYY-MM-DD format, can't be before the startDate.Format: date

status

FieldTypeRequiredDescriptionConstraints
statusstringNoTOIL request status. When omitted, TOIL requests in every status are returned.Allowed values: "OPEN" | "APPROVED" | "DENIED" | "CANCELLED" | "EXPIRED" | "DELETED"

limit

FieldTypeRequiredDescriptionConstraints
limitintegerNoa number of TOIL requests to return per page, between 1 and 1000, default is 200. The number of returned items might be less than the provided limit even when more pages exist; rely on nextToken .200
1 <= value <= 1000

nextToken

FieldTypeRequiredDescriptionConstraints
nextTokenstringNoThe nextToken returned by the previous API call. Send the same filters as in the previous call. Same semantics as the v1 nextToken parameter; a token that was not issued by this API fails with 400 INVALID_PAGINATION_TOKEN .

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataarray<Toil>No
response.data[]object
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.nextTokenstringNo

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