Skip to main content
POST
https://api.trycase.ai/api/v1
/
webhooks
curl -X POST "https://api.trycase.ai/api/v1/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/case",
    "events": ["order.confirmed", "order.shipped", "order.delivered"],
    "secret": "your_webhook_secret"
  }'
{
  "id": "wh_abc123",
  "url": "https://yourapp.com/webhooks/case",
  "events": ["order.confirmed", "order.shipped", "order.delivered"],
  "active": true,
  "created_at": "2025-01-15T10:00:00Z",
  "secret": "your_webhook_secret_or_auto_generated_hash"
}

Register Webhook

Register a webhook endpoint to receive real-time notifications about order events.

Available Events

EventDescription
order.confirmedOrder has been confirmed and payment processed
order.shippedOrder has shipped with tracking info
order.deliveredOrder has been delivered
order.cancelledOrder has been cancelled

Request Body

url
string
required
The URL to receive webhook events (must be HTTPS)
events
array
required
Array of event types to subscribe to
secret
string
Optional secret for webhook signature verification
curl -X POST "https://api.trycase.ai/api/v1/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/case",
    "events": ["order.confirmed", "order.shipped", "order.delivered"],
    "secret": "your_webhook_secret"
  }'
{
  "id": "wh_abc123",
  "url": "https://yourapp.com/webhooks/case",
  "events": ["order.confirmed", "order.shipped", "order.delivered"],
  "active": true,
  "created_at": "2025-01-15T10:00:00Z",
  "secret": "your_webhook_secret_or_auto_generated_hash"
}
The secret is only returned when the webhook is created. Store it securely for signature verification.

Webhook Payload

When an event occurs, we’ll POST to your URL with this payload:
{
  "id": "evt_123",
  "type": "order.shipped",
  "created_at": "2025-01-16T09:00:00Z",
  "data": {
    "order": {
      "id": "ord_2025_0042",
      "order_number": "ORD-2025-0042",
      "status": "shipped",
      "tracking": {
        "carrier": "FedEx",
        "tracking_number": "1234567890"
      }
    }
  }
}

Verifying Signatures

If you provided a secret, verify the X-Webhook-Signature header:
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}