JSON:API conventions
The media type, the shape of resources, paging, refs, caching and the error format every route shares.
Every JSON answer of the API follows JSON:API. What this page says holds for every route; the API reference has each route's own parameters and schemas.
The media type
JSON goes both ways as application/vnd.api+json, exactly.
- Reading: send an
Acceptheader that allows it, or the answer is 406. - Writing: every request that may change something (any method but
GET,HEADandOPTIONS) must sendContent-Type: application/vnd.api+json, also without a body (aDELETE, a transition). Without it the answer is 415content-type-required, with another type 415unsupported-media-type. The routes that take an upload (multipart/form-data: branding images, files of a revision, imports, translation imports) also need the headerX-Ccms-Requestwith any value; without it the answer is 403request-header-required.
This is what keeps a cross-site form from changing anything. The API sends no CORS headers, so a page on another origin cannot call it from a browser.
Resources
A resource is { type, id, attributes, relationships, meta }:
attributeshold stored data, in camelCase.metaholds what the server derives from it: validation issues, summaries, where a module is used.- JSON:API reserves
idandtype, so a module's own ID and type aremoduleIdandmoduleType.
Lists are paged
Every list is paged, even a short one:
page[number](from 1) andpage[size](default 50, at most 200);meta.pagewithcurrentPage,lastPage,perPageandtotal;linkswithself,first,last,prevandnext: follownextuntil there is none.
Filters are filter[<name>]. A query parameter a route does not support is 400
unsupported-parameter, so a misspelt filter never silently returns everything.
The change feed pages differently, by cursor
(page[cursor] and page[size]), since it reads what happened after a point rather than a fixed
list.
Refs and caching
Every content route reads one version of the content, chosen with ?ref=: a branch, a release tag
or a commit ID. Without it, the server's default applies (CCMS_DEFAULT_REF, normally main). A
token with only content.read may read main and release tags; other refs need
content.read.draft.
X-Ccms-Commitnames the commit an answer was read from. To read a list of several pages consistently, read every page at a release tag, which never moves. A token with onlycontent.readmay read a commit only whilemainor a tag points at it: pages pinned to the commit the first page atmainnamed answer 404not-foundoncemainmoves on, and the read starts again atmain.- By commit ID, an answer never changes and is marked
immutable. - By branch or tag, it is
no-cachewith anETag: send it back asIf-None-Match, and an unchanged answer is a cheap 304. - A withdrawn release's tag stays readable; every answer read at it carries
X-Ccms-Withdrawn: true.
Errors
Errors have the same shape on every route, binary ones and HTML pages included:
{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "…",
"code": "unsupported-parameter",
"source": { "parameter": "filter[langs]" }
}
]
}- Branch on
code, which is stable.detailis text for people and may change. source.parameternames a bad parameter;source.pointera bad part of the body.meta.retryAfter, where an error has it, is the seconds to wait. On a 429 or 503 with aRetry-Afterheader, wait that long before asking again.
Every code is in the error codes reference.