Learn · Logic
Notifications & webhooks
Get a signed webhook when matching writes commit, or read every committed change in order from the change log.
- API
GET /changes- In the schema
- —
Schema notify triggers#
Add a notify declaration to any object type in dbschema/default.gel to emit a named event strictly after insert, update or delete commits on that type. Rolled-back transactions emit nothing, and notify adds zero external network latency to your SQL commit path.
type Order { required buyer: ext::auth::Identity; required status: OrderStatus; # Emits the "order_changed" event only after the transaction commits notify order_changed after insert, update, delete;}After pushing the schema, subscribe one or more HTTPS webhook endpoints to order_changed via napalm webhooks add, the web console or the Control API. Types watched by notify also capture previous field values on updates in GET /changes.
Webhook deliveries#
A webhook subscribes an HTTPS endpoint to one or more schema notify triggers. Every delivery shares one envelope contract, so a receiver built for pings handles row deliveries by reading one additional field.
Signed outbound deliveries
Schema notify triggers fire strictly after commit, launching HMAC-SHA256 sealed ping or commit-ordered rows capsules to allowed hosts with causal Napalm-Position bookmarks.
| Kind | Sent when | Body |
|---|---|---|
ping | A write to a watched type commits. One delivery covers every such write since the last delivery. | Bodyevent, branch, types, time, position. No ids, no values and no kind field. |
rows | The webhook was added with a service key. Each delivery carries the next stretch of the change log that the key can read. | Bodykind, event, branch, position and transactions shaped like GET /changes items. |
gap | The change log cannot replay a stretch a rows webhook was due. | BodyThe gap in place of transactions. Reading continues from position. |
test | A manager sends a test from the console or CLI. | Bodykind, event, branch, time, test: true. A test does not move the webhook’s position. |
POST /hooks/napalm HTTP/1.1Content-Type: application/jsonNapalm-Event: note_changedNapalm-Delivery: 0192c3f4-6b1a-7d8e-9f00-1a2b3c4d5e6fNapalm-Position: nbm_0192c3f4_9b2e4dNapalm-Signature: sha256=5d41402abc4b2a76b9719d911017c592… {"event":"note_changed","branch":"main","types":["default::Note"], "time":"2026-11-10T08:00:00.000000+00:00","position":"nbm_0192c3f4_9b2e4d"}{"kind":"rows","event":"note_changed","branch":"main","position":"nbm_0192c3f4_9b2e4d", "transactions":[{"bookmark":"nbm_0192c3f4_9b2e4d","commit_time":"2026-11-10T08:00:00+00:00", "caller":{"kind":"session","via":"http"},"has_every_row":true, "rows":[{"type":"default::Note","op":"update","id":"8f2c1e64-…", "fields":{"id":"8f2c1e64-…","title":"Q4","done":true},"previous":{"title":"Q3"}}]}]}| Header | Meaning |
|---|---|
Napalm-Event | The notify’s name. A rows delivery lists every event the webhook follows, separated by commas. |
Napalm-Delivery | The delivery’s id, unchanged across retries. |
Napalm-Signature | sha256= followed by the hex HMAC-SHA256 of the raw body under the webhook’s signing secret. |
Napalm-Position | An opaque bookmark. On a ping, at or past every write the ping covers. On a rows delivery, at the last transaction. Absent on a test. |
A rows delivery carries up to 100 transactions or 1 MiB and never splits a transaction. Rows webhooks read from the change log, so the project’s cluster must keep a change log. Warehouse sync builds a worker that pages GET /changes, and Search index & cache sync builds a route that receives rows deliveries directly.
Verification and acknowledgment#
Verify the HMAC over the raw request bytes before parsing JSON, and acknowledge with a 2xx response as soon as the delivery is queued or applied.
- Verify first
- Compute the HMAC-SHA256 of the request body’s raw bytes with the signing secret. Compare the digest to
Napalm-Signaturein constant time before parsing. The secret is shown only when the webhook is added. - Acknowledge fast
- Any
2xxaccepts the delivery, and Napalm never reads the response body. Respond first and do the work in a background job. - Retries
- A failed ping is retried after 10 seconds. The wait doubles up to 5 minutes, and retries stop after one hour. Rows are retried from the webhook’s position for as long as the change log keeps those rows.
- Ordering
- Pings arrive in no particular order. Rows arrive in commit order. Each webhook has one rows delivery in flight at a time.
- Deduplication
- Deduplicate pings on
Napalm-Delivery. A retry keeps the same value. Deduplicate rows onNapalm-Position. - Forward compatibility
- Ignore body keys and
kindvalues you do not recognize. Napalm only ever adds keys.
The change log#
GET /changes returns committed transactions from the branch’s change log in commit order, letting a search index, analytics pipeline or cache stay synchronized without an external CDC connector. Every row carries the type, operation, object id and committed field values, while caller reports the caller kind and source without exposing a personal identity.
Commit-ordered change log and bookmarks
GET /changes streams committed transaction blocks in order along a causal Napalm-Bookmark cursor, enforcing caller access rules per type and marking unreplayable stretches with explicit gap items.
GET/changes
Query parameters
- afterstring
- Reading resumes after this bookmark (
nextfrom the previous page, or any item’sbookmark). Useafterorsince. - sincestring
- An RFC 3339 start time for a read with no bookmark yet.
- untilstring
- Optional upper-bound RFC 3339 timestamp.
- typesstring
- Comma-separated object type names (such as
Note,shop::Order). Required when schema sharing is disabled. - limitinteger
- Maximum transactions per page (1 to 1,000, default 100).
- reachstring
- The position where the read ends, such as a webhook’s
Napalm-Position. The page reportsis_reached. See Live tailing below.
curl "https://notes.napalmdata.com/changes?after=nbm_0192c3f4_7c3f1a&types=Note&limit=100" \ -H "Authorization: Bearer $NAPALM_KEY"{ "items": [ { "bookmark": "nbm_0192c3f4_9b2e4d", "commit_time": "2026-11-10T08:00:00+00:00", "caller": { "kind": "session", "via": "http" }, "has_every_row": true, "names_as_of": "commit", "rows": [ { "type": "default::Note", "op": "update", "id": "8f2c1e64-0b7a-4f4e-9d2b-3a6c5e1f7d90", "fields": { "id": "8f2c1e64-…", "title": "Q4", "done": true }, "previous": { "title": "Q3" } } ] } ], "next": "nbm_0192c3f4_9b2e4d", "is_caught_up": true, "access": { "default::Note": "checked" }}fields- The object’s values after an insert or update, or before a delete. Keys are the field names in the schema at commit time.
- Value types
- Booleans, integers and floats are JSON values. Every other value is text in PostgreSQL’s format, including datetimes, decimals,
bigintvalues, enum values andjsonfields. A link to one object is that object’sid. - Without a notify
- A type that no
notifywatches keeps less of each change. An update can leave out a large unchanged value, and a delete carries only theid. previous- For an update to a type that a
notifywatches, the prior values of the changed fields. link- Rows of a multi link, a multi property or a link with properties name that link or property (
linkorproperty). The row carries the elementadded,removedorupdated. has_every_row- False for a transaction too large to read row by row. The transaction lists the changed
typesinstead, so re-read those types in full.
The change log does not yet cover a branch spread across multiple shards. Reading on a multi-shard branch answers 409 branch_distributed, and rows webhooks cannot be attached to that branch. Use the change log and rows webhooks on single-shard branches.
The change log is kept per cluster. A project whose cluster keeps no change log answers 409 change_log_not_configured. A caller restricted to deployed queries by passthrough is refused because GET /changes reads outside deployed queries.
Live tailing#
A ping webhook and reach together tail the log with no polling loop and no open connection between writes. A ping signals that a watched type committed and carries the causal Napalm-Position bookmark on the commit log. Pass Napalm-Position as reach while reading from your saved cursor, and the response reports is_reached once the log advances past that position, waiting up to 30 seconds if needed.
Ordered commit block
Each finalized SQL transaction appends an immutable entry in commit order to the branch’s GET /changes history.
Resumable causal bookmark
Opaque after, next and Napalm-Position bookmarks resume GET /changes tails and route replica reads past every covered commit.
HMAC-signed notify capsule
Post-commit notify webhooks send Napalm-Signature HMAC-SHA256 sealed ping or rows payloads carrying Napalm-Position.
curl "https://notes.napalmdata.com/changes?after=$CURSOR&reach=$NAPALM_POSITION&types=Note" \ -H "Authorization: Bearer $NAPALM_KEY"The same position works anywhere a causal bookmark is accepted. Send Napalm-Position as Napalm-Bookmark on POST /query so woken worker reads see every write covered by the ping even when routed to a replica.
Access policies on changes#
The stream never returns rows the caller cannot read, and each page’s access map reports how every requested type was evaluated.
| Access | What the caller receives |
|---|---|
every | No rule denies a read, and a rule allows reads unconditionally (or the type has no rules). Every row arrives with all values. |
unchecked | The branch applies no access rules, so every row arrives. |
checked | Each row is re-read as the caller when the page is served. Visible rows arrive with the committed values, and hidden rows are omitted. A delete arrives as the id alone. |
none | The caller may not read the type, or the type does not exist. No rows of the type arrive. |
For checked types, visibility is evaluated when a change is read, not at commit time. A row hidden since the commit is omitted. A row revealed since the commit arrives with the older values.
Cursors and gaps#
Every page returns next, an opaque bookmark to pass back as after, and sets is_caught_up to true once the page holds everything written so far. Save next only after you apply the page. Delivery is at least once, so a crash between applying and saving replays the page instead of skipping ahead. Deduplicate on each item’s bookmark.
When the log cannot replay a stretch of history, the page inserts a gap item in place instead of skipping silently. Reading continues after the gap so a consumer can distinguish lost history from slow reading and resynchronize cleanly.
| Gap kind | Cause |
|---|---|
expired | The stretch is older than the branch’s change-log retention. The reader fell too far behind. |
unrecorded | The changes never reached the log. |
lost | A failover removed commits the previous primary had acknowledged. |
moved | The branch moved to another shard or was created again. |
Client SDKs and the CLI#
napalm-client and Dart’s napalm_client verify deliveries with readDelivery and page the change log with changes, advancing next automatically until reach is satisfied. See webhooks and the change log in the TypeScript SDK.
import { NapalmClient, isGap, readDelivery } from 'napalm-client' const napalm = new NapalmClient('https://notes.napalmdata.com', { token: serviceKey }) export async function POST(request: Request) { // Verify the signature over the raw bytes before parsing anything. const delivery = await readDelivery(await request.arrayBuffer(), request.headers, signingSecret) if (delivery.kind === 'ping') queue.add({ position: delivery.position }) return new Response(null, { status: 204 })} // In the job the ping woke: read the log from the saved cursor up to the ping's position.for await (const page of napalm.changes({ types: ['Note'], after: cursor, reach: job.position })) { for (const item of page.items) isGap(item) ? await resync(item.gap) : await index.apply(item.rows) if (page.next) cursor = await saveCursor(page.next)}Managers can summarize recent transactions without exposing row values or manage webhooks from the terminal.
napalm changes notes --since 1hnapalm webhooks add notes https://hooks.example.com/napalm --event note_changednapalm webhooks deliveries notesAn agent reads the same pages under the same rules with MCP’s read_changes tool or an A2A changes data part. See MCP server.