/

Loading...
Receive real-time notifications when events happen in your DataChonk projects.
Webhooks allow you to build integrations that subscribe to events in DataChonk. When an event occurs, we'll send an HTTP POST request to your configured URL with details about the event.
Events delivered within seconds
Automatic retries on failure
Signed payloads for verification
| Event | Description |
|---|---|
chonk.created | A new chonk was created |
chonk.updated | A chonk's configuration was updated |
chonk.deleted | A chonk was deleted |
generation.started | Code generation began |
generation.completed | Code generation finished successfully |
generation.failed | Code generation encountered an error |
scan.completed | Schema scan finished |
push.completed | Code was pushed to Git repository |
Configure webhooks in your project settings or via the API:
curl -X POST https://api.datachonk.io/v1/webhooks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-server.com/webhooks/datachonk",
"events": ["generation.completed", "push.completed"],
"secret": "your-webhook-secret"
}'All webhook payloads follow a consistent structure:
{
"id": "evt_abc123",
"event": "generation.completed",
"created_at": "2024-01-15T10:30:00Z",
"project_id": "proj_xyz789",
"data": {
"chonk_id": "chonk_456",
"chonk_name": "dim_customers",
"chonk_type": "entity",
"files_generated": [
{
"path": "models/marts/core/dim_customers.sql",
"lines": 45
},
{
"path": "models/marts/core/_core__models.yml",
"lines": 28
}
],
"duration_ms": 1234
}
}All webhooks include a signature header for verification. Always verify signatures in production to ensure requests come from DataChonk.
import crypto from 'crypto';
function verifyWebhookSignature(
payload: string,
signature: string,
secret: string
): boolean {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(`sha256=${expectedSignature}`)
);
}
// In your webhook handler
app.post('/webhooks/datachonk', (req, res) => {
const signature = req.headers['x-datachonk-signature'];
const isValid = verifyWebhookSignature(
JSON.stringify(req.body),
signature,
process.env.WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).json({ error: 'Invalid signature' });
}
// Process the webhook...
const { event, data } = req.body;
switch (event) {
case 'generation.completed':
console.log(`Generated ${data.files_generated.length} files`);
break;
// Handle other events...
}
res.status(200).json({ received: true });
});