Records
Creating types, publishing, writing rows, value formats and errors.
Raw Markdown for agents: records.md. MCP: read_docs("records").
Records are the structured data of a Space: user-defined record types (like
Supplier or Invoice) with typed fields, relations between types and a full
revision history per record. Documents are evidence, records are the state.
A type can also hold rules per case (per supplier, per product): Space and
connection rules name it as #key, and its description says when an agent
needs it.
Flow: from a new type to rows
- records.types.create with name, plural_name, an optional key and the fields
in
fields. The required title fieldnameis created automatically; an entry with keynamerelabels it. All fields are validated together; one invalid entry rejects the whole call. - Optionally records.fields.add_many to add more fields to the draft in one call (records.fields.add adds a single one). Relation fields are created with records.relationships.create (section Relations): create the types first, then the relations, then publish once per type.
- records.types.publish_preview lists every change with severity safe/warning/blocked. Fix blocked changes in the draft.
- records.types.publish turns the draft into an immutable schema version and creates the table. It needs space administration rights; in the chat it runs after the user confirms it.
- records.types.describe returns the field keys, option keys and an example payload; then write rows with data.write (read_docs("data")).
Field order: records.fields.add, add_many (per entry), update and
records.relationships.create (field.position, reverse_field.position) take an
optional position, the 0-based index among the live fields (later fields
shift down; omitted = at the end). records.fields.reorder (REST: POST
/records/types/{id}/fields/reorder) takes either every live field id in
field_ids or only some of them plus position: the listed fields move as a
block, in that order, to that index and the rest keep their relative order
(one field to the top: field_ids [id], position 0). Never resend all ids just to
move a few.
Draft revisions: every draft change (types.update, fields., relationships.) raises the type's draft_revision by one and returns the new value. Pass the last value you saw as expected_draft_revision; if someone else changed the draft in between, the call fails with draft_revision_conflict instead of overwriting their change. Omit it only when no one else edits the type.
records.fields.add, records.fields.add_many and records.fields.update answer
{field or fields, draft_revision, field_count}; records.fields.reorder answers
{field_ids (the new order), draft_revision, field_count}.
Pass include_type: true to get the full type detail with every draft field,
relationship and the published schema instead; records.types.get returns the
same detail at any time.
records.types.create and records.types.update answer {id, key,
draft_revision, current_version (once published), has_unpublished_changes,
updated_at, field_ids}, where field_ids maps every field key to its id.
records.relationships.create answers {record_relationship_id, record_type_id,
field_id, reverse_field_id (when a reverse field was created),
draft_revision, updated_at, target_type_id, target_draft_revision (when the
target is another type)}. Pass include_type: true for the full detail (both
types for a relationship); null and empty values are left out of it.
Rules
- Keys match
^[a-z][a-z0-9_]{0,63}$: a lowercase letter, then lowercase letters, digits or underscores, at most 64 characters. - Reserved field keys: archived_at, created_at, created_by, id, revision, title, updated_at, updated_by. These system columns exist on every record and are returned automatically; choose another key.
- A record type holds at most 150 fields including
name. A space holds at most 100 record types. The space owner's plan caps active record types across all owned spaces (limitdatabases); beyond it creating or restoring fails with billing_limit_reached. - Field types: text, long_text, number, money, boolean, date, datetime, single_select, multi_select, user, record_relation, document_relation, lookup, count. A status or category with its own values is a single_select with one option per value.
- single_select and multi_select fields need config.options with at least one {id, key, label}; the id may equal the key. unique is allowed for text, number, date and datetime fields.
- Option
coloris optional. The palette the web app draws is neutral (same as null), primary, success, warning, danger. Other names (green, orange, blue, ...) are accepted and stored, but they are not tones: the app shows such an option in an automatic category colour chosen by its position. - Text fields take config.format: plain (default), email, url or object_ref.
object_ref is the identity of the object:
authority:type:idwith the issuer first (acme.example:invoice:INV-1001,shopify:example.myshopify.com:order:1001). The type is a lower-case singular noun; prefer one of account, asset, booking, budget, campaign, contact, contract, credit_note, customer, deal, debit_note, despatch_advice, document, employee, event, expense, inventory_item, invoice, journal_entry, lead, location, message, order, order_response, party, payment, payout, payslip, price_list, product, project, quotation, receipt_advice, refund, remittance, return, shipment, statement, subscription, supplier, task, tax_filing, ticket, transaction, variant, work_order. It must be unique, a type has at most one, and values are normalized (authority and type lower-case). Use it as merge_on and derive the business_key of integration writes from it (<ref>#<action>). - Text fields take config.reference: the value is the key of a record of
another type and reads come back with a link to it (section Display and
references). Every field takes
config.technical: true: keys, hashes and trace columns the app hides by default in views and the record detail;entry_keyof an append-only type always is technical. Both change safely after publish, also on a frozen append-only type. - A unique key makes a combination of 2 to 3 text, number, date or datetime fields unique among active records (a supplier id plus a line text, a product plus a warehouse). Declare it with records.types.update and unique_keys, a list of field-key lists that replaces the whole list; it is applied on publish, which is blocked while duplicate combinations exist. records.types.describe lists unique_keys.
- Values by field type when writing rows:
- text, long_text: a string.
- number: a decimal string such as "12.50".
- money: an object {"amount": "12.50", "currency": "COP"}. amount is a decimal string, currency an ISO 4217 code; without currency the field's currency_default is used. A bare number is rejected.
- boolean: true or false.
- date: "YYYY-MM-DD". datetime: ISO 8601, stored and returned in UTC.
- single_select: one option key. multi_select: a list of option keys.
- user: the id of an active member of the organization that owns the space (records.users.list); the user needs no access to the space.
- record_relation and document_relation: not among the values. data.write takes them as {field_key: [ids]} in link, unlink (single targets) or set_links (the whole list).
- lookup and count are computed and read-only (section Relations).
- data.write writes up to 200 entries in one transaction; an upsert entry
names a unique field or all fields of one unique key in
record.key: no match creates, a match updates. dry_run rehearses without writing. Runs started by routines or workflows may touch at most 5000 records.
Relations
records.relationships.create adds the record_relation field field to the
type record_type_id (the source), pointing at target_type_id; reverse_field
adds a field on the target type that shows the same links from the other side.
cardinality reads from source to target:
| cardinality | links per source record | links per target record | example (source → target) |
|---|---|---|---|
| many_to_one | 1 | many | invoice → customer |
| one_to_many | many | 1 | order → order lines |
| one_to_one | 1 | 1 | employee → desk |
| many_to_many | many | many | product → tags |
Decide with two questions: may one source record link several targets, and
may one target be linked from several sources? A record that references
several targets that other records reference too needs many_to_many.
records.types.describe shows cardinality and single_valued per relation
field. A single-valued field holds one link: change it with set_links;
link with a second target fails.
Changing the cardinality: records.relationships.update with
record_relationship_id (relationships[].id of records.types.get),
cardinality and the source type's expected_draft_revision, then
records.types.publish_preview and records.types.publish of the source type.
Loosening is safe; tightening is blocked (relationship_cardinality_changed
with affected_rows) while existing links exceed the new limit: unlink the
extra links first.
lookup and count fields read a relation of their own type, added with
records.fields.add: count with config.relationship_id counts the linked
active records; lookup with config.relationship_id and config.lookup_field_id
(a scalar field of the other type) shows that field of the linked records, one
value on a single-valued side, otherwise a list of up to 20. No field type sums
linked values; see Groups and levels.
Display and references
Store keys, never show them. Keys, NITs, hashes and ids live in their own fields, marked technical when people need not see them; the title stays readable (a description, a name, "FE163 ACME SAS"), never a key or a hash.
display on a type (records.types.update, published like the title field)
says what a link to one of its records shows: {"primary": [field_id, ...], "secondary": [field_id, ...]}, 1 to 3 primary and up to 3 secondary ids of
active text, number, money, date, datetime, single_select or boolean fields;
null shows the title. An invoice shows number with customer and total, a
bank movement description with date and amount. Trashing or deprecating
a field drops it from display.
config.reference makes a text field a soft reference by value, also on
append-only types where relation fields are not allowed: {"targets": [{"type": type_key, "field": field_key}, ...], "type_field": field_key} with
1 to 8 targets, each a published type of the space and its text or number
field. type_field is an optional sibling text or single_select field whose
value is the type_key of the target; with it the value is looked up in that
type only, without it in all targets. A journal line points at the document
it settles:
{"key": "documento_cruce", "label": "Documento cruce", "type": "text",
"config": {"reference": {"targets": [
{"type": "facturas", "field": "numero"},
{"type": "soportes", "field": "clave"},
{"type": "movimientos", "field": "clave"}],
"type_field": "tipo_cruce"}}}with tipo_cruce = facturas, soportes or movimientos on each row.
Name the target type whenever keys of different types can collide (invoice
numbers and NITs). Nothing is checked when writing and nothing blocks changes
on the targets; a missing target type or field is skipped when reading.
Reads resolve references: records.rows.query, data.read, records.entries.get
and guest reads add references per row, keyed by field key, for
config.reference fields and the reference rules of append-only types:
{key, title, record_id, type_id, type_key, display} with display
{"primary": [{type, value, precision?}], "secondary": [...]} (raw values,
null without display). A value without exactly one live match (none, or
several) comes back as {key, title: null} and stays text. Relation values
carry the same display next to id and title. The hard reference rule
of an append-only type stays for references every row must have: it is
checked by the database and blocks changes on the target.
Reading
records.schema describes a whole Space in one call: every published type with its columns (type, description, fill rate), the relations between types and the record counts. Read it once, then ask the data with records.sql (section SQL below).
records.types.list and records.types.describe stay for writing: describe gives the field keys, option keys, relation targets and the write_mode a data.write needs. data.read returns single records by id or unique key with their revision. records.rows.query lists records of one type with a filter tree {"combinator": "and", "conditions": [{"field": "status", "op": "eq", "value": "open"}]}, optional sort, q for a text search, view_key and a signed cursor. linked_to {relationship_id, record_id, record_side} keeps the records linked to one record, also from the side without a field; record_side is the side of that record in the relationship. records.rows.related lists the relationships of a record with the count of linked records per side. records.rows.history pages through the revisions of a record and records.rows.linked_to_document lists the records that reference a document. records.charts.data aggregates one type for a chart (read_docs("records_charts")), records.rows.aggregate sums and groups it (section Groups and levels). Never page through a large type to count or sum.
Export: records.exports.create (record_type_id, idempotency_key, plus filter,
sort, q, view_key, view_filter, archived and linked_to as in
records.rows.query) needs download rights and returns download_url, valid
for 10 minutes and usable without an auth header; it is a credential, never
post or log it. The CSV streams up to 200,000 rows with the columns id, title,
one per active field (header = field label), revision, created_at and
updated_at; money is "<amount> <currency>", lists and links (titles, document
names) are joined with "; ".
Filter tree
The same tree filters records.rows.query, records.rows.aggregate,
records.exports.create, saved views and if.where of data.write. A group is
{combinator: and|or, conditions: [...]}, a condition {field, op, value} or
another group; at most 20 conditions in the whole tree and 3 levels of
groups, the root included. field is a field key (the title field is
name); system columns cannot be filtered.
| field type | operators |
|---|---|
| text | eq, neq, contains, starts_with, in, empty, not_empty |
| long_text | contains, empty, not_empty |
| number, money, count | eq, neq, gt, gte, lt, lte, in, empty, not_empty |
| boolean | eq, empty, not_empty |
| date, datetime | eq, neq, before, after, on_or_before, on_or_after, in_last_days, in_next_days, older_than_days, empty, not_empty |
| single_select, user | eq, neq, in, empty, not_empty |
| multi_select, record_relation, document_relation | has, has_any, empty, not_empty |
| lookup | eq, neq, contains, empty, not_empty |
- empty and not_empty take no value (an empty text counts as empty); in and has_any a non-empty list of at most 100; all others one scalar.
- Values: money compares the amount (decimal string); single_select and multi_select take option keys, user a user id, record_relation a record id, document_relation a document id; date "YYYY-MM-DD", datetime ISO 8601 or "$now" (the current time).
- contains and starts_with ignore case. A lookup condition holds when one of the linked records matches; contains only on looked-up text, long_text or single_select fields.
- in_last_days, in_next_days and older_than_days take a number of days (1-3650), counted in UTC and moving every day, so a saved view needs no fixed date: in_last_days N is today and the N-1 days before, in_next_days N today and the N-1 days after, older_than_days N N or more days before today (1 means before today).
- Another operator for the field type fails with invalid_filter.
Groups and levels
Which way to a sum or count:
- One type, filtered or grouped by one of its fields (also a relation to one record, such as the order of a line): records.rows.aggregate (below).
- Across types, joins or computed expressions: records.sql with SUM, COUNT and GROUP BY (section SQL).
- The number of linked records, or a field of them, as a column of every record: a count or lookup field (section Relations). No field type sums linked values: aggregate the linked type grouped by its relation field when that field is single-valued, otherwise use records.sql.
- A total row under a saved view in the app: config.summary of the view (section Saved views); it only configures the display.
records.rows.aggregate takes the filter, q, archived and view_key of
records.rows.query and returns one head per group value: rows (count) and
measures, each {key, field, op} with op sum, avg, min or max over number
and money fields, or count (filled values) over any stored field; at most 32.
- group_by is a field key; omitted it is the group of the view, null returns totals only. Text, number, boolean, date, datetime, single_select and user fields and relations to one record can be grouped. label is the title of the referenced or linked record. Text groups treat an empty text like no value: both land in the null group, "" never appears as a head.
- Without measures in the input a view's
config.groups.measures {field_id: sum|avg|min|max|count}apply, each under its field key (measures: []asks for none). - order value (default) sorts the heads by value and pages them with next_cursor (limit up to 500); order count returns the largest groups, at most 200, without paging (value pickers). group_values refreshes known heads (up to 200, null = rows without a value); the page then holds them all (limit rises to their number) and has no next_cursor.
- include_totals adds
totals {rows, measures}over all filtered rows, on the first page of the top level only. - Values are decimal strings. A money measure over several currencies returns value null and mixed true; otherwise currency names the currency.
- An append-only type grouped by entry_key pages its entries newest first; each head carries entry {number, effective_on, source, reverses_key, reversed_by}.
- The rows of one group: records.rows.query with
group: {"field": "<group key>", "value": <head value>}(null for the empty group). Each group pages with its own cursor; the filter tree is not the way to pick a group. - With view_key the sent filter is ANDed with the view's filter; view_filter "replace" (records.rows.query and records.rows.aggregate) uses the sent filter instead, while the view still supplies its group, levels, measures, period and balance.
Levels: a view's config.groups.levels (field ids, at most 2) nests its
heads. The first level is group_by_field_id; prefix_lengths on it (a text
field; 1 to 6 ascending lengths of 1-30, e.g. [1, 2, 4, 6] for class, group,
account and subaccount) folds the values into heads per code prefix. The
second level, a reference field or a relation to one record (e.g. the third
party), splits each value of the first. The levels apply when
records.rows.aggregate groups by the first level (the default with view_key)
and order is value; parent and depth need them.
- Each head carries
tree {token, kind, children, depth}. kind is prefix (a prefix with longer values below), value (a value of the first level, also a code that already ends on a level such as 511580, or 11 when 11 is itself a code) or sub (second level); depth 0 is the top level. - children heads: send the token as
parentto read the heads one level below (they page with their own cursor; totals only come on the top level). children rows: read them with records.rows.query and group, plussub_group {field, value}for a sub head. The token is opaque: take it from a head, never build it; a token that does not fit fails with invalid_field_value on parent. - Without parent the heads are the top level: the first prefix length, or the values without prefix lengths.
depth: n(without parent) returns all heads down to tree.depth n in preorder, each head followed by its children, paged with next_cursor; the same heads and numbers as opening every head level by level. Prefix values sort byte-wise (collation "C"), so a prefix comes before its extensions. n is at most the number of prefix lengths, plus 1 with a second level.- group_values picks heads of the level parent reads (the top level without parent), e.g. prefixes, to refresh them.
- A prefix head takes its label from the target row whose code is the prefix, without the reference rule's require (parent accounts are not postable); a sub head takes the title of its own target.
- Older clients:
ledger_node({level, prefix?}, {prefix}, {account}) is an alias of parent, and heads of a view with a balance still carry the stringnode(prefix, account, sub_group); both are deprecated.
Periods
A period is an object in local days of time_zone (IANA, default UTC):
{"preset": "this_month"} with this_month, last_month, this_quarter,
last_quarter, this_year or last_year covers the whole calendar period, also its
days after today (this_month = the 1st to the last day); {"preset": "last_n_days", "days": 30} ends today; {"preset": "custom", "from": "2026-01-01", "to": "2026-03-31"} takes inclusive ISO days, at most 3650.
Results echo the resolved window {from, to} (inclusive).
A view's config.period {field_id (a date or datetime field), default (a period, e.g. {preset: this_month}), applies_to: rows|metrics} names the field
the view reads by period and the period the app starts with.
- applies_to rows: records.rows.query and records.rows.aggregate with view_key
take
period(and time_zone) and keep only the rows whose period field lies in it, for rows, heads, totals and depth; aggregate echoes window. - applies_to metrics: period is ignored for rows and heads; it only frames the view's metrics.
- A period on a view without config.period (or without view_key) fails with invalid_field_value on period. A view with a balance takes its period on the balance date field (section Balances).
Comparisons (kpi charts with compare, read_docs("records_charts")): a running calendar period compares the days elapsed so far with as many days from the start of the previous period, capped at its end (30 March against all of February); a closed calendar period compares with the whole previous one; last_n_days and custom with as many days right before. previous_count 0 means no change can be computed.
Balances
A view whose config has a balance is an account sheet; its kind then reads
ledger (kind is derived, sending it is optional; sending kind: "grid" drops
the balance). All entries are field ids, not keys: config.balance {date_field_id, increase_field_id, decrease_field_id, tiebreak_field_id?, direction}; config.groups.levels[0] is the account (a text field with
exactly one reference rule or a relation to one record) and config.period
names the balance date field. Date is a required date or datetime field,
increase and decrease are number fields (one of them may stay empty per row:
net is increase - decrease with empty = 0). direction.mode is
increase_minus_decrease (default), decrease_minus_increase, or field: then
direction.field_id is a single_select or boolean field of the account's record
type and invert_when lists the option keys (or true) that flip the sign. The
account's current value applies to its whole history; without account row or
value the balances are null (sign unknown). A view whose configuration no
longer fits the schema reads as grid with config_issues (path, message,
severity error or warning, scope); capabilities tells what the view allows
(a view with a balance keeps its order and grouping and forbids filters on its
date field).
- Heads: records.rows.aggregate with view_key and period (required). Each head, at every level, carries ledger {opening, increase, decrease, closing, sign}: opening is the balance before the period, closing after it; heads without movement in the period and without opening balance drop out. A sub head takes the sign of its account. totals carry only the period's increase and decrease, no total balance.
- Rows of one account: records.rows.query with view_key, group (the head value), optionally sub_group (a sub head), and period. Rows come in date, tiebreak, id order with computed.balance, the running balance after the row (per account, or per account and sub value); every page sums the balance before it in the same statement, so a cursor stays valid when rows are added and always shows the current balances. sort is ignored.
- Without group and period the view reads flat like any view (its filter and sort, no computed.balance). period without group fails with ledger_needs_group; group without period with invalid_field_value on period. Filters on the date field are rejected (invalid_filter): the period selects the dates.
totals.checks [{kind: balanced, fields: [field, against], ok}](any view, with include_totals) compares each balanced rule of an append-only type whose two fields are summed: as sum measures or as the balance's increase and decrease. The comparison is exact; mixed or different currencies are never ok.- Agents that only need numbers can use records.sql or rows.aggregate on any view; guests never see views with a balance.
The older form, kind: "ledger" with config.ledger {date_field_id, increase_field_id, decrease_field_id, tiebreak_field_id?, direction, levels?, sub_group_field_id?} grouped by group_by_field_id, is still accepted and
stored as balance, groups.levels (levels become the prefix lengths,
sub_group_field_id the second level), period and pinned columns; views also
return it as config.ledger while the balance is valid.
Libro mayor (general ledger by PUC code with third parties), records.views.create:
{
"record_type_id": "<movimientos uuid>",
"idempotency_key": "libro-mayor-1",
"key": "libro_mayor",
"name": "Libro mayor",
"group_by_field_id": "<cuenta>",
"config": {
"version": 2,
"balance": {
"date_field_id": "<fecha>",
"increase_field_id": "<debito>",
"decrease_field_id": "<credito>",
"tiebreak_field_id": "<entry_key>",
"direction": {"mode": "field", "field_id": "<naturaleza de cuentas>",
"invert_when": ["credito"]}
},
"groups": {
"expanded": "none",
"levels": [{"field_id": "<cuenta>", "prefix_lengths": [1, 2, 4, 6]},
{"field_id": "<tercero>"}]
},
"period": {"field_id": "<fecha>", "default": {"preset": "this_month"}},
"columns": {"pinned": ["opening", "<debito>", "<credito>", "balance"]}
}
}Inventario con saldo corrido (stock per product, the running balance is the quantity on hand):
{
"record_type_id": "<movimientos de inventario uuid>",
"idempotency_key": "inventario-saldo-1",
"key": "inventario",
"name": "Inventario con saldo corrido",
"group_by_field_id": "<producto>",
"config": {
"version": 2,
"balance": {
"date_field_id": "<fecha>",
"increase_field_id": "<entrada>",
"decrease_field_id": "<salida>",
"tiebreak_field_id": "<entry_key>"
},
"groups": {"levels": [{"field_id": "<producto>"}]},
"period": {"field_id": "<fecha>", "default": {"preset": "this_year"}},
"columns": {"pinned": ["opening", "<entrada>", "<salida>", "balance"]}
}
}Pinned columns
config.columns.pinned lists up to 20 columns the app fixes after the title,
in order: field ids, and with a balance the computed opening and closing
(a head's balance before and after the period) and balance (the running
balance after a row). A pinned field that is no longer active, or a
computed column without balance, comes back as a warning in config_issues and
is left out. Pinning only changes the display; reads are unchanged.
config.columns.hidden hides computed columns of a balance: opening,
balance and closing. Other ids, or any id without a balance, come back as
a warning and are left out. Fields are shown or hidden with
visible_field_ids.
SQL
records.sql runs one read-only PostgreSQL SELECT and returns columns plus rows; the database joins and aggregates, so a comparison across several types is one call. Naming, exactly as records.schema lists it:
- Tables are the type keys (
invoices). Every table has id, title, revision, created_at and updated_at plus one column per stored field key; archived records are never included. - money is two columns,
total(numeric) andtotal_currency; multi_select is a text[] ('tag' = ANY(tags), orunnest(tags)); single_select holds the option key; dates are date or timestamptz. - A record_relation field has no column in its type's table. Its links are
the table
<source type>__<source field>with source_id and target_id, named after the field records.relationships.create added; the reverse field reads the same table from target_id. Invoices with their customer:SELECT i.title, c.title AS customer FROM invoices i JOIN invoices__customer ic ON ic.source_id = i.id JOIN customers c ON c.id = ic.target_id. A document_relation field is the table<type>__<field>with record_id and document_id. - Only built-in functions and scalar types work (aggregates, window, string, date, math,
JSON,
coalesce, casts to text/numeric/date/uuid/jsonb and arrays of them). Catalog functions, row-type orregclasscasts and column-only aliases are rejected. - lookup and count fields have no column;
computedin records.schema names the relation table and target column to join. - A Space that files partner objects also has
partners_objects(with my_role, local_ref, my_status of the own party, parent_id),partners_entries(the entries the own party may see,dataas jsonb,own, author_name) andpartners_obligations(what roles owe each other: kind, debtor_role, creditor_role, my_role, state, due_at, quantity, unit, settled_quantity); records.schema lists them underpartner_tables(read_docs("partners")).
Limits: 10 s per statement, 100 rows by
default and 1000 at most; has_more: true means rows were cut,
so aggregate, filter or page with ORDER BY and OFFSET. invalid_sql names the
unknown table or column and lists the valid ones (for a relation field the
hint names its link table); sql_timeout asks for a
narrower query.
Saved views
records.views.create (record_type_id, key, name) and records.views.update
take filter (the filter tree), sort, visible_field_ids, column_widths, group_by_field_id, kind, config,
position and is_default; personal: true makes a view only its owner sees.
visible_field_idsare field ids, not keys, and their order is the column order left to right. The position of a field in the schema only decides the order when the list is empty, which shows every active field. The web app always draws the title field first, wherever it is in the list, and skips ids of fields that are no longer active. Sending the list replaces it whole; unknown ids fail with invalid_field_value.configreplaces the whole configuration (omitted = unchanged).config.summaryis the total row the app draws under the view: {field_id: sum|avg|min|max|count|none}; sum, avg, min and max need a number or money field, count works on any stored field. To read such totals, call records.rows.aggregate with include_totals.config.groups{expanded: all|none, levels, initial_open_depth 0-6, measures}: section Groups and levels;config.period: section Periods;config.balance(and the olderconfig.ledger): section Balances;config.columns.pinnedandconfig.columns.hidden: section Pinned columns. Warnings come back in config_issues; errors refuse the write.
Updating and archiving
data.write updates, archives and restores records; read_docs("data") has the
entries, the conditions and the write mode. In short: a type on strict (the
default) needs the revision last read in if.revision for every change, a
type on merge only for archive, restore and set_links. if.schema_version
fails with schema_changed when the type was published again; call
records.types.describe again. Archiving is reversible with restore;
{"archive": {"unlink_relations": true}} drops all links of the record as
well (restore does not bring them back). records.rows.restore_revision brings
back an older revision as a new one.
Human decisions: records.rows.bulk_import and records.rows.archive_many run in the chat only after the user approves the card; MCP clients and routine or workflow runs get 403 human_only for them. Permanent deletion (records.types.purge, records.rows.purge) and snapshot restores stay with the user in the app.
Conversions: publishing a field type change first stores a PRE_CONVERSION snapshot (records.snapshots.list); preview it with records.fields.convert_preview. A publish that converts a field of a type with more than 100000 rows answers {"queued": true, "job_id": ...}; poll records.jobs.get until the status is SUCCEEDED or FAILED.
Type kinds
records.types.create takes kind: standard (default), append_only or
decision_table. The kind never changes; kind_config belongs to the draft
and is published with the type. Platform fields of a kind are locked
(config.locked): they cannot be trashed, renamed or retyped.
append_only: rows are immutable and arrive as whole entries (below).kind_config:effective_date_field(a required date field),constraints(positive,distinct,unique,unique_per_entry,referenceto a unique text field of a standard type, optionally only where a boolean field is true,balanced) andreversal(swapfield pairs,setboolean fields to true, false or"toggle", which flips the value and turns null into true,keyswith a suffix) andnumbering(below). These rules are enforced by the database,balancedwhen an entry is appended. Once the type has rows its schema is frozen except for new optional fields, labels andreversalandnumbering(type_frozen); config.reference, config.technical and display stay changeable. No relation, document, lookup or count fields. Fill entries with derivations (read_docs("derivations")) and aggregate them with summaries (read_docs("summaries")).decision_table: rows are rules withrule_key,valid_from,valid_to,priority,enabled,supersedesandsource; read_docs("rules").
Append-only types and entries
A type created with kind: "append_only" keeps rows that never change: no
update, archive, purge, import or undo. Rows arrive only as whole entries
through records.entries.append: up to 500 rows written atomically under one
entry_key, for example the two stock movements of a transfer. The platform
writes entry_key into every row; leave it out of values.
- Every row of an entry carries the same date in
kind_config.effective_date_field;effective_on, when given, must match (entry_date_mismatch). {"kind": "balanced", "field": "debit", "against": "credit", "per": "ledger"}makes the sum offieldequal the sum ofagainstover the rows of one entry; withoutagainstthe sum offieldis zero. Both are number or money fields of one type; money balances per currency, and the optionalper(a text or single_select field) balances each of its values on its own. Empty values count as zero. A broken entry fails with entry_unbalanced, details.issues lists the difference per group. There is no tolerance: book a rounding difference as its own row. Reversals are not checked.- Repeating an entry_key with the same rows and the same
sourcereturns the existing entry withcreated: false; other rows or another source fail with entry_conflict. Pick keys that are stable per source event. - Correct a mistake with records.entries.reverse: it appends the mirror image
under
<entry_key>#reverseoneffective_on, usingkind_config.reversal(swap paired fields, set flags, suffix unique keys). An entry is reversed once; a reversal cannot be reversed. Then append the corrected entry under a new key. kind_config.numbering{"field": "voucher", "series_field": "series"}numbers entries like an accounting system: an entry that leavesfieldempty and names a series inseries_field(text or single_select, the same on every row) gets the next number of that series and year,<series>-<year>-0001, written intofieldof every row and returned asentry.number. Numbers are drawn when the entry is appended and never change; replaying the entry returns the same number. An entry that brings its ownfieldvalue keeps it. A reversal of a numbered entry draws its own number from the same series.- records.locks.set closes the type through a date; afterwards no row may be dated on or before it (entry_locked). The date only moves forward.
- records.entries.reset empties a type whose periods were never closed (no lock date): rows and entries go, the type, its derivations and summaries stay. Derivations writing into it lose their traces and jobs, so derivations.run_pending books every source again. Numbering restarts. After the first lock it fails with entry_locked.
- Reversing and locking run after the user confirms them in the chat.
- Read entries with records.entries.list and records.entries.get, and rows as usual with records.rows.query or records.sql.
- Rows point at other records by value: a
referencerule for a reference every row must have (checked, blocks changes on the target), config.reference for cross references such as the document a line settles (resolved when reading, never blocks, addable while the type has rows). Section Display and references. - Routine runs with the type in their record scope get records_entries_append, records_entries_list and records_entries_get; a rehearsal checks the entry (values, date, balanced) without writing. Reversing and locking stay with people.
Import from a file
For many rows (invoices exported from a system, a migration) do not send them as arguments: upload a JSONL file into the Space (documents.upload_initiate, documents.upload_url, PUT the bytes, documents.upload_confirm) and call records.imports.create with record_type_id, document_id and merge_on. Each line is one JSON object: {"values": {...}, "relations": {...}, "documents": {...}, "expected_revision": n}; relations take record ids or natural keys such as {"code": "C-001"} (a unique field, the fields of one unique key or the title field of the target type; it must match exactly one active record). A line that updates an existing record of a strict type needs expected_revision; types filled by imports and sync scripts belong on write_mode merge. At most 50000 lines and 50 MB per file; empty lines are skipped.
What a line does:
- Without merge_on every line creates a new record, nothing is matched (a re-run duplicates). With merge_on (field keys; the fields of one unique key work best) the line finds the active record with the same key values and updates it, or creates it when none exists. A merge_on value must be present and non-null in every line and appear once per block of 200 lines. An archived match fails (archived_match) unless restore_archived is true, which restores it and applies the line.
- Values are merged: a field absent from
valueskeeps its stored value, a field present is overwritten, an explicit null clears it. A new record needs its required fields in the line. relationsanddocumentsREPLACE per field: the list given for a field becomes its whole target list (add = send old plus new ids, remove = leave them out, [] clears it). Fields not named there keep their links. There is no append mode in an import; to add one target to existing links use data.write withlink.- A line that changes nothing counts as updated in the counters (matched by merge_on), and writes no revision.
- Relations replace without a revision check in an import on a merge type, while data.write set_links always needs the exact revision.
The import runs in the background: call records.imports.get with wait_seconds (at most 30) until SUCCEEDED or FAILED; records.imports.list lists the imports of a Space, newest first. Always run it with dry_run true first; the dry run reads the whole file and lists errors as {line, path, code, message} (first 50, errors_total counts all). Applying (dry_run false) requires a SUCCEEDED dry run with errors_total 0 for the same document, merge_on and restore_archived, else import_requires_dry_run. Rows are written in atomic blocks of 200; all blocks share one change_set_id. If a block fails, the import ends FAILED with the line, the blocks before it stay written and next_line tells where it stopped; repeat as a new import with merge_on so the written rows are updated, not duplicated. Dry-run counters are exact only with errors_total 0: matches between blocks of the same file count as created.
Errors and fixes
- append_only_type: the type only takes whole entries; use records.entries.append, and records.entries.reverse to correct.
- entry_locked: the row date is on or before the lock date (records.locks.get); date the entry later.
- entry_unbalanced: a
balancedconstraint fails; details.issues names the field, group, currency and difference. Add the missing row. - reference_invalid, reference_in_use, constraint_violation: details names
the field and rule of
kind_configthat the row or change breaks. - type_frozen, field_locked, kind_config_invalid: the change would break the kind's rules; details.issues lists each one.
- invalid_field_value: details.field names the value. A reserved key lists details.reserved, a malformed key shows details.pattern. Pick another key.
- validation_error from records.types.create or records.fields.add_many:
details maps each invalid entry (for example
fields[3].key) to its problem. Nothing was created; fix those entries and send the whole call again. - draft_revision_conflict: the draft changed since you read it. details.draft_revision is the current value; re-read with records.types.get if needed and retry with it.
- record_type_not_published: the type is still a draft. Run records.types.publish_preview, then records.types.publish.
- schema_incompatible on publish: blocked changes remain; details.changes lists them (the approval card shows them as publish_blocked). Fix the draft and publish again.
- conflict from data.write (revision_conflict from the other row operations): details.current carries the current row; decide again and retry with its revision.
- base_required: the write needs the revision last read; see the write mode in read_docs("data").
- unknown_field: call records.types.describe for the current keys.
- invalid_relation_target "allows a single target": the field is single-valued and got a second link; "is already linked to another record": the target may be linked from one record only and already is. Replace links with set_links, or change the cardinality (section Relations).
- import_requires_dry_run: run the same import with dry_run true first; the dry run must be error-free and match document, merge_on and restore_archived.
- ledger_needs_group: records.rows.query on a view with a balance got period without group; pass group (one account from records.rows.aggregate) or drop period to read the view flat.
- query_timeout: the query ran too long; narrow filter, q or period, or group by another field.
- required_field_missing, unique_violation, invalid_filter, invalid_cursor, record_archived and limit_exceeded name the field, filter or limit; unique_violation lists all fields of a unique key in details.fields.
Example
Create a type with three fields:
{
"operation_key": "records.types.create",
"arguments": {
"space_id": "<space uuid>",
"idempotency_key": "invoice-type-create-1",
"name": "Invoice",
"plural_name": "Invoices",
"key": "invoice",
"fields": [
{"key": "code", "label": "Code", "type": "text", "unique": true},
{"key": "total", "label": "Total", "type": "money",
"config": {"currency_default": "COP", "precision": 2}},
{"key": "status", "label": "Status", "type": "single_select",
"config": {"options": [
{"id": "open", "key": "open", "label": "Open"},
{"id": "paid", "key": "paid", "label": "Paid"}
]}}
]
}
}After records.types.publish_preview and records.types.publish, write rows:
{
"operation_key": "data.write",
"arguments": {
"space_id": "<space uuid>",
"idempotency_key": "invoice-upsert-0042-0043",
"ops": [
{"record": {"type": "invoice", "key": {"code": "inv_0042"}},
"upsert": {"name": "INV-0042",
"total": {"amount": "1250000.00", "currency": "COP"},
"status": "open"}},
{"record": {"type": "invoice", "key": {"code": "inv_0043"}},
"upsert": {"name": "INV-0043",
"total": {"amount": "98000.00"}, "status": "paid"}}
]
}
}A second run of the same call updates the two records; on a strict type that
needs their revision in if.revision.