Collections

Structured content for your site — blog posts, products, team members, and more.

What are Collections?

Collections are containers for your structured content. Think of them as spreadsheets where each column has a type — text, number, date, and more. You create a collection, define its fields, then add records through the admin UI, the AI assistant, or the REST API.

Define Schema

Create collections with typed fields — text, number, boolean, date, select, and more.

Manage Records

Add, edit, and delete records through the admin UI or the REST API.

Use in Templates

Query records directly in your page templates with built-in functions.

Schema Field Types

text

Short or long text

"Hello world"

number

Integer or decimal

42

bool

True or false

true

date

Date and time

"2024-01-15T10:30:00Z"

select

Single choice from options

"published"

email

Email address

"user@example.com"

url

Web URL

"https://example.com"

json

Raw JSON data

{"key": "value"}

Using Collections in Templates

Access your collection data directly in page templates with built-in functions.

List all records from a collection
{{range $post := documents "blog-posts"}}
  <h2>{{$post.GetString "title"}}</h2>
  <p>{{$post.GetString "content"}}</p>
{{end}}
Get a single record by ID
{{with document "record-id"}}
  <h1>{{.GetString "title"}}</h1>
  <span>Price: ${{.GetInt "price"}}</span>
{{end}}
Access record data by type
{{$doc.GetString "title"}}     {{/* text fields */}}
{{$doc.GetInt "count"}}        {{/* number fields */}}
{{$doc.GetBool "published"}}   {{/* boolean fields */}}
{{$doc.GetTime "createdAt"}}   {{/* date fields */}}
{{$doc.GetStrings "tags"}}     {{/* array fields */}}
Note

The REST API lets you manage records programmatically. Use it to sync data from external systems, build custom integrations, or automate content workflows.

REST API

Manage records programmatically via the API. See the API Reference for authentication details.

GET /api/collections/{collectionId}/records

List all records in a collection.

POST /api/collections/{collectionId}/records

Create a new record. Send field values as JSON body.

PATCH /api/collections/{collectionId}/records/{recordId}

Update an existing record.

DELETE /api/collections/{collectionId}/records/{recordId}

Delete a record.

Access Rules

Control who can read, create, update, and delete records with rule expressions.

Rule Meaning
"" (empty) Admin only (default)
"true" Anyone (public access)
"@request.auth != nil" Any authenticated user
"@request.auth.role = 'admin'" Admin users only

Rules are set per-collection in the admin dashboard under Settings.

Example: Blog Posts

Schema
[
  {"name": "title",     "type": "text",   "required": true},
  {"name": "content",   "type": "text",   "required": true},
  {"name": "author",    "type": "text",   "required": false},
  {"name": "published", "type": "bool",   "required": false},
  {"name": "tags",      "type": "json",   "required": false}
]
Page Template
<div class="blog">
  {{range $post := documents "blog-posts"}}
    {{if $post.GetBool "published"}}
      <article>
        <h2>{{$post.GetString "title"}}</h2>
        <p class="author">By {{$post.GetString "author"}}</p>
        <div>{{$post.GetString "content"}}</div>
      </article>
    {{end}}
  {{end}}
</div>

What's next?