API
Client SDK
createClient from @interactive-inc/cms/client wraps the REST API.
Collections are named by slug at run time, since their definitions live in the database. Pass a data type to collection<T>() to type a known collection's data; it is not checked at run time.
import { ClientError, createClient } from "@interactive-inc/cms/client"
const cms = createClient({
baseUrl: "https://<host>/api",
headers: { authorization: "Bearer cms_..." },
})
type Post = { title: string; slug: string; body: string }
const page = await cms.collection<Post>("posts").list({ filter: { "title.contains": "hello" }, sort: "-publishedAt" })
const created = await cms.collection<Post>("posts").create({ title: "Hello" })
await cms.collection("posts").requestReview(created.id)
const site = await cms.public.global("site")
const resolved = await cms.public.page("/blog/hello")Surface
collection(slug):list,get,create,update,replace,patch,remove,publish,unpublish,requestReview,withdrawReview,schedulePublish,scheduledPublish,cancelScheduledPublish,revisions,restore,translations,translate,tagsglobal(slug):get,updatepublic:collection(slug),global,search,pageproposals:list,get,create,approve,rejectmedia:list,upload,removeapiKeys:list,create,revokecollections(),search,reindex,previewPage,activity
A non-2xx response throws ClientError with the envelope's code, message, status, and details.