⚠️ Work in progress — createCMS is pre-1.0 and not production-ready (not tested in production). Expect breaking changes.
createCMS
Reference

Templates

Per-property default values, via cms.api.templates.

A template is a default value for a block property in a given collection and block type. Template strings can contain {{key}} variables, resolved when applied. Templates are keyed by (collection, blockType, propertyKey). Methods live under cms.api.templates and mirror on the client as client.templates.<method> with identical types.

Templates are not versioned content, so these methods do not return a commit envelope. A template can only target a text property (string or richText); pointing one at any other property type throws TEMPLATE_PROPERTY_INVALID.

Methods

List Templates

List every template, ordered by collection then block type, so you can see which block properties already have defaults. Narrow the results by collection, block type, or a case-insensitive substring of the template string, and page through with limit/offset. Every filter is optional.

template:read
GET/templates/list
const { data, error } = await client.templates.list({
  query: { collection: 'pages', blockType: 'hero', limit: 20 },
});
Parameters
collectionstring

Filter by collection name.

blockTypestring

Filter by block type.

searchstring

Case-insensitive substring match on the template string.

limitnumber= 50

Page size.

offsetnumber= 0

Rows to skip.

Returns
templatesTemplate[]

The matching template records on this page. Each has `id`, `collection`, `blockType`, `propertyKey`, `template`, `description`, and timestamps.

totalnumber

Total templates matching the filters, ignoring `limit`/`offset`.

hasMoreboolean

Whether more templates exist after this page.

Get a Template

Fetch a single template by id, so you can inspect its string, description, and which property it targets. Throws TEMPLATE_NOT_FOUND if no template with that id exists.

template:read
GET/templates/getTemplate
const { data, error } = await client.templates.getTemplate({
  query: { templateId: 'tpl_abc123' }, // required
});
Parameters
templateIdstringrequired

The template id.

Returns
templateTemplate

The template record: `{ id, collection, blockType, propertyKey, template, description, ... }`.

Get Resolved Defaults

Resolve the default values for every template on a collection and block type, with {{key}} variables already substituted, so you can seed a new block's properties. You get back a defaults map from propertyKey to its resolved string; it is empty when the pair has no templates.

template:read
GET/templates/getTemplateDefaults
const { data, error } = await client.templates.getTemplateDefaults({
  query: { collection: 'pages', blockType: 'hero' }, // both required
});
Parameters
collectionstringrequired

The collection name.

blockTypestringrequired

The block type.

Returns
defaultsRecord<string, string>

Maps each `propertyKey` to its resolved template string. Empty when the collection/block-type pair has no templates.

Resolve a Template String

Resolve an arbitrary template string against your current variables, substituting {{key}} placeholders with their stored values. Unknown placeholders are left literal, so you can preview exactly what a template will render to.

template:read
GET/templates/resolveTemplate
const { data, error } = await client.templates.resolveTemplate({
  query: { template: 'Welcome to {{siteName}}' }, // required
});
Parameters
templatestringrequired

The template string to resolve.

Returns
resolvedstring

The template string with every known `{{key}}` replaced by its value; unresolved placeholders remain as-is.

Create a Template

Create a template for a (collection, blockType, propertyKey) triple; you get back the new record, and its {{key}} variable usages are tracked for you. The target property must be a string or richText property — pointing at any other type throws TEMPLATE_PROPERTY_INVALID — and a duplicate triple throws TEMPLATE_KEY_EXISTS.

template:create
POST/templates/createTemplate
const { data, error } = await client.templates.createTemplate({
  body: {
    collection: 'pages', // required
    blockType: 'hero', // required
    propertyKey: 'title', // required
    template: 'Welcome to {{siteName}}', // required
  },
});
Parameters
collectionstringrequired

The collection name.

blockTypestringrequired

The block type.

propertyKeystringrequired

The property key this template applies to.

templatestringrequired

The template string, may include `{{key}}` variable placeholders.

descriptionstring

Optional description.

Returns
templateTemplate

The created template record, including its generated `id`.

Update a Template

Update a template's string and/or description; omitted fields keep their current value, and changing the string re-syncs its tracked variable usages. Throws TEMPLATE_NOT_FOUND if the template does not exist.

template:update
POST/templates/updateTemplate
const { data, error } = await client.templates.updateTemplate({
  body: {
    templateId: 'tpl_abc123', // required
    template: 'Updated {{siteName}} content',
  },
});
Parameters
templateIdstringrequired

The template id.

templatestring

New template string. Omit to keep the current value.

descriptionstring

New description. Omit to keep the current value.

Returns
templateTemplate

The updated template record.

Delete a Template

Delete a template by id. You get back the id you deleted; throws TEMPLATE_NOT_FOUND if it does not exist.

template:delete
POST/templates/deleteTemplate
const { data, error } = await client.templates.deleteTemplate({
  body: { templateId: 'tpl_abc123' }, // required
});
Parameters
templateIdstringrequired

The template id.

Returns
templateIdstring

The id of the deleted template.

On this page