# set_chapter_rule

Keep a collection in sync with a property value, or stop.

`PUT /v1/chapters/{collectionId}/rule` · MCP tool `set_chapter_rule` · scope `write` · beta · since 2026-10-26.4

The studio's Stay in sync for a plain collection (kind collection; chapters refuse it): with a rule its spot members become exactly the live spots that match, in a moment and from then on, keeping the place of spots that already belonged; set_chapter_members can then only reorder them. rule null stops syncing and keeps the spots it holds, hand-picked from then on. Returns the collection.

## Path parameters

- `collectionId` (string, required): Id of the collection (list_chapters).

## Body parameters

- `rule` (CollectionSyncRule or null, required): { source: all } follows every live spot except helpers; { source: option, propKey, optionId } a select or checkbox option; { source: text, propKey, value } a short text property value; { source: kicker, value } the spots' kicker. null stops syncing.
  Fields of CollectionSyncRule: https://developers.sceniq.earth/fields/collection-sync-rule.md

## Returns

200: Chapter.

- `collectionId` (string, required): The chapter's or collection's id.
- `productId` (string, required): The guide's id.
- `name` (string, required): Its title.
- `slug` (string or null, required): URL slug, unique in the guide.
- `description` (string or null, required): One-line summary on the chapter card.
- `kind` (string, required): chapter carries a stack of pages; collection is a plain spot set. One of `collection`, `chapter`.
- `pages` (array of ChapterPage, required): The chapter pages in reading order, normalised on save. Chapter spots are the unique Spots-page refs in page order; member rows follow them. Legacy chapters are converted on read. Empty chapters and plain collections return []. Replaces the removed body and intro response fields.
  Fields of ChapterPage: https://developers.sceniq.earth/fields/chapter-page.md
- `rule` (CollectionSyncRule or null, required): The studio-managed rule for a synced collection. A source of all follows every live spot except helper pins; other sources follow a property value. Null for hand-picked collections and chapters. Synced spot members can only be reordered through the API.
  Fields of CollectionSyncRule: https://developers.sceniq.earth/fields/collection-sync-rule.md
- `order` (number, required): Position in the guide.
- `coverUrl` (string or null, required): The cover image.
- `coverStorageId` (string or null, required): The cover's storage id (from an upload with target=blob).
- `members` (array of objects, required): Members in order: spots, or chapters inside a collection.
  - `spotKey` (string or null, required): A member spot's key.
  - `memberCollectionId` (string or null, required): A chapter placed as a card inside a collection.
  - `order` (number, required): Position in the chapter.
- `archived` (boolean, required): true when the chapter or collection is hidden from buyers but kept (update_chapter archived).
- `createdAt` (number, required): When the row was created (Unix time in milliseconds).
- `updatedAt` (number, required): When the row last changed (Unix time in milliseconds).

## Examples

### Keep Top picks in sync with every spot whose Best time is Sunrise

```bash
curl -X PUT "https://sceniq.earth/api/v1/chapters/kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n/rule" \
  -H "Authorization: Bearer $SCENIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "rule": {
    "source": "option",
    "propKey": "best_time",
    "optionId": "sunrise"
  }
}'
```

MCP `tools/call`:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "set_chapter_rule",
    "arguments": {
      "collectionId": "kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n",
      "rule": {
        "source": "option",
        "propKey": "best_time",
        "optionId": "sunrise"
      }
    }
  }
}
```

Response 200:

```json
{
  "collectionId": "kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n",
  "productId": "j5738kd1q9x2m7v4c6b8n0p3r5t1w9y2",
  "name": "Top picks",
  "slug": null,
  "description": "If you only have a day in each park",
  "kind": "collection",
  "rule": {
    "source": "option",
    "propKey": "best_time",
    "optionId": "sunrise"
  },
  "pages": [],
  "order": 4096,
  "coverUrl": null,
  "coverStorageId": null,
  "members": [
    {
      "spotKey": "01M2Z1G0Y0R2K5P8S1V4X7Z0C3",
      "memberCollectionId": null,
      "order": 1024
    },
    {
      "spotKey": "01M3H2AWH0F9PB64V7QB8QS0MC",
      "memberCollectionId": null,
      "order": 2048
    }
  ],
  "archived": false,
  "createdAt": 1789895640000,
  "updatedAt": 1790673240000
}
```

### Stop syncing: the spots it holds stay, hand-picked from now on

```bash
curl -X PUT "https://sceniq.earth/api/v1/chapters/kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n/rule" \
  -H "Authorization: Bearer $SCENIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "rule": null
}'
```

MCP `tools/call`:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "set_chapter_rule",
    "arguments": {
      "collectionId": "kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n",
      "rule": null
    }
  }
}
```

Response 200:

```json
{
  "collectionId": "kn7a2s4d6f8g0h2j4k6k8z0x2c4v6b8n",
  "productId": "j5738kd1q9x2m7v4c6b8n0p3r5t1w9y2",
  "name": "Top picks",
  "slug": null,
  "description": "If you only have a day in each park",
  "kind": "collection",
  "rule": null,
  "pages": [],
  "order": 4096,
  "coverUrl": null,
  "coverStorageId": null,
  "members": [
    {
      "spotKey": "01M2Z1G0Y0R2K5P8S1V4X7Z0C3",
      "memberCollectionId": null,
      "order": 1024
    },
    {
      "spotKey": "01M3H2AWH0F9PB64V7QB8QS0MC",
      "memberCollectionId": null,
      "order": 2048
    }
  ],
  "archived": false,
  "createdAt": 1789895640000,
  "updatedAt": 1790673240000
}
```

## Errors

- `invalid_argument` (400): A required field is missing, a field is unknown, or a value does not match its type (the Convex validator's path and value are in the message).
- `invalid_request` (400): A writer refused a value: a map link on a host that is not allowed, a title that is too long, a date that does not exist, too many items in a list. The message is the writer's own sentence.
- `unauthenticated` (401): The request carries no key. Send it as Authorization: Bearer sk_sceniq_... (or X-Api-Key).
- `invalid_api_key` (401): The key is unknown, revoked or expired.
- `api_scope_required` (403): A read-only key called a write operation, or a key without the publish option called publish_changes.
- `forbidden` (403): The key belongs to a creator account that is no longer active.
- `not_found` (404): The id does not exist or belongs to another creator. The two answers are identical on purpose, so ids never reveal what exists.
- `payload_too_large` (413): A JSON body over 2 MB, an image over 6 MB, a batch upload over 19 MB, or an MCP message over 2 MB.
- `rate_limited` (429): Over a limit: requests per key per minute, per creator per hour, uploads per key per minute, or check_links per guide per hour.
- `internal_error` (500): An unexpected failure. The message is hidden on purpose.

Reference: https://developers.sceniq.earth/reference/set_chapter_rule
