Skip to main content

Get a CMS item by slug

Fetch one published document from a CMS collection when the app already knows its slug. The response is the document itself, not a paginated list.

Request​

GET /v1/public/cms/collections/:collection/items/:slug

Use getCmsDocument() when the collection and slug are dynamic. For a legal page, getLegalPage() provides the collection name for you. A signed-out request to an open collection needs the tenant code and allowSignedOut: true:

const document = await client.getLegalPage('terms-and-conditions', {
tenantCode,
environment: 'staging',
locale: 'de-DE',
allowSignedOut: true,
});

renderLegalPage(document);

Use the tenant code and environment that match the project. For another collection, call client.getCmsDocument(collection, slug, options). The SDK encodes the path segments and maps the locale to a CMS locale.

Response and fallback​

The response contains the collection's document fields. A legal-pages document includes fields such as slug, localized title and body, effectiveAt, and status. Rich-text body content is JSON from the CMS editor; it is not HTML.

The CMS first looks for a published document with that slug in the named tenant. If none exists, it tries the shared tenant. If neither has the item, the route returns 404. There is no lookup by document ID.

A missing, draft, or malformed slug returns 404, so do not treat that status as proof that the document was deleted. Publishing the legal-pages item with slug terms-and-conditions can cause project users to be asked to accept the terms again at their next sign-in. Review that behavior before publishing changes to this specific item.