Read a page through the delivery API
curl -s "https://cms-production.boldcms.dev/api/routing/resolve?pathname=/about&locale=en" \
-H "Authorization: Bearer $ACCESS_TOKEN"GET /api/routing/resolve takes an address of a site and answers what lives there: a page or
another entry, a redirect, an address that is gone, or nothing. The access token decides which
project is read, so the request never names the project.
The same call from JavaScript, with the fetch built into Node.js 18 and later, browsers and
Cloudflare Workers:
const accessToken = '<your access token>'
const url = new URL('https://cms-production.boldcms.dev/api/routing/resolve')
url.searchParams.set('pathname', '/about')
url.searchParams.set('locale', 'en')
const res = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}` } })
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`)
const route = await res.json()
if (route.status === 'ok') console.log(route.collection, route.document)Request
| Part | Value | Required | Default |
|---|---|---|---|
Authorization header | Bearer <access token> | yes | |
pathname query | The address on the site, starting with /, such as /blog/my-post | no | / |
locale query | A language code, such as en or cs | no | the project's default language |
Response
A resolved request answers HTTP 200 with a JSON object. Read status, not the HTTP status: an
address with no page is also a 200.
status | Means | Fields to read |
|---|---|---|
ok | The address is a page or an entry of a collection | collection, document, breadcrumbs, alternateLocales, structuredData |
redirect | The address moved | redirectUrl, redirectPermanent |
gone | The address was removed and marked as gone, the meaning of HTTP 410 | none |
notFound | Nothing lives at the address | document and collection, only when the project has its own not found page |
Every answer also carries pathname, locale, projectSlug (the project the token belongs to)
and localeConfig: the project's languages, its default language and how languages appear in
addresses. Use localeConfig for a language switcher and alternateLocales for the translations
of the one document.
For a page (collection is pages), its sections are document.layout, in the order the page
shows them. Each section names its block in blockType.
Errors
Errors answer {"errors":[{"message":"..."}]}.
| HTTP | message | When |
|---|---|---|
401 | Missing or invalid Authorization header. Expected: Bearer <access-token> | No Authorization header, or one that does not start with Bearer |
401 | Invalid access token | The token belongs to no project |
403 | Origin '<origin>' is not allowed for this project | The project lists the origins it allows, and the request's Origin header is not one of them. localhost and 127.0.0.1 are always allowed. |
429 | Rate limit exceeded | More than 100 requests in one second with one token. Wait for the seconds in the Retry-After header. |
Reference
The full list of fields in document depends on the collection. A reference of every endpoint and
field, generated from the API's OpenAPI document, will be added to this section.