Get a leave type
This endpoint returns a single leave type from the REST API v2 surface. It is a read-only GET on /v2/leave-types/{id}, authenticated with a bearer API key that carries the leave-types:read scope. Use it when you already know the leave type's resource ID and need its current name, active flag, colour, display order or calendar behaviour.
Request contract
The method is GET and the path is /v2/leave-types/{id}. The only path parameter is id, a required string holding the resource ID. Authentication uses the Authorization header in the form Bearer <token>, where the key is a vt_live_ secret. The key must include the leave-types:read scope; how keys are created and how the key owner's role narrows them is covered in the authentication and scopes documentation for this API.
The exact request shape, the cURL example and the generated client variants are supplied as protected contract modules (code0001 and hidden-sdk-0-_default) and should be reproduced verbatim rather than retyped by hand.
Reading the 200 response
A successful call returns a JSON envelope whose data object is the leave type. The fields are fixed by the schema, so treat them as the contract rather than as optional extras:
- id — the leave type ID (string).
- name — the leave type name (string).
- isActive — whether the leave type is active (boolean).
- color — the leave type colour in #RRGGBB format (string).
- position — the leave type's display order, read-only and set in the dashboard (integer).
- calendarStatus — how leaves of this type appear on connected calendars such as Outlook and Google; the allowed values are "Busy" or "Free".
The sample payload in the protected module code0002 shows a Vacation leave type with isActive true, colour #1E90FF, position 0 and calendarStatus "Busy". Use those values as a shape reference, not as data from your own account. The full response schema is delivered as protected module schema0003.
Telling the error responses apart
Every failure uses the same error envelope: code, name, description, resolution and requestId, with an optional details object. The status code tells you which layer rejected the call, and that distinction should drive your retry logic:
- 401 UNAUTHORIZED — the key is missing, malformed or not recognised. Fix the Authorization header before retrying.
- 403 INSUFFICIENT_SCOPE — the key is valid but lacks a needed scope. The details.requiredScopes list names what to add in the dashboard.
- 403 (revoked key) — the key itself is no longer valid; issue a replacement.
- 403 (acting user) — the key owner or the X-On-Behalf-Of user may not perform the action.
- 404 RESOURCE_NOT_FOUND — the leave type does not exist or was deleted, or it sits outside the data this key can access. Check the ID and the key owner's visibility before assuming deletion.
- 429 RATE_LIMITED — too many requests in a short window. Wait a few seconds and retry.
- 500 INTERNAL_ERROR — a server-side failure. Retry later and quote the requestId if it persists.
The error envelope schema is supplied as protected modules schema0004 through schema0008, and the representative error bodies as code0003, code0005 and code0006. A 404 on this endpoint is ambiguous by design: it covers both a genuinely missing leave type and one the key cannot see, so do not treat it as proof of deletion.
Pre-flight checklist
Before you send the request, confirm each of these:
- You have the leave type's resource ID, not its display name.
- The key is a full vt_live_ secret sent as Bearer <token>.
- The key carries leave-types:read.
- If you are acting for another user, the X-On-Behalf-Of user is set and permitted.
- Your client handles 404 as either missing or out-of-scope, and backs off on 429 rather than hammering the endpoint.
If a call fails and you cannot resolve it from the error body, the developer contact channel for this API is available through the site's developer support route.
Frequently asked questions
Which scope does this endpoint need?
leave-types:read. A key without it receives a 403 INSUFFICIENT_SCOPE response, and the details.requiredScopes list names the scope to add in the dashboard.
Does a 404 always mean the leave type was deleted?
No. RESOURCE_NOT_FOUND covers both a leave type that does not exist or was deleted and one that falls outside the data the key can access. Verify the ID and the key owner's visibility before concluding the record is gone.
What does calendarStatus control?
It determines how leaves of this type appear on connected calendars such as Outlook and Google. The schema allows "Busy" or "Free".
Can I change position through this endpoint?
No. position is read-only here and is set in the dashboard. To change a leave type, use the update endpoint, which requires leave-types:write.
curl -X GET "$API_BASE_URL/v2/leave-types/string" \
-H "Authorization: Bearer "{
"data": {
"id": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
"name": "Vacation",
"isActive": true,
"color": "#1E90FF",
"position": 0,
"calendarStatus": "Busy"
}
}{
"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 | 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 |