.do

Webhooks

Event subscriptions and real-time notifications

Subscribe to events and trigger workflows.

Pattern

POST /:ns/webhooks
GET  /:ns/webhooks/:id
DELETE /:ns/webhooks/:id

Example

# Create webhook
POST https://apis.do/acme.com/webhooks
{
  "url": "https://your-app.com/webhook",
  "events": ["business.created", "order.completed"],
  "secret": "your-webhook-secret"
}

# Webhook delivery
POST https://your-app.com/webhook
{
  "event": "business.created",
  "data": {
    "id": "biz_123",
    "name": "Acme Inc"
  },
  "timestamp": "2024-11-11T15:30:00Z"
}

SDK

import { $ } from 'sdk.do'

const client = $('acme.com')

// Create webhook
const webhook = await client.Webhook.create({
  url: 'https://your-app.com/webhook',
  events: ['business.created', 'order.completed'],
  secret: 'your-webhook-secret'
})

// Event handler
on($.Business.created, async (business) => {
  console.log('New business:', business.name)
})

Events

Common platform events:

// Business events
$.Business.created
$.Business.updated
$.Business.deleted

// Order events
$.Order.placed
$.Order.completed
$.Order.cancelled

// User events
$.User.registered
$.User.invited
$.User.deleted

// Payment events
$.Payment.succeeded
$.Payment.failed

Security

Verify webhook signatures:

import { createHmac } from 'crypto'

function verifyWebhook(payload: string, signature: string, secret: string) {
  const hmac = createHmac('sha256', secret)
  hmac.update(payload)
  const expected = hmac.digest('hex')
  return signature === expected
}

// In your webhook handler
app.post('/webhook', (req, res) => {
  const signature = req.headers['x-webhook-signature']
  const payload = JSON.stringify(req.body)

  if (!verifyWebhook(payload, signature, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature')
  }

  // Process webhook
  res.status(200).send('OK')
})

Retry Policy

Failed webhooks are retried with exponential backoff:

  • Attempt 1: Immediate
  • Attempt 2: 1 minute
  • Attempt 3: 5 minutes
  • Attempt 4: 30 minutes
  • Attempt 5: 2 hours
  • Attempt 6: 12 hours

Rate Limits

PlanWebhooks/min
Free10
Pro100
Business1,000
EnterpriseCustom

Support