Released docs. You are viewing the documentation published with v0.46.0. Development docs are available at Latest.
Send registry events to a webhook
For the data publisher
In about fifteen minutes your registry will tell another system each time a contact is created: the event declared, a contact added, and the signed delivery read back from a local receiver.
Declare the event
Section titled “Declare the event”In the project directory, ask which events the registry sends today:
rstack breg explain events .Event deliveries: No event deliveries declared.None: a registry sends nothing until a Record type declares it. Open registry.yaml and add a
hooks list to the contact Record type, right after its mutationMode line:
mutationMode: mutablehooks: - id: contact-created-v1 phase: after trigger: created projection: [name] handler: type: url destinationId: contact-eventsThe hook fires once a new contact is committed. Its projection lets only name leave the
registry. contact-events is a destination name, not an address: an operator binds it to a URL,
and the local registry binds it to a receiver of its own.
Check the project and ask again:
rstack breg check .rstack breg explain events .Event deliveries: events.contact.contact-created-v1.webhook phase after handler type url destination contact-events projected fields nameCreate a contact
Section titled “Create a contact”Start the registry with the hook in place:
rstack breg dev startwebhook receiver http://127.0.0.1:<port>/eventsevents file <project-dir>/.breg/dev/events.jsonlThe receiver verifies each delivery’s signature before it keeps it, in .breg/dev/events.jsonl.
That file holds projected values, so use test records only. Add the test contact again:
rstack breg examples run contactThe registry commits the contact first, then delivers the event from its own queue.
Read the delivery
Section titled “Read the delivery”rstack breg --format json dev events{ "deliveryId": "events.contact.contact-created-v1.webhook", "destinationId": "contact-events", "eventType": "contact-created-v1", "attempt": 1, "status": "received"}"status": "received" means the receiver verified the signature and kept the first attempt. The
report leaves out the projected name; add --include-payload to see it.
If deliveries is empty, the first delivery has not arrived yet or the registry is still
retrying; run the command again after a few seconds. On a deployed registry,
rstack breg hook list shows the deliveries still waiting or failed, as
Bind webhook receivers describes.
The local receiver proves only that an attempt arrived. A real receiving service stores each
event before acting on it. A retry resends an event with the same idempotencyKey; an operator
replay resends it with the same eventId and a new key. Check both before acting.
When you are finished, rstack breg dev stop --remove stops the registry and deletes its test data.
Serve a lookup to Evidence, or run a registry for real with Deploy and serve.
Cookies on Registry Stack
We use optional cookies to understand how you use the main Registry Stack website and this documentation. If you contact us, we may link this activity to your enquiry. You can change your choice at any time. Read the privacy policy.
Your browser asks sites not to track you, so optional tracking stays off.
We could not use or save that choice. Optional tracking remains off.