---
title: "Update collection schema (fields and title/slug/content/image pointers)"
method: PATCH
path: "/api/v1/sites/{subdomain}/collections/{collectionId}"
tags: ["collections"]
---

# Update collection schema (fields and title/slug/content/image pointers)

`PATCH /api/v1/sites/{subdomain}/collections/{collectionId}`

## Request

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

Cannot change the type of an existing field id; remove and add a new field instead. The field whose id matches `slugField` must remain present, have type `text`, and `required: true`.

## Request body

- object
  - `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
  - `contentField` string
  - `imageField` string

## Response `200`

- 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
- `404`: Resource not found

---

[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)
