Skip to content

List a Location's Leave Policies

This endpoint returns the active leave policies configured for one location. Each enabled leave type contributes one policy object, and the whole set arrives in a single response with no pagination. Disabled policies are not included, so the array reflects only what is currently in force for that location.

Request shape and access

The call is a GET to the location leave-policies route, with the location's resource ID in the path. Access is controlled by the leave-policies:read scope on the API key. The key is sent as a bearer token in the Authorization header. If the location does not exist, or lies outside what the key owner can reach, the endpoint answers with a 404 RESOURCE_NOT_FOUND error. The exact request line, header and path parameter contract are provided in the accompanying protected modules; treat those as the source of truth for implementation.

Reading the response

The response is a list of policy objects. Each object ties a leave type to a location and carries the rules that apply there. Group the fields mentally into four blocks: quota and rollover, request behaviour, accrual, and TOIL. The quota block uses quotaUnit to say whether the quota is measured in days or hours, with daysPerYear and maxRolloverDays as the primary numbers and hoursPerYear and maxRolloverHours as optional hour-based counterparts. hasUnlimitedDays overrides the numeric quota when true. The request-behaviour block covers approval, reason, visibility, past-dated requests, negative balances and the smallest requestable interval. The accrual block describes how leave is earned over time. The TOIL block describes time off in lieu. Optional fields are omitted rather than sent as null, so a missing field means the setting was not configured.

Field groups at a glance

Use this checklist when mapping the response into your own model:

  • Identity: locationId and leaveTypeId pair the policy to its location and leave type.
  • Active flag: isActive is always true here, because only active policies are returned.
  • Quota: quotaUnit, daysPerYear, hoursPerYear, maxRolloverDays, maxRolloverHours, hasUnlimitedDays.
  • Request rules: isApprovalRequired, isReasonRequired, hideLeaveType, allowLeaveInPast, negativeBalanceAllowed, shortestLeaveInterval, negativeBroughtForwardAllowed.
  • Accrual: accrual.type plus optional capRate, firstEarningDate, periodStart, allowAdvanceUsage, pauseWhenUserDeactivated.
  • Rollover expiry: broughtForwardExpiration.enabled plus optional month, day or afterDays.
  • TOIL: toil.enabled plus optional shortestInterval, requestsAllowedForUsers, expiration, expirationDate, expirationMonths.

The exact field names, types and enum values are defined in the protected schema modules and should be copied from there, not retyped.

Worked example: two policies, two shapes

The sample response shows two policies for the same location. The first has a 20-day yearly quota, a 5-day rollover cap, unlimited days off, approval required, and TOIL enabled at a one-hour minimum. The second has hasUnlimitedDays set to true with a zero numeric quota, no approval requirement, a reason required, past-dated leave allowed, a half-day minimum interval, and TOIL disabled. Reading them side by side shows why you should branch on hasUnlimitedDays before using daysPerYear, and why a zero in daysPerYear does not by itself mean no leave is available. The full sample body is in the protected response module.

Telling the error cases apart

A 401 means the key is missing, malformed or unrecognised. A 403 means the key is valid but lacks the required scope or the acting user is not permitted. A 404 means the location ID is wrong or outside the key owner's data reach. A 429 means too many requests arrived in a short window and the call should be retried after a brief wait. A 500 means something failed on the server side; retry later and quote the requestId if it persists. Each error body carries a code, name, description, resolution and requestId, and the exact envelopes are in the protected error modules.

Frequently asked questions

Why is isActive always true in the response?

Because the endpoint only returns active policies. Disabled policies are filtered out before the response is built, so every object you receive is active by definition.

Does the response paginate?

No. All active policies for the location arrive in one response. If you need a single leave type's policy, use the per-leave-type endpoint instead.

What does a missing optional field mean?

Optional fields such as hoursPerYear, capRate or expirationDate are omitted when not set. A missing field means the setting was not configured, not that it is zero or false.

What happens if the location ID is wrong?

The endpoint returns a 404 RESOURCE_NOT_FOUND error. The same error is returned when the location exists but lies outside the key owner's data reach, so check both the ID and the key's visibility.

How do I get the policy for just one leave type?

Use the per-leave-type endpoint for the location and leave type. This list endpoint returns every active policy for the location in one call.

curl -X GET "$API_BASE_URL/v2/locations/string/leave-policies" \
  -H "Authorization: Bearer "
{
  "data": [
    {
      "locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
      "leaveTypeId": "leaveType-fcc1e5c5-ba93-479d-bd58-8f860ba10615",
      "isActive": true,
      "quotaUnit": "days",
      "daysPerYear": 20,
      "maxRolloverDays": 5,
      "hasUnlimitedDays": false,
      "isApprovalRequired": true,
      "isReasonRequired": false,
      "hideLeaveType": false,
      "allowLeaveInPast": false,
      "negativeBalanceAllowed": false,
      "shortestLeaveInterval": "FULL-DAY",
      "negativeBroughtForwardAllowed": false,
      "accrual": {
        "type": "NONE"
      },
      "broughtForwardExpiration": {
        "enabled": false
      },
      "toil": {
        "enabled": true,
        "shortestInterval": "ONE-HOUR",
        "requestsAllowedForUsers": true,
        "expiration": false
      }
    },
    {
      "locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
      "leaveTypeId": "leaveType-88681ca1-4a47-4e4d-bc35-ffff86c0f54e",
      "isActive": true,
      "quotaUnit": "days",
      "daysPerYear": 0,
      "maxRolloverDays": 0,
      "hasUnlimitedDays": true,
      "isApprovalRequired": false,
      "isReasonRequired": true,
      "hideLeaveType": false,
      "allowLeaveInPast": true,
      "negativeBalanceAllowed": false,
      "shortestLeaveInterval": "HALF-DAY",
      "negativeBroughtForwardAllowed": false,
      "accrual": {
        "type": "NONE"
      },
      "broughtForwardExpiration": {
        "enabled": false
      },
      "toil": {
        "enabled": false
      }
    }
  ]
}
{
  "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

FieldTypeRequiredDescriptionConstraints
idstringYesresource ID.

response

FieldTypeRequiredDescriptionConstraints
responseobject
response.dataarray<LeavePolicy>Yes
response.data[]object
response.data[].locationIdstringYesthe ID of the location this policy applies to
response.data[].leaveTypeIdstringYesthe ID of the leave type this policy belongs to
response.data[].isActivebooleanYesalways true, because only active policies are returned
response.data[].quotaUnitstringYesthe unit the quota is set inAllowed values: "days" | "hours"
response.data[].daysPerYearnumberYesthe yearly quota in days
response.data[].hoursPerYearnumberNothe yearly quota in hours
response.data[].maxRolloverDaysnumberYesthe maximum number of unused days that roll over into the next leave year
response.data[].maxRolloverHoursnumberNothe maximum number of unused hours that roll over into the next leave year
response.data[].hasUnlimitedDaysbooleanYeswhether the leave type grants unlimited leave in this location
response.data[].isApprovalRequiredbooleanYeswhether leaves of this type need approval in this location
response.data[].isReasonRequiredbooleanYeswhether a reason is required
response.data[].hideLeaveTypebooleanYeswhether the leave type is hidden from users in this location when they request leave
response.data[].allowLeaveInPastbooleanYeswhether users can request leave for past dates
response.data[].negativeBalanceAllowedbooleanYeswhether a user's balance can go negative
response.data[].shortestLeaveIntervalstringYesthe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
response.data[].negativeBroughtForwardAllowedbooleanYeswhether a negative balance is brought forward into the next leave year
response.data[].accrualobjectYesaccrual settings. Fields that are not set are left out.
response.data[].accrual.typestringYesthe accrual type, for example NONE , WEEKLY or MONTHLY . NONE means the full quota is available at the start of the leave year.
response.data[].accrual.capRatenumberNothe accrual cap rate, from 0.1 to 10
response.data[].accrual.firstEarningDatestringNothe date accrual startsdate
response.data[].accrual.periodStartstringNothe start of the first accrual perioddate
response.data[].accrual.allowAdvanceUsagebooleanYeswhether users can use leave before it is accrued
response.data[].accrual.pauseWhenUserDeactivatedbooleanYeswhether accrual pauses while the user is deactivated
response.data[].broughtForwardExpirationobjectYeswhen rolled-over leave expires. A policy with no expiry of its own follows its location's; enabled true with neither a date nor afterDays means rolled-over leave expires at the end of the leave year.
response.data[].broughtForwardExpiration.enabledbooleanYeswhether rolled-over (brought forward) leave expires
response.data[].broughtForwardExpiration.monthintegerNomonth rolled-over leave expires in, for a fixed expiry date; present only when enabled
response.data[].broughtForwardExpiration.dayintegerNoday of the month rolled-over leave expires on, for a fixed expiry date; present only when enabled
response.data[].broughtForwardExpiration.afterDaysintegerNonumber of days after the leave year starts that rolled-over leave expires, instead of a fixed date; present only when enabled
response.data[].toilobjectYesTOIL settings. Fields that are not set are left out.
response.data[].toil.enabledbooleanYeswhether users can request TOIL (time off in lieu) for this leave type in this location
response.data[].toil.shortestIntervalstringNothe smallest unit of leave a user can requestAllowed values: "FULL-DAY" | "HALF-DAY" | "ONE-HOUR" | "HALF-HOUR" | "FIFTEEN-MINUTES"
response.data[].toil.requestsAllowedForUsersbooleanNowhether users can request TOIL themselves, not only approvers
response.data[].toil.expirationbooleanNowhether earned TOIL expires
response.data[].toil.expirationDatestringNothe date earned TOIL expiresdate
response.data[].toil.expirationMonthsintegerNothe number of months after which earned TOIL expires

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