Create collection
create_collectionStand up a new collection on an existing site in one call: append a collections[] entry (with contentType, pathPrefix, template, and optional items[]), optionally create the index page that hosts the matching <collection-list>, and seed initial items into the content_items table. After this call:
/{path_prefix}/{slug}resolves each item via Mustache substitutionthe index page's
<collection-list>iterates the seeded itemsadd_content_item/edit_content_item/delete_content_itemmanage rows afterward.
Use this when the user asks 'add a blog to my site', 'set up case studies', 'add a careers section', etc. Schemas are per-site — pick a contentType slug that's unique within the site (call list_content_types to see what's already declared) and ship the fields[] schema inline. Writes a new draft version; call publish to push live.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | No | Initial items to seed into content_items. Each row's content must satisfy the collection's `fields` (required fields populated, declared types matched). The index page's <collection-list> will iterate these. | |
| fields | Yes | Per-item field schema. Each field becomes a form input AND a write-time validation rule. Include every field the `template` references (placeholders like {{title}}, {{body}}, {{image.url}} map to field keys). The schema is per-site and per-collection — there is no global catalog. | |
| enabled | No | Defaults to true. Set false to ship the collection definition (template + items) without serving detail URLs or rendering index iteration. | |
| site_id | Yes | ||
| template | Yes | Per-item template Node tree with {{field}} placeholders. The template is rendered for each detail URL with the row's content substituted in. See the canonical examples in lib/fixtures/templates/lanyard.json, prive.json, axel.json for the shape. | |
| index_page | No | Optional index page to create at the same time. If the site already has an index page at the prefix (e.g. /blog), omit this and patch its tree separately. | |
| path_prefix | Yes | URL prefix for detail pages. Single segment, kebab-case, with leading and trailing slashes. Examples: '/blog/', '/projects/', '/searches/', '/case-studies/'. | |
| content_type | Yes | The collection's per-site identifier (its content_type slug). Lowercase kebab-case. Each site owns its catalog — pick whatever name fits the brief (project, blog, recipe, episode, gift, …). |