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:

  1. Go to Site Settings > Webhooks
  2. Click "Add Webhook"
  3. Enter your webhook URL (must be HTTPS)
  4. Select which events to receive
  5. 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:

  1. Go to Site Settings > Deploy Hooks
  2. Click "Create Deploy Hook"
  3. Name your hook (e.g., "CI Pipeline")
  4. 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.