# Webhooks and the change feed

A webhook is a change feed on one base: record writes append numbered payloads, read back by cursor, and a refresh sets its expiration a week out.

A webhook records the changes made to one base as numbered payloads, so a client can read what changed since its last cursor. Load a scenario with an empty table, create a webhook on it and create a record:

```bash
H='Authorization: Bearer pat.placeholder'
J='Content-Type: application/json'
B=appBlnk0000000001
T=tblBlnk0000000001
curl -s -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"airtable_blank_schema"}'
curl -s -X POST "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" -H "$J" -d "{\"specification\":{\"options\":{\"filters\":{\"dataTypes\":[\"tableData\"],\"recordChangeScope\":\"$T\"}}}}" | jq -c '{id, expires: .expirationTime[:10]}'
# -> {"id":"ach00000000000001","expires":"2026-03-09"}
W=ach00000000000001
curl -s -X POST "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"fields":{"Name":"Acme"}}' | jq -c '{id, fields}'
# -> {"id":"rec00000000000001","fields":{"Name":"Acme"}}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads" -H "$H" | jq -c '{cursor, mightHaveMore, payloadFormat, created: [.payloads[].changedTablesById[$T].createdRecordsById | keys[]]}' --arg T "$T"
# -> {"cursor":2,"mightHaveMore":false,"payloadFormat":"v0","created":["rec00000000000001"]}
```

The webhook needs no `notificationUrl`: payloads append whether or not one is set. Its `expirationTime` is seven days after it was created, on the simulator's clock.

### Choose what a webhook watches

The `specification.options.filters` object decides which writes reach a webhook:

| Filter | Payloads it receives |
|---|---|
| `dataTypes` includes `tableData`, no `recordChangeScope` | record writes to any table of the base |
| `dataTypes` includes `tableData`, `recordChangeScope` is a table id | record writes to that table only |
| `dataTypes` without `tableData`, such as `["tableFields"]` | no record writes |

[Test filters and writes that append nothing](#test-filters-and-writes-that-append-nothing) shows each row.

### Read payloads by cursor

A webhook you create numbers its payloads from 1, and `cursorForNextPayload` on the webhook list names the number the next one gets. Update the record, then read from cursor 2:

```bash
curl -s -X PATCH "$RYSTIC_URL/v0/$B/$T/rec00000000000001" -H "$H" -H "$J" -d '{"fields":{"Name":"Acme Co"}}' | jq -c .fields
# -> {"Name":"Acme Co"}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[] | {id, cursorForNextPayload}]'
# -> [{"id":"ach00000000000001","cursorForNextPayload":3}]
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=2" -H "$H" | jq -c '{cursor, changed: .payloads[0].changedTablesById[$T].changedRecordsById}' --arg T "$T"
# -> {"cursor":3,"changed":{"rec00000000000001":{"current":{"cellValuesByFieldId":{"fldBlnk0000000001":"Acme Co"}}}}}
```

A read with no `cursor` starts at the webhook's first payload. A webhook a scenario seeds starts at its seeded `cursorForNextPayload`, and a lower cursor reads from there, as no cursor does ([Seeded webhooks](#test-seeded-webhooks)). The response's `cursor` is the one to send next. With `limit`, a page has at most that many payloads, and `mightHaveMore` is `true` while more follow:

```bash
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?limit=1" -H "$H" | jq -c '{cursor, mightHaveMore, n: (.payloads | length)}'
# -> {"cursor":2,"mightHaveMore":true,"n":1}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=99" -H "$H" | jq -c '{cursor, payloads}'
# -> {"cursor":99,"payloads":[]}
```

A cursor past the last payload returns 200 with no payloads and the same `cursor`.

### Test which writes append a payload

A write appends one payload per request, its records grouped under `changedTablesById`, and `baseTransactionNumber` rises with each payload. Create two records in one request, then replace one of them with PUT and update, replace and delete it in batches:

```bash
curl -s -X POST "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"records":[{"fields":{"Name":"Birch"}},{"fields":{"Name":"Cedar"}}]}' | jq -c '[.records[].id]'
# -> ["rec00000000000002","rec00000000000003"]
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=3" -H "$H" | jq -c '[.payloads[] | {baseTransactionNumber, created: (.changedTablesById[$T].createdRecordsById | keys)}]' --arg T "$T"
# -> [{"baseTransactionNumber":3,"created":["rec00000000000002","rec00000000000003"]}]
curl -s -X PUT "$RYSTIC_URL/v0/$B/$T/rec00000000000002" -H "$H" -H "$J" -d '{"fields":{"Name":"Birch Ltd"}}' | jq -c .fields
# -> {"Name":"Birch Ltd"}
curl -s -X PATCH "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"records":[{"id":"rec00000000000002","fields":{"Name":"Birch Inc"}}]}' | jq -c '[.records[].fields]'
# -> [{"Name":"Birch Inc"}]
curl -s -X PUT "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"records":[{"id":"rec00000000000002","fields":{"Name":"Birch"}}]}' | jq -c '[.records[].fields]'
# -> [{"Name":"Birch"}]
curl -s -g -X DELETE "$RYSTIC_URL/v0/$B/$T?records[]=rec00000000000002" -H "$H" | jq -c .
# -> {"records":[{"deleted":true,"id":"rec00000000000002"}]}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=4" -H "$H" | jq -c '[.payloads[].changedTablesById[$T] | keys[0]]' --arg T "$T"
# -> ["changedRecordsById","changedRecordsById","changedRecordsById","destroyedRecordIds"]
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[].cursorForNextPayload]'
# -> [8]
```

| Write | Payload |
|---|---|
| `POST /v0/{baseId}/{tableIdOrName}`, one record or a batch | one payload, under `createdRecordsById` |
| `PATCH /v0/{baseId}/{tableIdOrName}/{recordId}` | one payload, under `changedRecordsById` |
| `DELETE /v0/{baseId}/{tableIdOrName}/{recordId}` | one payload, under `destroyedRecordIds` |
| `PUT /v0/{baseId}/{tableIdOrName}/{recordId}` | one payload, under `changedRecordsById` |
| batch `PATCH` or `PUT` on `/v0/{baseId}/{tableIdOrName}` | one payload, every changed record under `changedRecordsById` |
| batch `DELETE` on `/v0/{baseId}/{tableIdOrName}` | one payload, every deleted id under `destroyedRecordIds` |
| an update that changes no cell, such as `PATCH` with `{"fields": {}}` | none |
| `POST /v0/{baseId}/{recordId}/{attachmentFieldIdOrName}/uploadAttachment` | none |
| field and table changes | none |

An update payload includes only the cells whose value changed, and a cell the request cleared reads `null`. Update record 3 without changing it, then clear its `Name` with PUT. The read lists one payload, the PUT's:

```bash
curl -s -X PATCH "$RYSTIC_URL/v0/$B/$T/rec00000000000003" -H "$H" -H "$J" -d '{"fields":{"Name":"Cedar"}}' | jq -c .fields
# -> {"Name":"Cedar"}
curl -s -X PUT "$RYSTIC_URL/v0/$B/$T/rec00000000000003" -H "$H" -H "$J" -d '{"fields":{}}' | jq -c .fields
# -> {}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=8" -H "$H" | jq -c '[.payloads[].changedTablesById[$T].changedRecordsById]' --arg T "$T"
# -> [{"rec00000000000003":{"current":{"cellValuesByFieldId":{"fldBlnk0000000001":null}}}}]
```

**Differs from Airtable:** an attachment upload and a schema change append no payload.

Delete a record and read its payload:

```bash
curl -s -X DELETE "$RYSTIC_URL/v0/$B/$T/rec00000000000003" -H "$H" | jq -c .
# -> {"deleted":true,"id":"rec00000000000003"}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=9" -H "$H" | jq -c '[.payloads[] | {baseTransactionNumber, destroyed: .changedTablesById[$T].destroyedRecordIds}]' --arg T "$T"
# -> [{"baseTransactionNumber":9,"destroyed":["rec00000000000003"]}]
```

### Keep a webhook active

Refreshing a webhook sets its `expirationTime` to seven days after the call. Reading its payloads does the same when it has an `expirationTime`. Move the clock a day on and refresh:

```bash
curl -s -X POST "$RYSTIC_URL/_rystic/clock" -d '{"advance_seconds":86400}' > /dev/null
curl -s -X POST "$RYSTIC_URL/v0/bases/$B/webhooks/$W/refresh" -H "$H" | jq -c '.expirationTime[:10]'
# -> "2026-03-10"
curl -s -X POST "$RYSTIC_URL/_rystic/clock" -d '{"advance_seconds":86400}' > /dev/null
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks/$W/payloads?cursor=10" -H "$H" > /dev/null
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[].expirationTime[:10]]'
# -> ["2026-03-11"]
```

Moving the clock past `expirationTime` leaves the webhook active:

```bash
curl -s -X POST "$RYSTIC_URL/_rystic/clock" -d '{"advance_seconds":864000}' > /dev/null
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[] | {isHookEnabled, expires: .expirationTime[:10]}]'
# -> [{"isHookEnabled":true,"expires":"2026-03-11"}]
```

**Differs from Airtable:** a webhook never expires: `isHookEnabled` stays `true` after `expirationTime` passes.

### Turn notifications off and delete a webhook

`enableNotifications` sets `areNotificationsEnabled`, and payloads keep appending either way:

```bash
curl -s -X POST "$RYSTIC_URL/v0/bases/$B/webhooks/$W/enableNotifications" -H "$H" -H "$J" -d '{"enable":false}'
# -> {}
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[] | {areNotificationsEnabled, lastNotificationResult}]'
# -> [{"areNotificationsEnabled":false,"lastNotificationResult":null}]
curl -s -X POST "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"fields":{"Name":"Dune"}}' | jq -c .id
# -> "rec00000000000004"
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[].cursorForNextPayload]'
# -> [11]
curl -s -X DELETE "$RYSTIC_URL/v0/bases/$B/webhooks/$W" -H "$H"
# -> {}
curl -s -o /dev/null -w '%{http_code}\n' -X DELETE "$RYSTIC_URL/v0/bases/$B/webhooks/$W" -H "$H"
# -> 404
```

**Differs from Airtable:** the simulator sends no notification pings, so `lastNotificationResult` stays `null` on a webhook you create. Poll the payloads route instead. The `airtable_webhook_desk` scenario seeds webhooks whose `lastNotificationResult` shows a success, a failure with a retry pending and notifications turned off.

### Test filters and writes that append nothing

Create one webhook per filter row, then add and rename a table, add an attachment field and upload a file. Only the record writes after that append payloads:

```bash
mk() { curl -s -X POST "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" -H "$J" -d "{\"specification\":{\"options\":{\"filters\":$1}}}" | jq -r .id; }
mk "{\"dataTypes\":[\"tableData\"],\"recordChangeScope\":\"$T\"}"
# -> ach00000000000002
mk '{"dataTypes":["tableData"]}'
# -> ach00000000000003
mk '{"dataTypes":["tableFields"]}'
# -> ach00000000000004
curl -s -X POST "$RYSTIC_URL/v0/meta/bases/$B/tables" -H "$H" -H "$J" -d '{"name":"Orders","fields":[{"name":"Name","type":"singleLineText"}]}' | jq -c .id
# -> "tbl00000000000001"
curl -s -X PATCH "$RYSTIC_URL/v0/meta/bases/$B/tables/tbl00000000000001" -H "$H" -H "$J" -d '{"name":"Orders 2026"}' | jq -c .name
# -> "Orders 2026"
curl -s -X POST "$RYSTIC_URL/v0/meta/bases/$B/tables/$T/fields" -H "$H" -H "$J" -d '{"name":"Logo","type":"multipleAttachments"}' | jq -c .name
# -> "Logo"
curl -s -X POST "$RYSTIC_URL/v0/$B/rec00000000000001/Logo/uploadAttachment" -H "$H" -H "$J" -d '{"contentType":"text/plain","file":"aGVsbG8=","filename":"a.txt"}' | jq -c .id
# -> "rec00000000000001"
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[].cursorForNextPayload]'
# -> [1,1,1]
curl -s -X POST "$RYSTIC_URL/v0/$B/$T" -H "$H" -H "$J" -d '{"fields":{"Name":"Elm"}}' > /dev/null
curl -s -X POST "$RYSTIC_URL/v0/$B/tbl00000000000001" -H "$H" -H "$J" -d '{"fields":{"Name":"A-1"}}' > /dev/null
curl -s "$RYSTIC_URL/v0/bases/$B/webhooks" -H "$H" | jq -c '[.webhooks[] | {id, cursorForNextPayload}]'
# -> [{"id":"ach00000000000002","cursorForNextPayload":2},{"id":"ach00000000000003","cursorForNextPayload":3},{"id":"ach00000000000004","cursorForNextPayload":1}]
```

### Test seeded webhooks

The `airtable_webhook_desk` scenario seeds four webhooks in different states, the fourth one lapsed with `isHookEnabled` `false`. Load it, create an order, read the first webhook from cursor 1 and refresh the lapsed one:

```bash
curl -s -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"airtable_webhook_desk"}'
D=appHook0000000001
curl -s -X POST "$RYSTIC_URL/v0/$D/tblHook0000000001" -H "$H" -H "$J" -d '{"fields":{"Order number":"A-100"}}' | jq -c .fields
# -> {"Order number":"A-100"}
curl -s "$RYSTIC_URL/v0/bases/$D/webhooks/achHook0000000001/payloads?cursor=1" -H "$H" | jq -c '{cursor, n: (.payloads | length)}'
# -> {"cursor":15,"n":1}
curl -s -X POST "$RYSTIC_URL/v0/bases/$D/webhooks/achHook0000000004/refresh" -H "$H" | jq -c '.expirationTime[:10]'
# -> "2026-03-09"
curl -s "$RYSTIC_URL/v0/bases/$D/webhooks" -H "$H" | jq -c '[.webhooks[] | {id, isHookEnabled}][3]'
# -> {"id":"achHook0000000004","isHookEnabled":false}
```

The lapsed webhook accepts the refresh and keeps `isHookEnabled` `false` (unconfirmed: a lapsed Airtable webhook has not been refreshed to compare).

---

Source: https://www.rystic.ai/docs/simulators/airtable/features/change-feed · Markdown: https://www.rystic.ai/docs/simulators/airtable/features/change-feed.md
