BOLDCMS
Develop

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

PartValueRequiredDefault
Authorization headerBearer <access token>yes
pathname queryThe address on the site, starting with /, such as /blog/my-postno/
locale queryA language code, such as en or csnothe 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.

statusMeansFields to read
okThe address is a page or an entry of a collectioncollection, document, breadcrumbs, alternateLocales, structuredData
redirectThe address movedredirectUrl, redirectPermanent
goneThe address was removed and marked as gone, the meaning of HTTP 410none
notFoundNothing lives at the addressdocument 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":"..."}]}.

HTTPmessageWhen
401Missing or invalid Authorization header. Expected: Bearer <access-token>No Authorization header, or one that does not start with Bearer
401Invalid access tokenThe token belongs to no project
403Origin '<origin>' is not allowed for this projectThe 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.
429Rate limit exceededMore 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.

On this page