Configure webhooks to receive real-time notifications about events in your Devdraft account. Webhooks send HTTP POST requests to your specified URLs whenever important events occur, enabling you to automate workflows and keep external systems in sync.

What are Webhooks?

Webhooks are HTTP callbacks that Devdraft sends to your specified URLs when events occur in your account. Instead of repeatedly polling our API for updates, webhooks push event data to your application in real-time, enabling immediate responses to important business events.
Webhooks management dashboard showing configured endpoints and event history - light modeWebhooks management dashboard showing configured endpoints and event history - dark mode

Webhooks Management Dashboard

Quick Setup

Set up your first webhook in under 3 minutes:
1

Access Webhook Settings

Navigate to App Settings → Webhooks in your dashboard
2

Create Webhook Endpoint

Click Create Webhook and provide your endpoint URL
Create webhook interface with URL and event selection - light modeCreate webhook interface with URL and event selection - dark mode

Create Webhook Interface

3

Configure Security

Choose encryption settings and verify endpoint connectivity
4

Monitor Events

Track webhook deliveries and debug any issues

Webhook Events

Payment-Related Notifications:
  • transaction.successful - When payments complete successfully
  • transaction.failed - When payments fail or are declined
  • transaction.pending - When transactions await processing
  • transaction.canceled - When transactions are canceled
  • transaction.disputed - When payments are disputed

Creating Webhooks

1

Start Webhook Creation

Navigate to App Settings → Webhooks and begin the setup process.
2

Configure Webhook Details

Required Information:
  • Endpoint URL: Your server URL to receive webhook events
  • Events: Select which events to subscribe to
  • Secret: Optional signing secret for verification
  • Description: Optional notes for identification
3

Test and Activate

Test your webhook endpoint and activate it to start receiving events.

Managing Webhooks

Webhook Security

Signature Verification

Verify webhook authenticity using HMAC-SHA256 signatures in request headers

HTTPS Required

All webhook URLs must use HTTPS to ensure encrypted data transmission

Timeout Handling

Implement proper timeout handling for webhook endpoint responses

Idempotency

Handle duplicate events gracefully using idempotency keys

Implementing Webhook Endpoints

const express = require('express');
const crypto = require('crypto');
const app = express();

app.use(express.json());

// Webhook signature verification
function verifySignature(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature, 'hex'),
    Buffer.from(expectedSignature, 'hex')
  );
}

app.post('/webhooks/devdraft', (req, res) => {
  const signature = req.headers['x-devdraft-signature'];
  const payload = JSON.stringify(req.body);
  
  if (!verifySignature(payload, signature, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Unauthorized');
  }
  
  // Process the webhook event
  const event = req.body;
  console.log(`Received event: ${event.type}`);
  
  // Respond with success
  res.status(200).send('OK');
});

Best Practices

1

Implement Proper Error Handling

Robust Endpoint Design:
  • Return appropriate HTTP status codes
  • Handle malformed or unexpected payloads
  • Implement timeout protection
  • Log all webhook events for debugging
Always return a 2xx status code for successfully processed webhooks, even if your business logic encounters errors.
2

Ensure Idempotency

Duplicate Event Handling:
  • Use event IDs to detect duplicates
  • Implement idempotent processing logic
  • Store processed event IDs temporarily
  • Handle race conditions gracefully
const processedEvents = new Set();

app.post('/webhook', (req, res) => {
  const eventId = req.body.id;
  
  if (processedEvents.has(eventId)) {
    return res.status(200).send('Already processed');
  }
  
  // Process event
  processEvent(req.body);
  processedEvents.add(eventId);
  
  res.status(200).send('OK');
});
3

Monitor Webhook Health

Ongoing Maintenance:
  • Track webhook delivery success rates
  • Monitor endpoint response times
  • Set up alerts for failed deliveries
  • Regularly review event processing logs
High failure rates may indicate endpoint issues or network problems that need immediate attention.
Webhooks provide real-time event notifications but should not be your only integration method. Always implement fallback mechanisms using our REST API for critical business processes.