Skip to content

Get a Location by ID

The Get a Location endpoint returns one location record from the REST API v2. Use it when you already know the location's resource ID and need its name, timezone, default status or creation timestamp. The request requires the locations:read scope.

Request contract

The endpoint uses the GET method and the path /v2/locations/{id}. The only path parameter is id, a required string that identifies the location. Authentication uses a bearer token in the Authorization header, sent as Authorization: Bearer vt_live_<secret>. The key must carry the locations:read scope, and the key owner's role limits which locations the key can reach. The exact request shape and generated client examples are provided in the protected code and SDK modules that accompany this page.

Response fields

A successful 200 response wraps a data object. The following field map explains what each property means and whether it is always present.

Field map

The table below maps each response property to its type, requiredness and meaning. The id, name, isDefault and createdAt fields are required; timezone is optional and is omitted when no timezone is stored.

Error handling

Errors use a consistent envelope with code, name, description, resolution and requestId. The 404 RESOURCE_NOT_FOUND response means the location does not exist or is outside the key's data reach. A 401 response indicates a missing, malformed or unrecognized API key. A 403 response can indicate a missing scope or that the acting user may not perform the action. A 429 response means too many requests were sent in a short time; wait and retry. A 500 response indicates an internal error; retry later and quote the requestId if the problem persists.

Decision checklist

Before calling this endpoint, confirm the following:

Worked example

The captured 200 response shows a location named Los Angeles with the timezone America/Los_Angeles, isDefault set to false, and a createdAt timestamp in ISO 8601 format. The id is a UUID-style string. If you need to confirm that this location is the company default, read the isDefault boolean rather than inferring it from the name.

Location response field map
FieldTypeRequiredMeaning
idstringYeslocation ID
namestringYeslocation name
timezonestringNothe location's IANA time zone, left out when none is stored
isDefaultbooleanYeswhether this is the company's default location
createdAtstring (date-time)Yesa timestamp in the ISO 8601 format

Field types and requiredness reflect the supplied contract schema. The timezone field may be absent.

Error response map
StatusCodeMeaningResolution
401UNAUTHORIZEDThe API key is missing, malformed or not recognized.Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.
403INSUFFICIENT_SCOPEThe API key does not have the scopes this request needs.Add the scopes listed in details.requiredScopes to the key in the dashboard.
404RESOURCE_NOT_FOUNDThe requested resource does not exist or is outside the data this key can access.Check the ID of the resource named in details.resource and that the key owner can see it.
429RATE_LIMITEDToo many requests were sent in a short time.Wait a few seconds and retry, using the same Idempotency-Key for writes.
500INTERNAL_ERRORSomething went wrong on our side.Retry later, and if it keeps happening, contact support and quote the requestId.

The 403 example in the supplied contract shows a requiredScopes array containing leaves:write; the actual required scope for this endpoint is locations:read.

Frequently asked questions

What authentication does the Get a Location endpoint require?

Send an API key as a bearer token in the Authorization header. The key must include the locations:read scope. The key owner's role also limits which locations the key can reach.

Why does a request return 404 RESOURCE_NOT_FOUND?

The location ID may not exist, or the location may be outside the data reach of the API key. Check the ID and confirm that the key owner can see the location.

Is the timezone field always returned?

No. The timezone field is optional and is left out when no IANA time zone is stored for the location.

How do I create or update a location instead?

Use the Create a location or Update a location endpoints. Both require the locations:write scope and may return 202 Accepted with an operation to poll if the write takes longer than the wait window.

curl -X GET "$API_BASE_URL/v2/locations/string" \
  -H "Authorization: Bearer "
{
  "data": {
    "id": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
    "name": "Los Angeles",
    "timezone": "America/Los_Angeles",
    "isDefault": false,
    "createdAt": "2022-08-22T15:00:00.000Z"
  }
}
{
  "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.dataobjectYes
response.data.idstringYeslocation ID
response.data.namestringYeslocation name
response.data.timezonestringNothe location's IANA time zone, left out when none is stored
response.data.isDefaultbooleanYeswhether this is the company's default location
response.data.createdAtstringYesa timestamp in the ISO 8601 formatFormat: date-time

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