Released docs. You are viewing the documentation published with v0.34.0. Development docs are available at Latest.
Send registry events to a webhook
For the data publisher
This tutorial uses the maintained Base Registry Engine (BReg) business demo and the receiver supervised by
bregctl dev. You will read the event declaration, create a record, and inspect
the value-redacted delivery receipt.
Start the demo receiver
Section titled “Start the demo receiver”From the Registry Stack checkout, run:
products/breg/demo/run.sh --webhookThe launcher creates a disposable project under products/breg/demo/.run,
starts PostgreSQL, the stock ThunderID issuer, Base Registry Engine, and the
loopback receiver. Leave it running in this terminal.
Read the declaration
Section titled “Read the declaration”In another terminal:
webhook_run="$PWD/products/breg/demo/.run"grep -A20 '^ hooks:' \ "$webhook_run/project/modules/business-establishment-summary/module.yaml"The operating-created-v1 event selects the establishment entity, the created
trigger, and the projected establishment-code and operating-status values.
The compiled destination binding, retry policy, and disclosure can be inspected
without opening runtime secrets:
bregctl explain events "$webhook_run/project"Cause a delivery
Section titled “Cause a delivery”Acquire a fresh token through the retained dev session and copy its protected header file:
umask 077bregctl --format json dev token business-demo "$webhook_run/project" \ > tutorial-work/webhook-token.jsonpython3 -c 'import json,shutil,sys; shutil.copyfile(json.load(open(sys.argv[1]))["headerFile"], sys.argv[2])' \ tutorial-work/webhook-token.json tutorial-work/webhook-authorization.headerchmod 600 tutorial-work/webhook-authorization.headerCreate an operating establishment:
webhook_url=$(cat "$webhook_run/breg-origin")curl --silent --show-error --fail-with-body \ --header @tutorial-work/webhook-authorization.header \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: tutorial-establishment-9' \ --data '{"data":{"establishmentCode":"ESTABLISHMENT-TUTORIAL-009","siteName":"North Quay Annex","establishmentKind":"warehouse","operatingStatus":"operating"}}' \ --output tutorial-work/establishment.json --write-out 'HTTP %{http_code}\n' \ "$webhook_url/v1/records/establishments?accessProfile=business-operator"The response is 201. Delivery runs after the transaction commits, so allow a
few seconds before reading the receiver report.
Inspect the receipt
Section titled “Inspect the receipt”bregctl --format json dev events "$webhook_run/project" \ > tutorial-work/webhook-events.jsonpython3 -m json.tool tutorial-work/webhook-events.jsonThe report identifies the compiled event and destination, generation, attempt,
and receipt time. Payloads are omitted unless you explicitly add
--include-payload. A receipt means the receiver accepted that attempt. Operated
deployments inspect pending and dead-letter work through the separate webhook
operations described in Operate BReg webhooks.
Stop the demo
Section titled “Stop the demo”Press Ctrl+C in the first terminal. A successful run removes its owned dev
session. An interrupted or failed run retains .run/ for diagnosis. Stop that
owned session before removing the directory and retrying.
Keep tutorial-work/webhook-authorization.header out of support messages. The
checkout ignores it, but it remains a bearer credential until it expires.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Next move |
|---|---|
A request returns 401 | Rerun bregctl dev token business-demo "$webhook_run/project" while the demo remains active and copy the new headerFile. |
| The new receipt is not visible yet | Wait a few seconds and rerun bregctl dev events. |
| The launcher stops before its ready line | Read the bounded diagnostics it prints. Preserve the failed .run/ directory until you have diagnosed the owned session. |
- Author a registry project to declare events on your own entities.
- Operate BReg webhooks to configure operated destinations, retry limits, and dead-letter recovery.
- Base Registry Engine API reference for the delivery contract a receiver validates and deduplicates.