# All 19 Field Types

> Reference for all 19 canonical OvertCMS field types, FieldDefinition properties, reserved keys, requiredOn lifecycle modes, and PATCH null semantics.

OvertCMS enforces a closed, strongly typed schema system built on **19 canonical field types**. Every field inside a post type, reusable component, inline object, or list item uses one of these 19 types—there are no untyped escape hatches outside the explicit `json` field type.

## The 19 Canonical Field Types

| Type | Wire Format (JSON) | `filterable` | `sortable` | `unique` | Primary Use Case |
| --- | --- | --- | --- | --- | --- |
| `string` | `string` | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Yes | Titles, names, emails, CSS colors, short labels |
| `text` | `string` | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Yes | Multi-line plain text, excerpts, bios, summaries |
| `slug` | `string` | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Built-in per locale | URL-safe entry identifiers (`kebab-case`) |
| `rich_html` | `string` (canonical HTML5) | No | No | No | Long-form articles with semantic HTML5 and `<cms-block>` components |
| `number` | `number` | Yes (`eq`, `in`, `gte`, `lte`) | Yes | Yes | Prices, ratings, counts, sort weights |
| `boolean` | `boolean` | Yes (`eq`, `in`) | Yes | Yes | Feature flags, toggles, binary indicators |
| `date` | `string` (`YYYY-MM-DD`) | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Yes | Calendar dates without time or timezone |
| `datetime` | `string` (RFC3339 UTC) | Yes (`eq`, `in`, `gte`, `lte`) | Yes | Yes | Exact timestamps with timezone offset or `Z` |
| `time` | `string` (`HH:mm` or `HH:mm:ss`) | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Yes | Wall-clock time of day without date or timezone |
| `url` | `string` | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Yes | Yes | External links, canonical URLs, root-relative paths |
| `select` | `string` or `string[]` | Yes (`eq`, `in`, `contains`, `gte`, `lte`) | Single-select | Single-select | Fixed enums, tags, categories with optional custom values |
| `reference` | `string` or `string[]` | Yes (`eq`, `in`) | No | Single-reference | Strongly typed relations to entries in target post types |
| `image` | `object` (`{ assetId, alt, ... }`) | No | No | No | Verified image assets with alt text and focal points |
| `audio` | `object` (`{ assetId, ... }`) | No | No | No | Audio tracks with transcripts and durations |
| `video` | `object` (`{ assetId, ... }`) | No | No | No | Video assets with poster images and durations |
| `file` | `object` (`{ assetId, ... }`) | No | No | No | Downloadable documents (PDF, CSV, plain text) |
| `object` | `object` | No | No | No | Nested inline field groups or reusable component references |
| `list` | `array` | Primitive lists only | No | No | Ordered arrays of primitives, objects, components, or discriminated unions |
| `json` | any valid JSON value | No | No | No | Semi-structured payloads bounded by `maxBytes` and optional `jsonSchema` |

<Note>
  `slug` fields are always unique per `(site, postType, locale)` at the database level. Setting `unique: true` on other scalar fields (`string`, `text`, `url`, `date`, `time`, `datetime`, `number`, `boolean`, single `select`, single `reference`) enforces atomic uniqueness across all non-trashed entries in the same `(site, postType, locale)` via `entry_unique_values`.
</Note>

### Explore Field Families

- [Text & Rich HTML Fields](/fields/text-fields) — `string`, `text`, `slug`, `rich_html`
- [Primitive, Date & URL Fields](/fields/primitive-and-date-fields) — `number`, `boolean`, `date`, `datetime`, `time`, `url`
- [Select & Reference Fields](/fields/select-and-reference) — `select`, `reference`
- [Media Fields](/fields/media-fields) — `image`, `audio`, `video`, `file`
- [Composite & JSON Fields](/fields/composite-fields) — `object`, `list`, `json`

---

## `FieldDefinition` Reference

Every field in a post type or component is defined by a `FieldDefinition` JSON object. When a post type or component is saved, OvertCMS automatically normalizes defaults and assigns an immutable UUIDv7 `fieldId` to every field (preserving `fieldId` across updates when matched by `fieldId` or `key`).

```json
{
  "fieldId": "0195c8a2-7b4d-7f10-8e3a-6b2c1d4e5f6a",
  "key": "headline",
  "label": "Headline",
  "type": "string",
  "instruction": "Write an engaging, sentence-case headline under 80 characters.",
  "description": "Primary H1 displayed on the article page and social cards.",
  "required": true,
  "requiredOn": "publish",
  "writable": true,
  "readOnly": false,
  "aiWritable": true,
  "filterable": false,
  "sortable": true,
  "unique": false,
  "localized": true,
  "deprecated": false,
  "replacedBy": "",
  "defaultValue": null,
  "constraints": {
    "minLength": 10,
    "maxLength": 80,
    "lengthUnit": "graphemes",
    "trim": true
  },
  "ui": {
    "group": "Header",
    "order": 1,
    "placeholder": "Enter a concise headline...",
    "width": "full"
  }
}
```

### Complete Property Reference

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `fieldId` | `string` | Auto UUIDv7 | Immutable field identifier assigned by the server and preserved across schema updates. |
| `key` | `string` | Required | JSON property name on entry `data`. Must match `^[a-z][a-zA-Z0-9_]{0,63}$` and must not be reserved. |
| `label` | `string` | Required | Human-readable label shown in the Admin UI and validation error messages. |
| `type` | `string` | Required | One of the 19 canonical field types listed above. |
| `instruction` | `string` | `""` | AI & editorial authoring guidance (max **2,000** Unicode characters). Surfaced in `/agent/v1/prompt`, schemas, and validation issues. |
| `description` | `string` | `""` | Short helper text (max **500** Unicode characters). |
| `required` | `boolean` | `false` | Whether the field must have a non-empty value. Evaluated according to `requiredOn`. |
| `requiredOn` | `"draft"` \| `"publish"` | `"publish"` | Lifecycle stage at which `required: true` is enforced. |
| `writable` | `boolean` | `true` | If `false`, no API caller may write or clear this field (`field_read_only`). |
| `readOnly` | `boolean` | `false` | If `true`, prevents all API writes or clears to this field (`field_read_only`). |
| `aiWritable` | `boolean` | `true` | If `false`, API key and MCP actors cannot set, modify, or clear this field (`field_not_ai_writable`), while human Admin users still can. |
| `filterable` | `boolean` | `false` | Indexes the field in `entry_field_index` (or uses `entry_references`) so queries can filter on it. |
| `sortable` | `boolean` | `false` | Indexes the field for keyset-paginated `sort` queries. |
| `unique` | `boolean` | `false` | Enforces atomic uniqueness across non-trashed entries per `(site, postType, locale)`. |
| `localized` | `boolean` | `false` | Marks whether the field varies across locales on localized post types. |
| `deprecated` | `boolean` | `false` | Flags the field as deprecated in schemas and prompts without breaking existing data. |
| `replacedBy` | `string` | `""` | Key of a sibling, non-deprecated field replacing this field. Requires `deprecated: true`. |
| `defaultValue` | `any` | `null` | Value applied automatically when a field is omitted or `null` (unless explicitly cleared on `PATCH`). |
| `constraints` | `object` | `{}` | Type-specific validation and structural rules (`FieldConstraints`). |
| `ui` | `object` | `null` | Cosmetic authoring hints (`group`, `order`, `placeholder`, `width`). Excluded from `schemaFingerprint`. |
| `searchEndpoint` | `string` | Auto (for `reference`) | Server-populated Agent Plane URL (`/agent/v1/collections/{postType}/fields/{path}/options`) on `reference` fields. |

<Tip>
  **Instruction length limits across the schema hierarchy:**
  - Site instruction: max **8,000** characters
  - Post type instruction: max **4,000** characters
  - Component instruction: max **2,000** characters
  - Field instruction (and list variant instruction): max **2,000** characters
  - Field description: max **500** characters
</Tip>

### Deprecation Rules (`deprecated` and `replacedBy`)

When evolving a schema without breaking agents or clients, mark an old field `deprecated: true` and optionally point `replacedBy` to a sibling field in the same field list:

- Setting `replacedBy` while `deprecated: false` fails with `replaced_by_requires_deprecated`.
- Pointing `replacedBy` to the field's own key fails with `invalid_replaced_by`.
- Pointing `replacedBy` to a nonexistent sibling fails with `unknown_replaced_by`.
- Pointing `replacedBy` to another deprecated field fails with `deprecated_replaced_by`.

---

## Reserved Keys and Slugs

### Reserved Field Keys

Field keys must match `^[a-z][a-zA-Z0-9_]{0,63}$` and cannot collide with system entry properties or JavaScript prototype-pollution keys:

| Category | Reserved Field Keys |
| --- | --- |
| Prototype-pollution keys (rejected at **every** nesting depth, including inside `json` and `<cms-block data-props>`) | `__proto__`, `constructor`, `prototype` |
| System entry envelope keys | `id`, `status`, `_meta`, `version`, `etag`, `createdAt`, `updatedAt`, `publishedAt`, `scheduledAt`, `unpublishAt`, `locale`, `translationGroupId` |
| Conditional key | `slug` — **allowed ONLY** when `type` is `"slug"`; rejected with `reserved_field_key` for any other field type |

### Reserved Post-Type Slugs

Post-type and component slugs must match `^[a-z][a-z0-9_-]{0,63}$`. Post-type slugs cannot collide with Delivery or Schema route namespaces:

- `site`
- `redirects`
- `media`
- `singletons`
- `sitemap`
- `components`
- `post-types`

Attempting to create a post type with any of these slugs returns `422` with issue code `reserved_post_type_slug`.

---

## `requiredOn: "draft" | "publish"`

OvertCMS separates draft authoring from publication readiness using the `requiredOn` attribute:

- **`"publish"` (default):** A field with `required: true` and `requiredOn: "publish"` may be omitted or empty (`""`) while creating or patching a `draft` entry. When the entry is published, scheduled, or created directly with `status: "published"` or `status: "scheduled"`, validation switches to publish mode and rejects missing or empty values with code `required`.
- **`"draft"`:** A field with `required: true` and `requiredOn: "draft"` is enforced immediately on every `draft` create and update, as well as on publish/schedule. Use this for essential identifiers like `title` or `slug`.

<Note>
  Updating a `scheduled` entry also validates in **publish mode** so a scheduled release can never drift into an unpublishable state before its `scheduledAt` timestamp fires.
</Note>

---

## Write Permissions (`readOnly`, `writable`, `aiWritable`)

OvertCMS enforces field- and component-level write guards on both full creates and partial `PATCH` updates:

- **`readOnly: true` or `writable: false`:** Any attempt to set, change, or clear the field returns `422` with `field_read_only`. Existing values on untouched keys during a `PATCH` are preserved cleanly.
- **`aiWritable: false`:** Blocks API key (`api_key`) and MCP (`mcp`) actors from writing, modifying, or clearing the field (`field_not_ai_writable`) or component (`component_not_ai_writable`). Human Admin users (`user` actors) can still edit these fields.
- **Nested protection:** Clearing or overwriting an `object` or `list` that contains an existing protected child field is also rejected unless the protected child remains untouched.

---

## `PATCH` Null Semantics: `null`, `clearFields`, and `X-Null-Semantics: clear`

LLM agents frequently serialize optional fields as `null` when constructing partial update payloads. To prevent accidental data loss, OvertCMS enforces **safe null semantics by default**:

| Payload on `PATCH` | Default Behavior | With `X-Null-Semantics: clear` (or MCP `nullClears: true`) |
| --- | --- | --- |
| Key omitted from `data` | Unchanged | Unchanged |
| `"summary": null` in `data` | **Unchanged** (ignored) | **Cleared** (removed from `draftData`) |
| `"clearFields": ["summary"]` | **Cleared** (removed from `draftData`) | **Cleared** (removed from `draftData`) |

### Rules and Conflict Guards

1. **Explicit clearing via `clearFields`:** Pass the top-level field keys to erase in `clearFields: ["subtitle", "heroImage"]`. Cleared fields do **not** have their `defaultValue` re-applied on that `PATCH`.
2. **Conflict detection:** Providing the same field key as a non-null value in `data` (or targeting it in `bodyPatches`) **and** listing it in `clearFields` (or null-clearing it under `X-Null-Semantics: clear`) fails with `field_both_set_and_cleared`.
3. **Mixing `data` and `bodyPatches`:** Providing a non-null value in `data` **and** a `bodyPatches` entry for the same `rich_html` field fails with `field_both_set_and_patched`.
4. **Clearing protected or required fields:** Clearing a `readOnly` or `!aiWritable` field fails with `field_read_only` / `field_not_ai_writable`. Clearing a field that is currently required (e.g., `requiredOn: "draft"`, or any required field on a `scheduled` entry) fails with `required`.

```json
{
  "expectedVersion": 3,
  "data": {
    "title": "Updated Article Title",
    "subtitle": null
  },
  "clearFields": ["excerpt"]
}
```

In the default request above, `title` is updated, `subtitle` is left **untouched**, and `excerpt` is explicitly **cleared**.
