Row history
Row history is an append-only log of every insert, update and delete on the tables you choose: the row’s primary key, the old and new values, the user who made the change and the request it came from. It is opt-in per table, because every write to an audited table costs one extra insert.
Turn it on
Section titled “Turn it on”In the dashboard open a table and choose the History tab, then Turn on history. Or in SQL, as the table owner (the SQL editor works; the anon, authenticated and service_role API roles cannot):
select base.enable_audit('public.orders');select base.enable_audit('public.users_private', array['password_hash', 'api_token']); -- never store these columnsselect base.disable_audit('public.orders');- The table needs a primary key, otherwise a row cannot be identified and the call fails. You cannot exclude a primary-key column.
- Excluded columns are never written to the log. Leave out tokens, hashes and large blobs.
- The
audit,auth,baseandpg_*schemas cannot be audited.
What is recorded
Section titled “What is recorded”| Column | Meaning |
|---|---|
id, ts, txid |
order, time and database transaction. All changes of one transaction share the txid |
schema_name, table_name, pk |
the row, as JSON (for example {"id": "..."}) |
op |
INSERT, UPDATE or DELETE |
old_data, new_data |
insert: the whole new row. Delete: the whole old row. Update: only the changed columns, in both |
actor_id, actor_role |
the sub of the JWT (when it is a uuid) and its role. A secret key shows service_role and no actor_id |
claims |
only the claims in an allow-list (default tenant_id, org_id, app_role), so email addresses are not copied |
request_id |
the x-request-id of the API request |
An update that changes nothing, or only excluded columns, writes nothing. When the primary key itself changes, pk holds the new key and the old one is in old_data. The log cannot be edited or deleted by SQL users; only the retention function below removes old rows.
Read it
Section titled “Read it”The dashboard’s History tab shows a table’s log. In a data grid, select exactly one row and choose History to see only that row. Programmatically, with a secret key (server side only), use the SDK:
// the history of one row, newest firstconst { data: changes, error } = await admin.history.forRow("orders", { id: orderId })
// a table, filtered; 50 entries by default (1 to 1000)const page = await admin.history.list({ table: "orders", // "orders" means public.orders; use "app.orders" for another schema op: ["UPDATE", "DELETE"], actorId: userId, // the JWT sub that made the change since: new Date("2026-10-01"), // ts >= since until: "2026-10-15T00:00:00Z", // ts < until limit: 100,})// next page: pass the last id you gotconst older = await admin.history.list({ table: "orders", before: page.data.at(-1).id })Entries are AuditEntry objects with the columns of the table above. history.list also takes pk, requestId and order: "asc". Calls resolve to { data, error } and never throw; bad input is rejected before any request (error.code is history_invalid). Turning history on is not an SDK call: use the dashboard or base.enable_audit(...) as the table owner. Or call the REST view yourself:
curl -s "$BASE_URL/rest/v1/base_audit_log?table_name=eq.orders&pk=eq.%7B%22id%22%3A%22<uuid>%22%7D&order=id.desc&limit=50" \ -H "apikey: $SECRET_KEY" -H "Authorization: Bearer $SECRET_KEY"Retention
Section titled “Retention”Old rows are removed by audit.purge(older_than, batch), which you call yourself; it deletes up to batch rows (default 10000) and returns the count, so call it until it returns 0. Run it from a scheduled job. The default age is the database setting base.audit_retention_days (90; 0 keeps everything), with a minimum of one hour. Only service_role can run it.
Limits
Section titled “Limits”- Every write to an audited table adds one insert and a diff. Audit what you need, and exclude wide columns.
TRUNCATEand changes made withsession_replication_role = replica(some restore and replication tools) are not recorded.- The log is a single table; there is no partitioning yet.
- Time-travel reads (
as_of) have their own limits, see below.
Read the past (as_of)
Section titled “Read the past (as_of)”Time-travel rebuilds a table as it was at a moment, from the history above. Turn it on per table, after history is on:
select base.enable_audit('public.orders');select base.enable_as_of('public.orders'); -- creates public.base_as_of_orders(p_as_of)select base.disable_as_of('public.orders');Then read with the same Data API and the same filters, select, order and limit:
curl -s "$BASE_URL/rest/v1/orders?as_of=2026-10-22T10:00:00Z&status=eq.open&select=id,total" -H "apikey: $KEY" -H "Authorization: Bearer $USER_JWT"const { data } = await client.from("orders").select("id,total").eq("status", "open").asOf(new Date("2026-10-22T10:00:00Z"))- Row-level security of today applies. A signed-in user gets only the rows they can read now, with their values at that moment. Rows deleted since then are not returned to end users (the policy cannot say whose a deleted row was). The secret key (
service_role) also gets the rows deleted since. - Only
GETandHEAD. The moment must be in the past, after history was turned on for the table (since), withinbase.audit_retention_days(90) and withinbase.as_of_max_age_days(30;0= retention only). Otherwise the call fails with an explanatory 400. - Columns you excluded from history come back
null. A column added after the moment shows its current value. If a primary key was changed after the moment, or the table was renamed or moved to another schema, oraudit.purgealready removed history from before the moment, the call fails (400) instead of returning wrong rows; after a rename runbase.enable_audit(...)again (history restarts). Partitioned tables are not supported. Embedded resources (select=*,other(*)) show today’s rows. Write the moment withZor a UTC offset (a value without one is read in the database time zone). - The filters run after the rebuild, so a table with more than
base.as_of_max_rows(50000) readable rows is refused. Narrow the table or raise the setting. - A table without
base.enable_as_ofanswers 404PGRST202(function not found). Tables whose history started before this feature must runbase.enable_audit(...)again once to record a start time. - The
base_as_of_<table>function depends on the table’s row type: runbase.disable_as_of(ordisable_audit) before dropping the table. - Point-in-time recovery of a whole database is a separate, Cloud-only feature.