REST API v2 for workspace integrations
Use this API to read and change workspace data from integrations, partner tools, internal tooling and AI agents. Each key is owned by a user, limited to the permissions it needs, and cannot exceed what its creator could do.
What v2 adds
Compared with v1, v2 adds user-owned scoped keys, synchronous writes that return the updated resource or a 202 Accepted operation to follow, webhooks for changes to leaves, users and other resources, and errors carrying a stable code, description and actionable resolution suitable for an AI agent. Checklist before calling: create a key, send it as a bearer token, choose only needed scopes, and branch on the error code rather than message text.
Base URL and first call
Append /v2 to the configured API origin. Create a key in the dashboard and send it as a bearer token, as shown in the quick-start example. A successful response returns the resource or list under data. A nextToken value indicates another page of results.
Pagination without missing records
Leave, TOIL, user and webhook lists accept limit and nextToken; other lists return all items at once. Pass nextToken unchanged to fetch the next page and stop only when it is absent. A page may be short or empty while nextToken is still present because data reach is applied after paging, so do not stop at the first short page.
Expanding related resources
Leave and user reads accept expand as a comma-separated list so related records arrive inline instead of requiring a second request. The example filters leave records by date and expands user and leaveType. Each expanded value needs the read scope for that resource; without it, the identifier is still returned and can be matched by userId, approverId or leaveTypeId.
Errors you can act on
Each failure returns the same error structure and an HTTP status from the error catalog. Branch on code; details is optional and varies by error. The most useful details are requiredScopes for INSUFFICIENT_SCOPE, field paths and messages for VALIDATION_ERROR, reason and missingScopes for ON_BEHALF_OF_NOT_ALLOWED, resourceType and id for RESOURCE_NOT_FOUND, and revocationCode and revocationReason for KEY_REVOKED.
v1 compatibility
The v1 API at /v1 with its x-api-key header keeps working for existing keys but is sealed with no new endpoints, and v1 keys do not work on v2. New integrations should use v2 keys. The legacy OAuth2 hostname note is retained privately as a compatibility mapping, not as a recommendation for new work.
| Status | When |
|---|---|
| 200 OK | Read, update or action succeeded. |
| 201 Created | The resource was created. |
| 202 Accepted | The write is still running. Follow it in Operations. |
| 204 No Content | The resource was deleted. Leaves and TOIL requests return 200 OK with the deleted request instead. |
Success and deletion outcomes; leaves and TOIL deletions return 200 OK with the deleted request instead of 204.
| Endpoint | Values |
|---|---|
| GET /v2/leaves, GET /v2/leaves/{id} | user, approver, leaveType |
| GET /v2/users, GET /v2/users/{id} | location, department, holidays |
Each value needs the read scope of the resource it embeds.
| Code | details carries |
|---|---|
| INSUFFICIENT_SCOPE | requiredScopes, plus expand when an expand value caused it. |
| VALIDATION_ERROR | fields, each with a path and a message. |
| ON_BEHALF_OF_NOT_ALLOWED | reason: TARGET_OUTSIDE_REACH or TARGET_NOT_PERMITTED, the second with missingScopes. |
| RESOURCE_NOT_FOUND | resourceType and id. |
| KEY_REVOKED | revocationCode and revocationReason. |
details is optional and depends on the error.
Frequently asked questions
Where do I go after the overview?
Create a scoped key in the dashboard, then follow the linked guides for authentication, scopes by endpoint, acting on behalf of users, idempotency, operations, errors, rate limits, webhooks, webhook events, migrating from v1, and the API reference.
Can I keep using v1 keys with v2?
Existing v1 keys continue to work on the sealed v1 API, but v1 keys do not work on v2 and new keys are v2 keys. Plan availability and dashboard location are recorded as owner-confirmed items below.
$API_BASE_URL/v2curl $API_BASE_URL/v2/departments \
-H "Authorization: Bearer vt_live_..."{
"data": [...],
"nextToken": "..."
}# First page
curl "$API_BASE_URL/v2/users?limit=100" \
-H "Authorization: Bearer vt_live_..."
# Next page, with the nextToken from the previous response (URL-encoded)
curl --get "$API_BASE_URL/v2/users" \
--data-urlencode "limit=100" \
--data-urlencode "nextToken=$NEXT_TOKEN" \
-H "Authorization: Bearer vt_live_..."curl --get "$API_BASE_URL/v2/leaves" \
--data-urlencode "startDate=2026-10-01" \
--data-urlencode "endDate=2026-10-31" \
--data-urlencode "expand=user,leaveType" \
-H "Authorization: Bearer vt_live_..."{
"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": "...",
"details": { "requiredScopes": ["leaves:write"] }
}
}| List | Default limit | Maximum |
|---|---|---|
| GET /v2/leaves | 200 | 1000 |
| GET /v2/toil | 200 | 1000 |
| GET /v2/users | 200 | 1000 |
| GET /v2/webhooks | 25 | 100 |
Only these lists paginate; other lists return every item in one response.