Skip to the page

Learn · Logic

Notifications & webhooks

Receive HMAC-signed webhooks when matching writes commit, or stream policy-filtered changes in commit order from the change log.

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.

dbschema/default.gel
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 webhook deliveries

Post-commit triggers send HMAC-signed pings or ordered row batches to your HTTPS endpoints.

Napalm sends four delivery kinds depending on how the webhook is configured and triggered.

KindSent whenBody
pingA 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.
rowsThe 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.
gapThe change log can no longer replay commits due for a rows webhook.BodyA gap object replaces transactions, and delivery continues from position.
testA manager sends a test from the console or CLI.Bodykind, event, branch, time, test: true. A test does not move the webhook’s position.
A ping delivery
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"}
A rows delivery body
{"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"}}]}]}
HeaderMeaning
Napalm-EventName of the notify trigger. A rows delivery lists every event watched by the webhook, separated by commas.
Napalm-DeliveryThe delivery’s id, unchanged across retries.
Napalm-Signaturesha256= followed by the hex HMAC-SHA256 of the raw body under the webhook’s signing secret.
Napalm-PositionAn 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 raw request bytes with your signing secret and compare the digest to Napalm-Signature in constant time before parsing JSON. Napalm shows the secret once when the webhook is added.
Acknowledge fast
Any 2xx accepts the delivery, and Napalm never reads the response body. Respond first and do the work in a background job.
Retries
Failed pings retry after 10 seconds, doubling up to 5 minutes for up to one hour. Row deliveries retry from the webhook’s saved position while those commits remain in the change log.
Ordering
Pings arrive in any order, while row deliveries arrive in commit order with one request in flight per webhook.
Deduplication
Deduplicate pings by Napalm-Delivery, which stays constant across retries, and deduplicate row deliveries by Napalm-Position.
Forward compatibility
Ignore body keys and kind values 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 so search indexes, analytics pipelines and caches 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.

Ordered change log

Clients page committed transactions from a saved cursor under caller read policies.

Start from an RFC 3339 timestamp on the first read, then pass each page’s next bookmark as after on subsequent requests.

GET/changes

Query parameters

afterstring
Reading resumes after this bookmark (next from the previous page, or any item’s bookmark). Use after or since.
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 reports is_reached. See Live tailing below.
Request · curl
curl "https://notes.napalmdata.com/changes?after=nbm_0192c3f4_7c3f1a&types=Note&limit=100" \  -H "Authorization: Bearer $NAPALM_KEY"
Response
{  "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, bigint values, enum values and json fields. A link to one object is that object’s id.
Without a notify
A type that no notify watches keeps less of each change. An update can leave out a large unchanged value, and a delete carries only the id.
previous
For an update to a type that a notify watches, 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 (link or property). The row carries the element added, removed or updated.
has_every_row
False for a transaction too large to read row by row. The transaction lists the changed types instead, 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. Each ping signals that a watched type committed and carries the causal Napalm-Position bookmark on the change log.

Ordered commits

Every committed transaction appends an immutable entry to the branch change log.

Causal bookmarks

Saved cursors resume log reads and keep replica queries caught up.

Webhook pings

Signed post-commit pings wake your worker with the latest commit position.

Pass Napalm-Position as reach when reading from your saved cursor. The response waits up to 30 seconds if needed and sets is_reached once the log advances to that position.

Request · curl
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 modeReturned rows
everyNo rule denies a read, and a rule allows reads unconditionally (or the type has no rules). Every row arrives with all values.
uncheckedThe branch applies no access rules, so every row arrives.
checkedEach 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.
noneThe caller may not read the type, or the type does not exist. No rows of the type arrive.

For checked types, Napalm evaluates visibility when the change is read rather than at commit time. Rows hidden after the commit are omitted, while rows revealed after the commit arrive with their values from that commit.

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 kindCause
expiredThe stretch is older than the branch’s change-log retention. The reader fell too far behind.
unrecordedThe changes never reached the log.
lostA failover removed commits the previous primary had acknowledged.
movedThe 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, page the change log with changes and advance next automatically until reach is satisfied. See webhooks and the change log in the TypeScript SDK.

app/hooks/napalm/route.ts
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 })} // Inside the background worker, read changes from the saved cursor up to the ping 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.

Terminal
napalm changes notes --since 1hnapalm webhooks add notes https://hooks.example.com/napalm --event note_changednapalm webhooks deliveries notes

An agent reads the same pages under the same rules with MCP’s read_changes tool or an A2A changes data part. See MCP server.

Type a word or two to search every docs page.