Back to Documentation
CLI & API
Webhooks
Receive real-time notifications when events happen on your sites. Integrate with your CI/CD pipeline.
1Create a Webhook
Set up webhooks to receive event notifications:
- Go to Site Settings > Webhooks
- Click "Add Webhook"
- Enter your webhook URL (must be HTTPS)
- Select which events to receive
- Click "Create Webhook"
A secret key is generated for signature verification.
2Available Events
Subscribe to these events:
deployment.created
New deployment started
deployment.succeeded
Deployment completed successfully
deployment.failed
Deployment failed
domain.added
Domain added to site
domain.verified
Domain DNS verified
3Webhook Payload
Example webhook payload:
{
"event": "deployment.succeeded",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"deployment": {
"id": "dpl_abc123",
"url": "https://my-site.bericanlabs.com",
"status": "ready",
"createdAt": "2024-01-15T10:28:00Z"
},
"site": {
"id": "site_xyz789",
"name": "my-site"
}
}
}
4Verify Signatures
Verify webhook authenticity using the signature:
// Node.js example
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(`sha256=${expected}`)
);
}
// In your webhook handler
app.post('/webhook', (req, res) => {
const signature = req.headers['x-berican-signature'];
const isValid = verifyWebhook(
JSON.stringify(req.body),
signature,
process.env.WEBHOOK_SECRET
);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
// Process webhook...
});
5Deploy Hooks
Trigger deployments via webhook URL:
- Go to Site Settings > Deploy Hooks
- Click "Create Deploy Hook"
- Name your hook (e.g., "CI Pipeline")
- Copy the generated URL
# Trigger deployment
curl -X POST https://api.bericanlabs.com/hooks/deploy/hook_abc123
Use this to integrate with external CI/CD systems.