# Collections & Fields

> How Pottr models structured application entities using 9 field types, strict validation, and normalized schemas.

- **Category:** Core Concepts
- **Canonical Guide:** https://pottr.tangble.com/docs/collections-and-fields

---

>
How Pottr models structured application entities using 9 field types, strict validation, and normalized schemas.

## What is a Collection?

In Pottr, a **Collection** represents a structured data entity — such as `projects`, `tickets`, `invoices`, or `bookings`. Unlike WordPress posts, collections do not use `wp_posts` or `wp_postmeta`, keeping your application data separated from editorial content.

Collection slugs must use lowercase alphanumeric characters with hyphens or underscores (matching `^[a-z][a-z0-9_-]*$`).

## The 9 Supported Field Types

<table class="docs-table">
<thead>
<tr>
<th>Type</th>
<th>Data Representation</th>
<th>Description & Sanitization</th>
</tr>
</thead>
<tbody>
<tr>
<td>`text`</td>
<td>String</td>
<td>Single-line text. Sanitized via WordPress `sanitize_text_field()`.</td>
</tr>
<tr>
<td>`textarea`</td>
<td>String</td>
<td>Multi-line plain text. Sanitized via `sanitize_textarea_field()`.</td>
</tr>
<tr>
<td>`rich_text`</td>
<td>String (HTML)</td>
<td>Formatted HTML text. Sanitized via `wp_kses_post()`.</td>
</tr>
<tr>
<td>`number`</td>
<td>Number (int / float)</td>
<td>Stored and indexed as numeric values.</td>
</tr>
<tr>
<td>`boolean`</td>
<td>Boolean (`true` / `false`)</td>
<td>Boolean flag. Normalized to standard boolean on output.</td>
</tr>
<tr>
<td>`date`</td>
<td>String (ISO-8601)</td>
<td>Date/datetime string (e.g. `2026-05-10` or `2026-05-10T14:30:00Z`).</td>
</tr>
<tr>
<td>`relation`</td>
<td>Integer (Entry ID)</td>
<td>Foreign key ID referencing an entry in another collection.</td>
</tr>
<tr>
<td>`media`</td>
<td>Integer (Attachment ID)</td>
<td>WordPress media attachment ID.</td>
</tr>
<tr>
<td>`json`</td>
<td>Object / Array</td>
<td>Arbitrary structured JSON data payload.</td>
</tr>
</tbody>
</table>

## The Primary Title Field

Every collection in Pottr includes a primary `title` field (type `text`, required). If you declare a collection via Blueprints without a `title` field, Pottr automatically prepends it to the schema.

## What Is Validated

On every `POST`, `PUT` and `PATCH`, Pottr checks the body against the collection's schema:

<ul>
<li>Keys that are not fields of the collection are rejected (`unknown_field`).</li>
<li>Required fields must be present and non-empty (`missing_required`).</li>
<li>Each value is coerced and sanitized for its field type; values that cannot be coerced are rejected (`invalid_field`).</li>
<li>`relation` and `media` values must be positive integer IDs.</li>
</ul>

## User-Owned Collections

Add a `relation` or `number` field with the key `user_id` and the collection becomes user-owned: Pottr fills in the signed-in user on create and limits reads and writes to their entries. See [User-Owned Data](/pottr/docs/user-owned-data).

## Plan Limits

The number of collections and entries per collection depends on your plan. Hitting a limit returns `403 collection_limit_reached` or `403 entry_limit_reached`. See [Plans, Limits & Licensing](/pottr/docs/plans-and-limits).
