---
title: "Create collection (preset: blog|directory, or manual fields). Manual `fields` must include the `slugField` id as a text field with `required: true`. Optional attachDynamicPage adds a dynamic list/detail route with the home page navbar/footer auto-copied."
method: POST
path: "/api/v1/sites/{subdomain}/collections"
tags: ["collections"]
---

# Create collection (preset: blog|directory, or manual fields). Manual \`fields\` must include the \`slugField\` id as a text field with \`required: true\`. Optional attachDynamicPage adds a dynamic list/detail route with the home page navbar/footer auto-copied.

`POST /api/v1/sites/{subdomain}/collections`

## Request

- Base URL: `https://slatehut.com`
- URL: `https://slatehut.com/api/v1/sites/{subdomain}/collections`
- Auth: HTTP bearer

## Request body

- union
  - object
    - `preset` 'blog' | 'directory', required: Built-in field set and collection slug
    - `attachDynamicPage` object: Optional: append minimal list/detail page at /{slug} with home navbar/footer
      - `slug` string, required
      - `title` string
  - object
    - `name` string, required
    - `slug` string, required
    - `fields` CmsFieldDef[], required
      - `id` string, required
      - `name` string, required
      - `type` 'text' | 'richText' | 'number' | 'boolean' | 'date' | 'image' | 'url' | 'select' | 'color' | 'gallery' | 'file' | 'reference' | 'multiReference', required
      - `required` boolean: Must be true for the field that matches the collection `slugField` id.
      - `options` string[]
      - `referenceCollectionId` string: Target collection id for reference / multiReference fields.
    - `titleField` string, required
    - `slugField` string, required
    - `slugBasedOn` string
    - `contentField` string
    - `imageField` string
    - `attachDynamicPage` object
      - `slug` string, required
      - `title` string

## Response `201`

Collection created

- object
  - `collection` CmsCollectionSchema, required
    - `id` string, required
    - `name` string, required
    - `slug` string, required
    - `fields` CmsFieldDef[], required
      - `id` string, required
      - `name` string, required
      - `type` 'text' | 'richText' | 'number' | 'boolean' | 'date' | 'image' | 'url' | 'select' | 'color' | 'gallery' | 'file' | 'reference' | 'multiReference', required
      - `required` boolean: Must be true for the field that matches the collection `slugField` id.
      - `options` string[]
      - `referenceCollectionId` string: Target collection id for reference / multiReference fields.
    - `titleField` string, required
    - `slugField` string, required
    - `slugBasedOn` string: Field id to derive URL slug from when slug field is empty; defaults to titleField.
    - `contentField` string
    - `imageField` string

## Other responses

- `400`: Validation or conflict error
- `401`: Missing or invalid credentials
- `409`: Validation or conflict error

---

[API](https://skmtc.dev/slatehut/apis/slatehut-api.md) · [All operations](https://skmtc.dev/slatehut/apis/slatehut-api/llms.txt) · [OpenAPI document](https://skmtc.dev/slatehut/apis/slatehut-api/revisions/32dae277550c?raw)
