Skip to content
For developers

Example: the API of one site

On this page

A worked example of the content API: every route, parameter and response of a site with 4 public collections (author, page, post, tag), 2 globals (navigation, siteSettings) and a website search. This page is generated from an OpenAPI document when the website is built, so it is exactly what tinyzoo openapi writes for that site. What every site shares (routes, preview, caching, errors) is in the content API reference.

A site gets its own

The collections, fields and filters below belong to this example site. Yours come from your cms.config.ts, and you get the same reference for them in four ways:

  • /api/openapi.json on your site: the OpenAPI 3.1 document, always on (behind the content token when you set one).
  • /api/openapi: the same document as an interactive reference (Scalar), in development, or in production with cms.content.docs: true.
  • tinyzoo openapi: writes the document to a file (openapi.json), for a code generator or a CI step. Without a running site.
  • The typed client: tinyzoo client writes cms-content.ts with the types of every collection below, and @tinyzoo/client fetches them (the typed client).

Every route

MethodPathWhat it returns
GET/api/content/authorList author items
GET/api/content/author/{slug}Get one author by id
GET/api/content/pageList page items
GET/api/content/page/{slug}Get one page by its address (the chain of address parts, o-nas/tym) or id
GET/api/content/postList post items
GET/api/content/post/{slug}Get one post by slug (falling back to id)
GET/api/content/tagList tag items
GET/api/content/tag/{slug}Get one tag by id
GET/api/content/_tree/pageThe page tree, for navigation
GET/api/content/_global/navigationGet the navigation global
GET/api/content/_global/siteSettingsGet the siteSettings global
GET/api/content/_searchSearch the website

Shapes every collection shares

Every item has an id, createdAt and updatedAt; a collection that is translated adds locale, locales and, when its items have addresses, paths. Files and rich text look the same everywhere:

A file

FieldTypeNotes
iduuid string—
urluri string—
widthintegermay be null
heightintegermay be null
altstringmay be null
mimestring—
focal{ x: integer, y: integer }may be null
JSON
{
  "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
  "url": "https://cms.example.com/media/tulips.jpg",
  "width": 1600,
  "height": 1066,
  "alt": "A bunch of tulips on a table",
  "mime": "image/jpeg",
  "focal": { "x": 50, "y": 40 }
}

A gallery is a list of files, each with a caption (string, or null). A relation to another public collection arrives as the nested item (written Author (nested) below) with its plain fields only: no relations, files, galleries, groups, lists or blocks of its own. One to a collection that is not public arrives as { id, title }.

Rich text

Stored as a ProseMirror document: render it with <CmsContent :doc="item.body" /> and never as HTML. A node has a type, and optionally text, content, marks and attrs.

JSON
{
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "content": [{ "type": "text", "text": "The text, one paragraph." }]
    }
  ]
}

A list

Every list answers with its items, the total number of matches, and the page asked for:

JSON
{ "items": ["…"], "total": 1, "page": 1, "limit": 20 }

Author

author is a public collection; Author is the shape of one item.

List author items

GET /api/content/author

ParameterInTypeWhat it does
pagequeryintegerMin 1, default 1.
limitqueryintegerMin 1, max 100, default 20.
sortquery"createdAt" | "updatedAt" | "name" | "position"Default "createdAt".
dirquery"asc" | "desc"Default "desc".
qquerystringSubstring match against name.

Filters, each one a query parameter named after the field. Exact match: name.

StatusMeaning
200OK

Example response, /api/content/author?limit=1:

JSON
{
  "items": [
    {
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "name": "Ada Lovelace",
      "position": 1,
      "bio": {
        "type": "doc",
        "content": [
          {
            "type": "paragraph",
            "content": [{ "type": "text", "text": "The text, one paragraph." }]
          }
        ]
      },
      "createdAt": "2026-03-14T09:30:00.000Z",
      "updatedAt": "2026-03-14T09:30:00.000Z"
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 1
}

Get one author

GET /api/content/author/{slug}. Get one author by id.

ParameterInTypeWhat it does
slugpathstringRequired.
StatusMeaning
200OK
404Not found or not published

The answer is { "item": { … } }, the item shaped exactly as in the list above.

The author fields

FieldTypeNotes
iduuid string—
namestring—
positionintegermay be null
bioRichTextDocmay be null
createdAtdate-time string—
updatedAtdate-time string—

Page

page is a public collection; Page is the shape of one item.

List page items

GET /api/content/page. Returns only published items.

ParameterInTypeWhat it does
pagequeryintegerMin 1, default 1.
limitqueryintegerMin 1, max 100, default 20.
sortquerystring8 values: createdAt, updatedAt, title, slug, status, … Default "createdAt".
dirquery"asc" | "desc"Default "desc".
qquerystringSubstring match against title.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".

Filters, each one a query parameter named after the field. Exact match: title, slug, status, parent, metaTitle, metaDescription.

StatusMeaning
200OK

Example response, /api/content/page?limit=1&locale=en:

JSON
{
  "items": [
    {
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "title": "About us",
      "slug": "about-us",
      "status": "published",
      "sections": [
        {
          "id": "b7e4a1",
          "type": "hero",
          "heading": "Example heading",
          "lead": "Example lead",
          "image": {
            "id": "3d9e5b70-1c2a-48f6-b0e7-5a4c9d13e862",
            "url": "https://cms.example.com/media/tulips.jpg",
            "width": 1600,
            "height": 1066,
            "alt": "A bunch of tulips on a table",
            "mime": "image/jpeg",
            "focal": { "x": 50, "y": 40 }
          },
          "buttonLabel": "Example button label",
          "buttonUrl": "Example button url"
        }
      ],
      "parent": null,
      "position": 1,
      "metaTitle": "About us — Example",
      "metaDescription": "A short description for search engines.",
      "ogImage": {
        "id": "c41b8e92-7f05-4d3a-a6c8-12e9b05f7d3c",
        "url": "https://cms.example.com/media/tulips.jpg",
        "width": 1600,
        "height": 1066,
        "alt": "A bunch of tulips on a table",
        "mime": "image/jpeg",
        "focal": { "x": 50, "y": 40 }
      },
      "createdAt": "2026-03-14T09:30:00.000Z",
      "updatedAt": "2026-03-14T09:30:00.000Z",
      "locale": "cs",
      "locales": ["cs", "en"],
      "paths": { "cs": "/blog/ahoj-svete", "en": "/en/blog/hello-world" },
      "path": "/blog/hello-world",
      "breadcrumbs": [{ "title": "About us", "path": "/blog/hello-world" }]
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 1
}

Get one page

GET /api/content/page/{slug}. Get one page by its address (the chain of address parts, o-nas/tym) or id. The key is the chain of address parts from the top of the tree down, as one path segment with the slashes escaped (o-nas%2Ftym), looked up in the language asked for and then in the default one. A page under an unpublished page is not found.

ParameterInTypeWhat it does
slugpathstringRequired.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".
StatusMeaning
200OK
404Not found or not published

The answer is { "item": { … } }, the item shaped exactly as in the list above.

The page fields

FieldTypeNotes
iduuid string—
titlestring—
slugstringpattern ^[a-z0-9]+(?:-[a-z0-9]+)*$
status"draft" | "published"—
sections(object | object | object | object | object | object)[]—
parentstringmay be null
positioninteger—
metaTitlestringmay be null
metaDescriptionstringmay be null
ogImageCmsMediamay be null
createdAtdate-time string—
updatedAtdate-time string—
locale"cs" | "en"The language this item is served in.
locales("cs" | "en")[]Languages this item exists in.
pathsobjectThe item's address in each language it exists in.
pathstringmay be null. The page's address in the language served: its ancestors' address parts and its own (/o-nas/tym), language prefix included.
breadcrumbs{ title: string, path: string }[]From the top of the tree down to this page (the page itself last): title and address of each, in the language served. Only live pages.

The page tree

GET /api/content/_tree/page. Live pages only, top level first, each level in the order editors arranged it. A page under an unpublished page is left out with everything below it.

ParameterInTypeWhat it does
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".
JSON
{
  "items": [
    {
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "title": "About us",
      "path": "/o-nas",
      "children": [
        {
          "id": "3d9e5b70-1c2a-48f6-b0e7-5a4c9d13e862",
          "title": "The team",
          "path": "/o-nas/tym",
          "children": []
        }
      ]
    }
  ]
}

Post

post is a public collection; Post is the shape of one item.

List post items

GET /api/content/post. Returns only published items.

ParameterInTypeWhat it does
pagequeryintegerMin 1, default 1.
limitqueryintegerMin 1, max 100, default 20.
sortquerystring8 values: createdAt, updatedAt, title, slug, status, … Default "createdAt".
dirquery"asc" | "desc"Default "desc".
qquerystringSubstring match against title.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".

Filters, each one a query parameter named after the field. Exact match: title, slug, status, author, metaTitle, metaDescription. Date ranges: publishedAt.from, publishedAt.to.

StatusMeaning
200OK

Example response, /api/content/post?limit=1&locale=en:

JSON
{
  "items": [
    {
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "title": "Hello, world",
      "slug": "hello-world",
      "status": "published",
      "publishedAt": "2026-03-14T09:30:00.000Z",
      "hero": {
        "id": "3d9e5b70-1c2a-48f6-b0e7-5a4c9d13e862",
        "url": "https://cms.example.com/media/tulips.jpg",
        "width": 1600,
        "height": 1066,
        "alt": "A bunch of tulips on a table",
        "mime": "image/jpeg",
        "focal": { "x": 50, "y": 40 }
      },
      "author": {
        "id": "c41b8e92-7f05-4d3a-a6c8-12e9b05f7d3c",
        "name": "Ada Lovelace",
        "position": 1,
        "bio": {
          "type": "doc",
          "content": [
            {
              "type": "paragraph",
              "content": [{ "type": "text", "text": "The text, one paragraph." }]
            }
          ]
        }
      },
      "tags": [
        {
          "id": "5e0a7d34-9b18-4c6f-8d21-f3a6b94c0e57",
          "name": "Tutorials",
          "slug": "tutorials"
        }
      ],
      "body": {
        "type": "doc",
        "content": [
          {
            "type": "paragraph",
            "content": [{ "type": "text", "text": "The text, one paragraph." }]
          }
        ]
      },
      "location": { "place": "Example place", "note": "Example note" },
      "gallery": [
        {
          "id": "a7c3f185-2e64-4b90-93d7-6b1e08a4c2f9",
          "url": "https://cms.example.com/media/tulips.jpg",
          "width": 1600,
          "height": 1066,
          "alt": "A bunch of tulips on a table",
          "mime": "image/jpeg",
          "focal": { "x": 50, "y": 40 },
          "caption": "Spring at the market"
        }
      ],
      "metaTitle": "Hello, world — Example",
      "metaDescription": "A short description for search engines.",
      "ogImage": {
        "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
        "url": "https://cms.example.com/media/tulips.jpg",
        "width": 1600,
        "height": 1066,
        "alt": "A bunch of tulips on a table",
        "mime": "image/jpeg",
        "focal": { "x": 50, "y": 40 }
      },
      "createdAt": "2026-03-14T09:30:00.000Z",
      "updatedAt": "2026-03-14T09:30:00.000Z",
      "locale": "cs",
      "locales": ["cs", "en"],
      "paths": { "cs": "/blog/ahoj-svete", "en": "/en/blog/hello-world" }
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 1
}

Get one post

GET /api/content/post/{slug}. Get one post by slug (falling back to id).

ParameterInTypeWhat it does
slugpathstringRequired.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".
StatusMeaning
200OK
404Not found or not published

The answer is { "item": { … } }, the item shaped exactly as in the list above.

The post fields

FieldTypeNotes
iduuid string—
titlestring—
slugstringpattern ^[a-z0-9]+(?:-[a-z0-9]+)*$
status"draft" | "published"—
publishedAtdate-time stringmay be null
heroCmsMediamay be null
authorAuthor (nested)—
tagsTag (nested)[]—
bodyRichTextDoc—
location{ place: string, note: string }may be null
galleryCmsGalleryItem[]—
metaTitlestringmay be null
metaDescriptionstringmay be null
ogImageCmsMediamay be null
createdAtdate-time string—
updatedAtdate-time string—
locale"cs" | "en"The language this item is served in.
locales("cs" | "en")[]Languages this item exists in.
pathsobjectThe item's address in each language it exists in.

Tag

tag is a public collection; Tag is the shape of one item.

List tag items

GET /api/content/tag

ParameterInTypeWhat it does
pagequeryintegerMin 1, default 1.
limitqueryintegerMin 1, max 100, default 20.
sortquery"createdAt" | "updatedAt" | "name" | "slug"Default "createdAt".
dirquery"asc" | "desc"Default "desc".
qquerystringSubstring match against name.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".

Filters, each one a query parameter named after the field. Exact match: name, slug.

StatusMeaning
200OK

Example response, /api/content/tag?limit=1&locale=en:

JSON
{
  "items": [
    {
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "name": "Tutorials",
      "slug": "tutorials",
      "createdAt": "2026-03-14T09:30:00.000Z",
      "updatedAt": "2026-03-14T09:30:00.000Z",
      "locale": "cs",
      "locales": ["cs", "en"]
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 1
}

Get one tag

GET /api/content/tag/{slug}. Get one tag by id.

ParameterInTypeWhat it does
slugpathstringRequired.
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".
StatusMeaning
200OK
404Not found or not published

The answer is { "item": { … } }, the item shaped exactly as in the list above.

The tag fields

FieldTypeNotes
iduuid string—
namestring—
slugstringpattern ^[a-z0-9]+(?:-[a-z0-9]+)*$
createdAtdate-time string—
updatedAtdate-time string—
locale"cs" | "en"The language this item is served in.
locales("cs" | "en")[]Languages this item exists in.

Globals

A global is one object a site has once (its settings, its navigation). item is null until someone first saves it.

The navigation global

GET /api/content/_global/navigation

ParameterInTypeWhat it does
localequery"cs" | "en"Language to serve. Untranslated fields fall back to the default language. Default "cs".
FieldTypeNotes
iduuid string—
mainobject[]—
footerobject[]—
createdAtdate-time string—
updatedAtdate-time string—
locale"cs" | "en"The language this item is served in.
locales("cs" | "en")[]Languages this item exists in.

Example response:

JSON
{
  "item": {
    "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
    "main": [
      {
        "id": "b7e4a1",
        "type": "link",
        "label": "Contact",
        "url": "https://example.com",
        "newTab": true,
        "sub": true
      }
    ],
    "footer": [
      {
        "id": "b7e4a1",
        "type": "link",
        "label": "Contact",
        "url": "https://example.com",
        "newTab": true,
        "sub": true
      }
    ],
    "createdAt": "2026-03-14T09:30:00.000Z",
    "updatedAt": "2026-03-14T09:30:00.000Z",
    "locale": "cs",
    "locales": ["cs", "en"]
  }
}

The siteSettings global

GET /api/content/_global/siteSettings

FieldTypeNotes
iduuid string—
siteNamestring—
taglinestringmay be null
logoCmsMediamay be null
brandColorstringmay be null
openingHoursobject[]—
rulesCmsMediamay be null
contactobjectmay be null
metaTitlestringmay be null
metaDescriptionstringmay be null
ogImageCmsMediamay be null
createdAtdate-time string—
updatedAtdate-time string—

Example response:

JSON
{
  "item": {
    "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
    "siteName": "Example site name",
    "tagline": "Example tagline",
    "logo": {
      "id": "3d9e5b70-1c2a-48f6-b0e7-5a4c9d13e862",
      "url": "https://cms.example.com/media/tulips.jpg",
      "width": 1600,
      "height": 1066,
      "alt": "A bunch of tulips on a table",
      "mime": "image/jpeg",
      "focal": { "x": 50, "y": 40 }
    },
    "brandColor": "Example brand color",
    "openingHours": [
      {
        "id": "b7e4a1",
        "type": "item",
        "days": "Example days",
        "hours": "Example hours"
      }
    ],
    "rules": {
      "id": "c41b8e92-7f05-4d3a-a6c8-12e9b05f7d3c",
      "url": "https://cms.example.com/media/tulips.jpg",
      "width": 1600,
      "height": 1066,
      "alt": "A bunch of tulips on a table",
      "mime": "image/jpeg",
      "focal": { "x": 50, "y": 40 }
    },
    "contact": {
      "phone": "Example phone",
      "email": "ada@example.com",
      "address": { "street": "Joštova 10", "city": "Brno", "zip": "Example zip" },
      "photo": {
        "id": "5e0a7d34-9b18-4c6f-8d21-f3a6b94c0e57",
        "url": "https://cms.example.com/media/tulips.jpg",
        "width": 1600,
        "height": 1066,
        "alt": "A bunch of tulips on a table",
        "mime": "image/jpeg",
        "focal": { "x": 50, "y": 40 }
      }
    },
    "metaTitle": "Hello, world — Example",
    "metaDescription": "A short description for search engines.",
    "ogImage": {
      "id": "a7c3f185-2e64-4b90-93d7-6b1e08a4c2f9",
      "url": "https://cms.example.com/media/tulips.jpg",
      "width": 1600,
      "height": 1066,
      "alt": "A bunch of tulips on a table",
      "mime": "image/jpeg",
      "focal": { "x": 50, "y": 40 }
    },
    "createdAt": "2026-03-14T09:30:00.000Z",
    "updatedAt": "2026-03-14T09:30:00.000Z"
  }
}

GET /api/content/_search. Published entries of page, post, best matches first. Every word must appear (in any order, accents and case ignored); fewer than two letters return nothing.

ParameterInTypeWhat it does
qquerystringRequired. max 100 characters.
limitqueryintegerMin 1, max 50, default 10.
entityquerystringOnly these collections (comma-separated)
localequery"cs" | "en"Language to search in: only entries translated into it.
StatusMeaning
200OK
429Too many searches from this visitor
FieldTypeNotes
entity"page" | "post"—
iduuid string—
titlestring—
titleHighlightsinteger[][][start, end) character ranges of the words found
excerptstringText around the first word found; empty when only the title matched
highlightsinteger[][][start, end) character ranges of the words found
pathstringmay be null. The entry's address on the website, in the searched language
localestringmay be null
updatedAtdate-time string—

Example response, /api/content/_search?q=hello:

JSON
{
  "query": "hello",
  "items": [
    {
      "entity": "post",
      "id": "8f2a6c1e-4b7d-4e19-9a53-0c6d2f81b7a4",
      "title": "Hello, world",
      "titleHighlights": [[0, 5]],
      "excerpt": "The first post.",
      "highlights": [[0, 5]],
      "path": "/blog/hello-world",
      "locale": "en",
      "updatedAt": "2026-03-14T09:30:00.000Z"
    }
  ],
  "total": 1
}

Where this comes from

The document is test/contracts/openapi.playground.json, which the tests keep equal to what buildOpenApiDocument writes for the playground's cms.config.ts. The website's build turns it into this page.

Didn’t find what you need?

Write to us. We’re happy to help, and we’ll add it to the guide.

Get in touch

This page’s source on GitHub