Tutorial: Building with CleaveDB
Webhooks for CDC
In event-driven architectures, downstream systems (such as search indexes, notification dispatchers, cache invalidators, and third-party APIs) must react to database writes in real time. Rather than running cumbersome Kafka or Debezium clusters, CleaveDB provides native Change Data Capture (CDC) via HTTP Webhooks.
Configuring a webhook
Register an automated event hook on any bucket using the SHAPE WEBHOOK command:
SHAPE WEBHOOK "user_created" ON users WHEN action = "POUR" POST TO "https://api.example.com/hooks"Whenever a new document enters the users bucket via POUR, CleaveDB dispatches an HTTP POST request containing the event metadata and document payload.
Supported lifecycle actions
Webhooks can listen to any phase of the document lifecycle:
| Action | Trigger Event | Use Case |
|---|---|---|
| POUR | New document inserted | Send welcome emails, initialize profile caches |
| CHANGE | Fields modified or updated | Sync inventory, notify billing services |
| DRAIN | Document moved to rubbish bin | Purge user storage, invalidate session tokens |
Auditing registered webhooks
Inspect all active webhook listeners across your buckets using SHOW WEBHOOKS:
SHOW WEBHOOKSReturns an array containing each listener's name, target bucket, subscribed action type, and remote destination URL.
HTTP payload format
CleaveDB transmits standard JSON payloads directly to your endpoint:
{
"event": "POUR",
"bucket": "users",
"id": "u42",
"data": {
"name": "Jordan Lee",
"tier": "enterprise"
},
"timestamp": 1728561230,
"tenant": "default"
}The tenant key automatically inherits the current authenticated user context from AUTHENTICATE AS.
