Skip to content

Migrating from v1 to v2

REST API v1 continues to operate exactly as it does today. Existing integrations are not forced to change, and the move to v2 can happen on your own schedule. The trade-off is that v1 is sealed: it remains read-only and receives no new endpoints or fields. New features, write access and webhooks exist only in v2. This guide explains what changes, how to adapt your code, and how to retire the old key safely.

What changes between v1 and v2

The biggest shift is not the URL but the permission model. A v1 key belongs to the workspace and sees everything. A v2 key belongs to the person who created it, carries explicit scopes, and can only see data that person can see. Scopes never exceed the owner's role. The dashboard no longer creates v1 keys; existing v1 keys keep working and appear as legacy keys on the Open API add-on page, where they can be deleted. A v1 key does not work on v2 — v2 requires a key beginning with vt_live_..., created on the same Open API add-on page.

The table below summarizes the structural differences. Treat the base paths, header names and envelope shapes as exact contract values.

Success responses

In v1, a successful response wraps its payload in a status field set to ok. In v2 that wrapper is removed: the payload sits directly under data. If your client checks status === "ok" before reading the body, that check must be removed or it will fail on every v2 response. Read data (and nextToken, when present) directly, and rely on the HTTP status code to determine success or failure.

Errors

Every v2 error — including authentication failures and requests to unknown paths — uses a single envelope with a nested error object. The fields are: code, a stable identifier you should branch on rather than the human-readable text; name, a short label; description, what went wrong; resolution, what to do about it; requestId, which you should include when contacting support; and details, optional extra data such as the invalid fields.

A useful distinction for triage: the HTTP status code remains the source of truth for whether the call succeeded or failed, exactly as in v1. The error.code value is what you switch on to decide how to recover. Do not parse description or message text for control flow.

Endpoint mapping and field differences

Each of the six v1 endpoints has a v2 counterpart. The v2 version takes the same query parameters and returns the same fields, apart from the exceptions in the mapping table. The most consequential changes are in leaves and expanded users. In v2, reason requires the leaves:read-reason scope (which also covers TOIL) and is null without it; v1 always returned the reason. v2 leaves also add statusReason and approvedLevel, and fill in createdAt, which v1 left empty. When you use expand, the embedded user and approver use the v2 user shape: departmentId instead of teamId, and no role.

Single-resource reads such as GET /v2/<resource>/{id} are new in v2 and are not available in v1. Departments and locations gain extra fields on the single-resource endpoint; labels always return a numeric userCount (zero when no user has the label); leave types add position and calendarStatus.

v2 also validates query parameters that v1 passed through. Invalid input returns 400 VALIDATION_ERROR with the offending fields in details. limit must be an integer between 1 and 1000, and startDate and endDate on GET /v2/leaves must be YYYY-MM-DD dates without a time component.

Key ownership and data reach

Because a v2 key is tied to its creator, the same integration can return different results depending on who owns the key. An administrator-owned key sees the whole workspace, matching v1. A location admin sees only the locations they manage. An approver sees only the departments they approve and cannot read departments, locations or labels. A regular user sees only themselves and likewise cannot read departments, locations or labels.

If the integration must keep the full visibility it had under v1, issue the v2 key from an administrator account. Note that a v2 key's reach can be narrower than what its owner sees in the product interface, and the Visibility add-on does not lift that ceiling. When results are missing after migration, check both the key's scopes and the owner's data reach before assuming a bug.

Migration checklist

  1. Create a v2 key. On the Open API add-on page, grant the scopes your v1 integration uses: departments:read, locations:read, labels:read, leave-types:read, leaves:read, users:read and holidays:read. These match what a v1 key can read. Create the key as an administrator if the integration needs the whole workspace. Copy the secret immediately — it is shown only once.
  1. Switch the base URL and header. Change $API_BASE_URL/v1 to $API_BASE_URL/v2, and replace the x-api-key: <key> header with Authorization: Bearer vt_live_....
  1. Rework how you read responses. Drop the status: "ok" check and read data (plus nextToken when present) directly. For failures, branch on error.code rather than the message text. If your parser is strict about leave types, leaves or expanded users, apply the field differences from the endpoint mapping.
  1. Test against v2 and compare results with v1. If data is missing, check the key's scopes and the owner's data reach.
  1. Retire the v1 key. Once the integration is confirmed on v2, remove the legacy v1 key on the Open API add-on page. Removal is permanent: the key stops working and cannot be reissued.
Structural differences between v1 and v2
—v1v2
Base path$API_BASE_URL/v1$API_BASE_URL/v2
Authenticationx-api-key: <key> headerAuthorization: Bearer vt_live_... header
KeysCompany-wide, unscopedOwned by a user, with scopes (for example leaves:read) that never exceed the owner's role. A key sees only the data its owner can see.
Success envelope{ "status": "ok", "data": ... }{ "data": ... }
Error envelope{ "status": "error", "message": "..." } or { "message": "..." }{ "error": { "code", "name", "description", "resolution", "requestId", "details" } }
Paginationlimit and nextTokenSame: limit and nextToken, with nextToken at the top level next to data
AccessRead onlyRead and write, plus webhooks
Single resourcesNot availableGET /v2/<resource>/{id}

Exact contract values; do not alter base paths, header names or envelope shapes.

v2 error envelope fields
FieldDescription
codeStable error code. Branch on this, not on the text.
nameShort name of the error
descriptionWhat went wrong
resolutionHow to fix it
requestIdInclude it when you contact support
detailsOptional extra data, for example the invalid fields

The HTTP status code remains the source of truth for success or failure.

v1 to v2 endpoint mapping
v1v2ScopeDifferences
GET /v1/departmentsGET /v2/departmentsdepartments:readSame fields. GET /v2/departments/{id} also returns parentId and approvers.
GET /v1/locationsGET /v2/locationslocations:readSame fields. GET /v2/locations/{id} also returns the year start, first day of the week, quota reset and rollover expiry settings.
GET /v1/labelsGET /v2/labelslabels:readSame fields. userCount is always a number (0 when no user has the label).
GET /v1/leave-typesGET /v2/leave-typesleave-types:readAdds position and calendarStatus.
GET /v1/leavesGET /v2/leavesleaves:read, plus leaves:read-reason for the reasons and the read scope of each expand valueAdds reason, statusReason and approvedLevel, and fills in createdAt, which v1 leaves empty. v1 always returned the reason; in v2 it needs leaves:read-reason (which covers TOIL too) and is null without it. With expand, the embedded user and approver use the v2 user shape (departmentId instead of teamId, no role).
GET /v1/usersGET /v2/usersusers:read, plus the read scope of each expand valueSame fields. employeeId, startDate and endDate are null when not set, as in v1.

All six v1 endpoints have a v2 equivalent accepting the same query parameters and returning the same fields, except as listed.

Key owner role and visible data
Key owner rolev1 keyv2 key
AdministratorThe whole workspaceThe whole workspace
Location adminThe whole workspaceOnly the locations they manage
ApproverThe whole workspaceOnly the departments they approve. The key cannot read departments, locations or labels.
UserThe whole workspaceOnly themselves. The key cannot read departments, locations or labels.

A v2 key can see less than its owner sees in the product interface; the Visibility add-on does not change this ceiling.

Frequently asked questions

Will my existing v1 integration stop working?

No. v1 keeps working as it does today, and existing v1 keys keep working. The dashboard no longer creates new v1 keys, and v1 receives no new endpoints or fields. New features, write access and webhooks are v2 only.

Can I use my v1 key on v2?

No. v1 keys do not work on v2. Create a v2 key beginning with vt_live_... on the Open API add-on page. The secret is shown only once, so copy it immediately.

Why does v2 return less data than v1 for the same request?

A v1 key belongs to the workspace and sees everything. A v2 key belongs to its creator and is limited to that person's data reach. An approver or regular user key cannot read departments, locations or labels. Create the v2 key as an administrator to preserve full-workspace visibility.

Should I branch on the HTTP status or the error code?

Use the HTTP status code to decide whether the call succeeded or failed, as in v1. Use error.code to decide how to recover. Do not parse description or message text for control flow.

Can a deleted v1 key be recreated?

No. A deleted v1 key stops working and cannot be recreated. Delete it only after the integration is confirmed to run on v2.

{
  "status": "ok",
  "data": [{ "id": "...", "name": "Engineering", "isDefault": false, "createdAt": "..." }]
}
{
  "data": [{ "id": "...", "name": "Engineering", "isDefault": false, "createdAt": "..." }]
}
{
  "error": {
    "code": "...",
    "name": "...",
    "description": "Example post details.",
    "resolution": "What to do about it.",
    "requestId": "...",
    "details": {}
  }
}
# v1
curl $API_BASE_URL/v1/departments \
  -H "x-api-key: your-api-key"

# v2
curl $API_BASE_URL/v2/departments \
  -H "Authorization: Bearer vt_live_..."