Skip to content

Get a location's work week

This endpoint reports which days of the week a location treats as working days and, where the location overrides the default, how many hours are worked on a given day. It is a read-only call: you supply a location identifier, the request returns the schedule, and nothing is modified.

Request shape

The call is a GET to the location work-week route under the v2 locations namespace, with the location's identifier in the path. The identifier is a required string. The request needs the locations:read scope and a bearer token in the Authorization header. The complete request contract, including the exact path, header format and token prefix, is delivered in the accompanying protected modules (code0001 and schema0001/schema0002); treat those as the authoritative specification rather than any paraphrase here.

Reading the response

A successful response wraps a data object with two members. days is required: an array of integers from 0 to 6, where 0 is Sunday and 6 is Saturday, listing the working days of the week with each day appearing at most once. workHours is optional: an array of objects, each with a day (0-6) and an hours number, holding at most one entry per day. Days that do not appear in workHours use the location's default work hours. The exact schema, including the item limits and the note that out-of-range hour values fail validation, is in the protected module schema0003.

Worked example

The captured sample response shows days set to 1 through 5 (Monday through Friday) and a single workHours entry of day 5 with hours 4. Read together, that means the location works Monday to Friday, and Friday specifically is a four-hour day while the other four working days fall back to the default hours. The full sample payload is in protected module code0002. This illustrates the fallback rule: absence of a day from workHours is not the same as zero hours.

When the call fails

The documented failure for this endpoint is 404 RESOURCE_NOT_FOUND. That single status covers three distinct situations: the location does not exist, the location sits outside the data reach of the key being used, or the location exists but has no stored work week yet. Because the status is shared, a 404 alone does not tell you which cause applies. Other error responses follow the standard error envelope (protected modules schema0004 through schema0008 and code0003, code0005, code0006), with a stable code, a short name, a description, a resolution hint and a requestId to quote when escalating.

Triage checklist for a 404

  1. Confirm the identifier you sent matches a location the key owner can see. 2. If the key is scoped narrowly, check whether the location is inside that key's data reach. 3. If the ID is valid and visible, treat the 404 as a signal that no work week has been stored for that location yet, rather than as a missing location. 4. If you need to establish a schedule, use the replace work-week operation (locations:write) and then re-read.

Frequently asked questions

Which scope does the work-week read require?

locations:read. The key is sent as a bearer token in the Authorization header.

Why is workHours missing from some responses?

workHours is optional and is omitted when no day has custom hours. When present, it lists only days that differ from the default; days without an entry use the location's default hours.

What does a 404 on this endpoint mean?

It can mean the location does not exist, is outside the key's data reach, or has no stored work week yet. The status alone does not distinguish these, so verify the ID and key visibility before concluding the location is missing.

How are days numbered?

0 is Sunday and 6 is Saturday. Each day may appear at most once in days and at most once in workHours.

curl -X GET "$API_BASE_URL/v2/locations/string/work-week" \
  -H "Authorization: Bearer "
{
  "data": {
    "days": [
      1,
      2,
      3,
      4,
      5
    ],
    "workHours": [
      {
        "day": 5,
        "hours": 4
      }
    ]
  }
}
{
  "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
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