Webhooks
Webhooks are HTTP callbacks that allow your applications to receive real-time notifications when specific events occur. In the context of SQLite Cloud, webhooks make it easy to build reactive systems by automatically sending notifications when data changes happen within your databases.
Real-Time Notifications for Database Writes
Use the Webhooks panel to effortlessly create real-time notifications for write operations—such as inserts, updates, or deletes—within your SQLite Cloud database.
For example, you can configure SQLite Cloud to notify a webhook.site endpoint every time a write operation occurs on the albums
table of the chinook.sqlite
database.
Change Data Capture
Change Data Webhooks let you send structured HTTP requests to any external service whenever a row in a specific database and/or table is modified. These webhooks include:
- Database name
- Table name
- Operation type (insert, update, delete)
- Changed row data
This enables seamless integration with logging systems, monitoring dashboards, or external APIs that react to database activity.
Payload Fields
{
"type": "insert",
"database": "chinook.sqlite",
"table": "albums",
"column": [
"AlbumId"
],
"data": [
349
],
"webhook": {
"id": 1,
"action": "https://webhook.site/70792a3c-2a18-4a48-9ded-df1c90e758ce",
"options": {
"type": "url"
}
}
}
- type – The operation type (
insert
,update
, ordelete
). - database – The name of the database where the change occurred.
- table – The table affected by the operation.
- column – An array listing the column(s) involved in the operation.
- data – The values corresponding to the affected row(s).
- webhook – Metadata about the webhook itself, including its unique
id
, targetaction
(URL or Edge Function), and configurationoptions
.
Security
Upon creation, each webhook is assigned a secret key used to verify the authenticity of incoming requests.
Trigger Edge Functions
Webhooks in SQLite Cloud aren’t limited to data capture—they can also trigger Edge Functions:
- Via HTTP or WebSocket
- In response to database write events
Within an Edge Function, the webhook payload containing the Change Data Capture information is directly accessible through the request.data
variable, which is available by default in all Edge Functions.
// Get secret from database
const slackWebhookEndpoint = await connection.sql`GET ENV slack_webhook_endpoint`;
// Get record sent in body via webhook
const content = request.data;
// Define helpers to assign and notify
const notifyRep = async ( ) => {
await fetch(slackWebhookEndpoint, { body: JSON.stringify({ text: "Discover the Latest Album Releases" + JSON.stringify(request.data)}), method: 'POST', 'Content-type': 'application/json' });
}
// Call async functions
await notifyRep();
return {
data: 'OK'
}
This allows developers to build distributed, event-driven applications that react immediately to changes at the edge.