Records
A record is an instance of a model. It holds your actual data — the content fields, metadata, version history, and publishing state. All record types (pages, blog posts, products, bookings) are accessed through the same unified API.
Overview
Every record has:
- Data — The content fields defined by the model’s schema (text, images, references, etc.)
- Metadata — Non-versioned properties (tags, external IDs, custom attributes)
- Natural key — An optional slug or handle for human-friendly lookups (e.g.,
about-us,homepage) - Version history — For models with versioning enabled, each edit creates a new version
- Publishing state — For models with publishing enabled, records move through a draft/publish workflow
Versioning and Publishing Workflow
For models with versioning and publishing enabled:
- Create — A new record starts as version 1 in draft state
- Edit — Each save creates a new version (version 2, 3, etc.)
- Preview — View any version before publishing
- Publish — Make a specific version live; the public API returns the published version
- Roll back — Restore a previous version, as far back as your plan’s history window. Restoring APPENDS: the old version’s content comes back as a new version, validated like any other save, so history only ever moves forwards and the version you restored from stays exactly as it was
For models without publishing, changes take effect immediately. For models without versioning, updates replace the current data in place.
In the console
Creating a record
- Navigate to the content section for the model (e.g., Pages, Blog Posts)
- Click the model’s New button (for example New Page)
- Fill in the fields
- Click Save Draft or Publish (for models with publishing)
Editing a record
- Select the record from the list
- Make changes in the editor
- Save as a new draft or publish directly
Version history
For versioned models, click the History tab to view all versions, compare changes, and restore previous versions.
A restore is a new version, not a rewind, and it is validated exactly as any other save is. That matters when your model has changed since the version was written: an old version can hold a field your model no longer declares, which the save drops, or a value in a shape it no longer accepts, which the save refuses and names.
Restoring from the CLI or the API additionally re-spells a value whose type the model has since changed --- the same
conversion a schema migration performs, so a price stored before a type change comes back as the value it always was.
foir records revert <versionId> --validate-only reports everything it would convert, drop or refuse before anything is
written.
How long history is kept
Version history is retained for your workspace plan’s window:
| Plan | History kept |
|---|---|
| Free | 7 days |
| Entry | 30 days |
| Starter | 90 days |
| Pro | 1 year |
| Enterprise | For the life of the workspace |
A workspace that moves to Free because it stopped paying keeps the history it had: nothing is reclaimed because a payment lapsed.
A daily sweep reclaims versions older than the window. It only ever removes rows of the version history itself — records and variants are authored content and no age makes one deletable.
Five kinds of version are never reclaimed, whatever their age:
- the version you are currently editing (the draft the History tab opens on),
- the published version the public API serves,
- any version queued for a scheduled publish,
- any version a release would restore if you rolled the release back, and
- the newest version of every record.
A version that was published and has since been replaced by a newer publish is history like any other: it shows as Previously published and ages out with the rest of the window.
That last one is why a record can never end up with no history: if a record’s entire history is older than the window, its most recent version stays. Restoring is therefore always possible — the window bounds how far back you can go, not whether you can go back.
Changing plan changes the window, and the next sweep applies the new one. Moving to a shorter window can reclaim history that was previously inside it.
Via the CLI
The record subcommands take the model key and record identifier as positional arguments; field data is passed with -d, --data (inline JSON) or -f, --file (a JSON file).
List records for a model
foir records list blog-post
foir records list blog-post --first 20 --after <cursor>Get a record by ID or natural key
The second argument accepts either a record ID or a natural key:
foir records get blog-post rec_abc123
foir records get blog-post my-first-postAdd --resolved (published content), --preview (latest draft), or --locale <locale>.
Create a record
foir records create blog-post --natural-key my-first-post --data '{
"title": "My First Post",
"slug": "my-first-post",
"body": "Hello world."
}'Update a record
records update merges the fields you pass into the record’s content, and a versioned record gets a new version. --replace replaces the whole content instead, and --natural-key changes the key the record is addressed by. For the console “Save Draft” equivalent (atomic data + new version + current-version bump), use records save.
foir records update blog-post rec_abc123 --data '{ "title": "Updated Title" }'Save a record (Save Draft equivalent)
Atomically replaces the data, writes a new immutable version, and advances the current version so preview and storefront see the new content without a separate publish step.
foir records save blog-post rec_abc123 \
--data '{ "title": "Updated Title" }' \
--message "Fixed the title"Add --variant <key> to save into a specific variant.
Delete a record
foir records delete blog-post rec_abc123Publish a version
Publishing is by version ID:
foir records publish ver_xyz789Unpublish a record
foir records unpublish rec_abc123Create a new version
foir records create-version rec_abc123 \
--data '{ "title": "New Draft Version" }' \
--message "Reworked the intro"Duplicate a record
foir records duplicate blog-post rec_abc123 --natural-key my-first-post-copyList versions
foir records versions rec_abc123List variants
foir records variants rec_abc123Create a variant
foir records create-variant rec_abc123 --key mobile --name "Mobile Version"Via the API
Each public model has typed queries and mutations named after the model. The examples below use a page model; substitute your own model’s singular/plural names. Declared fields are returned at the top level of the record, alongside underscore-prefixed system fields (_id, _naturalKey, _modelKey, _createdAt, _updatedAt, _hasDraft, _ownerId, _ownerKind, _variant, and — for a caller holding targeting:debug — _segments and _resolvedBy). There is no data wrapper. See GraphQL → Querying Records for full detail.
Queries
Get a record by natural key
query {
page(naturalKey: "about") {
_id
_naturalKey
title
body
}
}The same read through the data client. There is no selection set — every scalar on the record comes back whether you asked for it or not:
const page = await foir.page.findUnique({ naturalKey: 'about' });Get a record by ID
query {
page(id: "rec_abc123") {
_id
title
}
}And by id:
const page = await foir.page.findUnique({ id: 'rec_abc123' });List records with filtering, sorting, and pagination
List queries return a Relay cursor connection. Use where to filter, orderBy to sort, and first/after to paginate:
query {
products(
where: { category: { eq: "electronics" }, price: { gte: 100 } }
orderBy: [{ createdAt: DESC }]
first: 20
) {
edges {
node {
_id
_naturalKey
title
price
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
totalCount
}
}The same list through the data client. findMany returns the same connection, so edges, pageInfo and totalCount are all still there:
const products = await foir.product.findMany({
where: { category: { eq: 'electronics' }, price: { gte: 100 } },
orderBy: [{ createdAt: 'DESC' }],
first: 20,
});Content resolution
Resolution — variant selection, locale handling, reference resolution — happens automatically from the query arguments; the resolved values come back directly on the typed fields. There is no separate resolved sub-field.
query {
page(
naturalKey: "homepage"
locale: "en-US"
contexts: { device: MOBILE, market: us }
) {
_id
title
hero {
heading
}
}
}Pass preview: true to get the latest draft instead of the published version (requires a key holding the drafts:read scope: a preview environment’s own key, never the one your production app ships).
Resolution arguments — including preview — are passed flat on the data client, alongside the key:
const page = await foir.page.findUnique({
naturalKey: 'homepage',
locale: 'en-US',
contexts: { device: 'MOBILE', market: 'us' },
preview: true,
});List versions
No SDK equivalent —
recordVersionsreads the versions of any record by parent id, with no model behind it, and returns an untyped record shape, so nothing generated from a per-model manifest can type the result. The typed per-model operations are the data client’s whole point; an untyped door beside them would be a downgrade, not parity. Read version history over/graphql.
query {
recordVersions(parentId: "rec_abc123", first: 10) {
edges {
node {
id
versionNumber
changeDescription
createdAt
}
}
pageInfo {
hasNextPage
endCursor
}
totalCount
}
}Mutations
Create a record
create<Model> takes the model’s declared fields flattened at the top level, plus the optional naturalKey system key.
mutation {
createBlogPost(input: {
naturalKey: "my-first-post"
title: "My First Post"
slug: "my-first-post"
body: "Hello world."
}) {
record {
_id
_naturalKey
title
}
replayed
}
}The same write through the data client. Model keys go on the wire verbatim, so a kebab-case key is reached with bracket access:
const { record: post } = await foir['blog-post'].create({
input: {
naturalKey: 'my-first-post',
title: 'My First Post',
slug: 'my-first-post',
body: 'Hello world.',
},
});Update a record
update<Model> identifies the target with where (must match exactly one record) and applies a typed operator tree in data. For versioned models, updates create a new version automatically.
mutation {
updateBlogPost(
where: { id: { eq: "rec_abc123" } }
data: { title: { set: "Updated Title" } }
changeDescription: "Fixed the title"
) {
record {
_id
_updatedAt
title
}
replayed
}
}The same update through the data client, with where and the operator tree in data passed through unchanged:
const { record: post } = await foir['blog-post'].update({
where: { id: { eq: 'rec_abc123' } },
data: { title: { set: 'Updated Title' } },
changeDescription: 'Fixed the title',
});Update many records
updateMany<Model> applies the same typed update to every record matching the predicate, returning { count, ids, replayed }. Always scope where: omitting it matches every record in the model.
mutation {
updateManyProduct(
where: { category: { eq: "electronics" } }
data: { price: { multiply: "0.9" } }
idempotencyKey: "sale-electronics-2026-09"
) {
count
ids
replayed
}
}The same bulk update through the data client, with the same obligation to scope where:
const result = await foir.product.updateMany({
where: { category: { eq: 'electronics' } },
data: { price: { multiply: '0.9' } },
idempotencyKey: crypto.randomUUID(),
});A multiply or an increment acts again when repeated, so it needs an idempotencyKey: a retry with the same key answers with the first attempt’s result instead of applying twice. See GraphQL → Update Many Records.
Publish a version
mutation {
publishBlogPostVersion(versionId: "ver_xyz789")
}The operation is named publishVersion on the data client — the manifest’s name for the publish<Model>Version field — and takes the same version id:
await foir['blog-post'].publishVersion({ versionId: 'ver_xyz789' });Unpublish a record
mutation {
unpublishBlogPost(id: "rec_abc123")
}The same call on the data client:
await foir['blog-post'].unpublish({ id: 'rec_abc123' });Delete a record
mutation {
deleteBlogPost(id: "rec_abc123")
}Returns true on success.
And on the data client:
await foir['blog-post'].delete({ id: 'rec_abc123' });Batch Operations
Process multiple create, update, and delete operations across any models in a single request. Each operation declares its type and the fields that type needs:
No SDK equivalent — a batch names its models as runtime strings and returns counts and errors rather than any one model’s shape, so nothing generated from a per-model manifest can type it. The typed per-model operations are the data client’s whole point; an untyped door beside them would be a downgrade, not parity. Send batches over
/graphql.
mutation {
batchRecordOperations(input: {
operations: [
{
type: CREATE
modelKey: "product"
naturalKey: "blue-widget"
data: { name: "Blue Widget", price: "29.99" }
}
{
type: UPDATE
modelKey: "product"
id: "rec_existing123"
data: { price: "24.99" }
}
{
type: DELETE
id: "rec_old456"
}
]
}) {
created
updated
deleted
errors {
type
index
message
}
}
}Atomic Field Operations
Atomic field updates are expressed through the update operator tree, evaluated server-side without a read-modify-write round trip. One that acts again when repeated (increment, decrement, multiply, push, splice) is refused unless the update carries an idempotencyKey, so that a retry lands once; see GraphQL → Update a Record:
mutation {
updateArticle(
where: { id: { eq: "rec_abc123" } }
data: {
viewCount: { increment: 1 }
tags: { push: ["featured"] }
lastViewed: { set: "2026-02-23T12:00:00Z" }
}
idempotencyKey: "view-rec_abc123-7f3c9a"
) {
record {
_id
viewCount
tags
}
replayed
}
}The same update through the data client. The operator tree is the data argument, unchanged:
const { record: article } = await foir.article.update({
where: { id: { eq: 'rec_abc123' } },
data: {
viewCount: { increment: 1 },
tags: { push: ['featured'] },
lastViewed: { set: '2026-02-23T12:00:00Z' },
},
idempotencyKey: crypto.randomUUID(),
});| Operator | Applies to | Effect |
|---|---|---|
set | any field | Replace the value |
setNull | any field | Clear the value (set to null) |
increment / decrement / multiply | number | Adjust the numeric value in place |
push | list | Append items |
pull | list | Remove matching items |
splice | list | Insert/remove at an index (start, deleteCount, insert) |
removeWhere | list | Remove items matching the item’s where shape |
connect / disconnect | reference | Point at / clear a referenced record |
Filtering
Each model has a generated <Model>WhereInput. Filter on declared fields by key, plus the always-available direct columns (id, naturalKey, createdAt, updatedAt, ownerId, createdBy, updatedBy). Operators available depend on the field type. Common text operators:
| Operator | Description | Example |
|---|---|---|
eq | Equals | { status: { eq: "active" } } |
ne | Not equals | { status: { ne: "cancelled" } } |
lt / gt / lte / gte | Comparison | { price: { gte: 50 } } |
contains / startsWith / endsWith | Substring match (text) | { title: { contains: "shirt" } } |
in / nin | In / not in array | { category: { in: ["a", "b"] } } |
isNull / isNotNull | Null check | { publishedAt: { isNotNull: true } } |
Compose with AND, OR, and NOT. See GraphQL → Filtering for operators by field type and list/reference filtering.
Advanced write patterns
For high-concurrency or bulk write scenarios, the GraphQL API exposes patterns that go beyond a plain field replacement:
- Atomic field operations —
increment,multiply,push,pull,splice,removeWhere, etc. on a single field, evaluated server-side without read-modify-write. See GraphQL → Atomic Field Operations. - Update many — apply one typed update to every record matching a predicate in a single mutation. See GraphQL → Update Many Records.
- Batch operations — group create/update/delete calls across models into a single
batchRecordOperationsmutation that runs as one round trip. See GraphQL → Batch Operations.
Best Practices
- Use natural keys for records that need human-friendly URLs (pages, blog posts). They make API queries and CLI lookups much simpler.
- Write meaningful
changeDescriptionvalues on each update so your version history is useful. - Use atomic field operations (
increment,push, etc.) for counters and array fields to avoid race conditions. - For bulk updates across many records, use update many with a scoped
wherepredicate. - For bulk imports or migrations, use batch operations to reduce round trips.