Declare a Postgres table in the records deploy phase and the platform gives you, with no backend code: validated REST CRUD (+ bulk + aggregate + count), composite field types, full-text search, row/column RBAC, soft delete, live SSE updates, record.* workflow triggers, an audit spine with actor provenance and English event summaries, gipity records CLI CRUD, and auto-generated table/form UI components.

One write path. Every write - REST, the gipity records CLI, a function's records service, workflow record steps and records llm-step tool, bulk import - flows through the same validation + audit + event pipeline. A raw db.query() INSERT from a function skips validation and audit (no field checks, no history entry, no actor); it still reaches the live stream and fires record.* workflow triggers, because the platform captures every change to a declared table in the database itself. In a function, use the injected records service when any of those matter: records.list/get/create/update/remove/history(table, ...), gated by the function's tables: list (writes are audited as FUNCTION, attributed by function name).

Declaring tables (gipity.yaml)

- name: records
  type: records          # AFTER the database phase - tables must exist
  tables:
    - table: deals
      auth_level: user   # public (anyone, signed out too, reads AND writes) | user (any signed-in caller) | member (default: owner + project members only; others get 403)
      searchable: true   # full-text search over text columns (q= param)
      auto_number: { prefix: DEAL }   # optional: new rows get DEAL0001001, DEAL0001002, ... (pad: 7, column: number by default)
      # append_only: true  # optional, ONE-WAY: rows can be added, never changed or deleted (see below)
      fields:
        - { name: name, type: text, required: true, title: true }
        - { name: stage, type: select, options: { values: [Lead, Proposal, Won, Lost] } }
        - { name: value, type: currency, label: Deal value }
        - { name: owner_id, type: relation, label: Owner, options: { table: people, display: full_name } }
        - { name: notes, type: textarea, section: Details, help: Internal notes }

With auth_level: user and no row policies, every signed-in caller can read, update and delete every row. For per-user data, add row policies (gipity rbac) or write through a function that filters on ctx.auth.userGuid.

Field metadata is optional per column - declared fields are coerced + validated on every write with self-correcting errors ('stage' must be one of: Lead, Proposal, Won, Lost (got 'Wonn')); undeclared columns pass through and Postgres validates them.

Types: text, textarea, number, boolean, date (YYYY-MM-DD), select, tags (list of short values on a plain TEXT column - send ["party","co-op"] or a string, stored/returned as "party, co-op", so ilike filters, q= search and sort all just work; options: {values} restricts them), json (objects only), and composites stored as JSONB in your column: currency {amountMicros, currencyCode} (accepts a plain number), name {firstName, lastName} (accepts "Ada Lovelace"), emails/phones/links (accept a bare string), address. relation describes an existing FK column (options: {table, display}); the value stays the raw id and Postgres enforces integrity.

Per-field keys: label, required (enforced on create), title (names the record in audit summaries), hide/section/help (drive generated UIs; order = declaration order).

Append-only tables (append_only: true) accept inserts and nothing else, for everyone, the owner included: the Records API answers 403 to update, delete, soft delete, ?purge=1, restore and bulk update/delete, and the database itself refuses UPDATE, DELETE and TRUNCATE from a function's db.query() or a migration. A migration also can't drop the table, drop or retype its columns, rename it, or remove the guard; adding a column is fine. Use it for command logs, ledgers and audit trails. It is one-way: once deployed, every later deploy must keep append_only: true (leaving it out fails the deploy), it can't be combined with soft_delete_column, and gipity records config <t> --append-only turns it on without a deploy but nothing turns it off. Dropping the whole database (gipity db drop) or deleting the account still removes it, and gipity db restore can't roll it back (restoring would rewrite it). gipity test writes to a throwaway copy without the database guard, but Records API calls in tests still get the 403.

Postgres VIEWs can be declared too - they get the full read API (list/filter/sort/aggregate) and render in the UI components read-only. The Records API refuses every write to a view (400); write to the base table instead.

Table schema (the migration side)

The table itself is a plain migrations/NNN-*.sql CREATE TABLE; Records layers onto whatever columns it finds. Only three columns are special, all optional:

CREATE TABLE IF NOT EXISTS deals (
  id          BIGSERIAL PRIMARY KEY,
  name        TEXT NOT NULL,
  stage       TEXT,
  created_at  TIMESTAMPTZ DEFAULT NOW(),
  updated_at  TIMESTAMPTZ DEFAULT NOW(),  -- bumped by Records on update; no trigger
  deleted_at  TIMESTAMPTZ               -- soft_delete_column: deleted_at
);

REST API

Base: https://a.gipity.ai/api/<PROJECT_GUID> - auth via X-App-Token (+ session cookie for user/member), or X-Api-Key.

From the browser, don't call these by hand - gipity.js mints the token for you and Gipity.records.* mirrors the endpoints below one-for-one, returning the unwrapped data: list(t, params) → {rows, total} · get(t, id) · create(t, data) · update(t, id, data) · remove(t, id, {purge}) · restore(t, id) · count(t, params) (a string is the filter) · aggregate(t, params) · schema(t) · history(t, id) · tableHistory(t) · comments(t, id) · addComment(t, id, text, {internal}) · createMany(t, rows) · stream(t, {onChange, filter}) → {stop()} · views.list/save/update/remove. params are the query params below (filter, any, sort, limit, offset, fields, q, include_deleted, only_deleted).

Live change stream (SSE)

GET /records/<t>/stream (Accept: text/event-stream; same auth as the REST API, X-Api-Key works for a device; filter=, any= and fields= narrow it). Events:

A device that must never miss a command: keep the last id: it processed on disk, reconnect with it after any drop, and on reset re-read the pending commands with GET /records/<t>?filter=.... Pair it with an append-only table so the command log can't be edited after the fact. In Python, the registry's gipity_device client does all of this (client.subscribe(table, on_event, cursor_file=..., on_reset=...): heartbeat timeout, reconnect with backoff, Last-Event-ID resume, a cursor file that survives restarts, and omitted rows fetched by id); see examples/python for a full device walkthrough.

Provenance + English audit history

Every write records WHO (user), and HOW: source = MANUAL (signed-in user) / API (API key, attributed by key name) / FUNCTION (a function's records service, attributed by function name) / WORKFLOW (record steps, attributed by workflow name) / FORM (anonymous public-table write) / IMPORT (any write with ?source=import). Each event carries a one-line English summary derived from field labels - deal-won-followup created deal task "Follow up: Acme won" - so /history is prompt-ready: an AI brief over a record (or a whole table) is one LLM call over the event stream, not a RAG project. CLI: gipity records history <table> [id] (omit the id for the table-wide feed). History payloads are de-identified (a display-name actor, never DB ids); the whole-table feed is owner/editor only (per-record history follows the table's read auth).

Workflows

record.after_insert/update/delete triggers fire on Records API writes only. A workflow record step writes through the same path, so its writes are validated, audited (WORKFLOW provenance), and can chain further triggers (depth-capped). See workflow.

From the CLI

gipity records tables (the configured tables) / list <table> (rows: -q, --filter, --sort, --only-deleted) / get <table> <id> / create <table> / update <table> <id> / delete <table> <id> / restore <table> <id> / history <table> [id] - same write path as the REST API, with provenance and self-correcting errors. gipity records config <table> --auth <level> changes a table's exposure without a redeploy, --append-only makes it append-only for good, and --auto-number <prefix> (--auto-number-pad, --auto-number-column, none to turn off) its numbering; for a table declared in gipity.yaml, the next deploy puts back the declared auth_level and auto_number, so change them there to keep them.

Auto-generated UI (Gipity Views)

Load after the client SDK and get ServiceNow-style list + form for free:

<script defer src="https://media.gipity.ai/client/v1/gipity.js" data-app="<PROJECT_GUID>"></script>  <!-- your project guid: gipity project info -->
<script defer src="https://media.gipity.ai/views/v1/gipity-views.js"></script>

<gipity-records table="deals" live></gipity-records>

<gipity-records> = table + "New" button + slide-over form. Or compose <gipity-table> (sort, per-column filter chips, search, pagination, CSV export, SSE live updates, composite-aware cells, relation display + typeahead) and <gipity-record-form> (type-appropriate widgets, sections, inline self-correcting validation errors, history pane with provenance, comments pane when the app has a comments table) yourself. Columns and widgets come from the field metadata, with live-introspection fallback for undeclared tables. Theme with --gv-* CSS variables. On a user or member table the components wait for sign-in: a signed-out visitor sees "Sign in to see these records." and no requests are made, and the component loads itself on sign-in, so put it on the page as-is (no mount-after-login code).

Drag-and-drop board: <gipity-kanban table="deals" group-by="stage" metric="amount" live> - one column per value of a declared select field, cards drag between them, and the drop is a normal validated + audited write that fires record.after_update. Same filter/sort attributes as the table, so "flip this list into a board" is a second element, never hand-written drag code. Add an integer position column to persist manual card order. <gipity-saved-views table="deals" target="deals-list"> saves and re-applies any of these components' filter+sort state as platform data (no app table).

Common mistakes