Skip to main content
POST
/
api
/
v1
/
webhooks
curl -X POST https://api.jasni.ai/api/v1/webhooks \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhooks/jasni",
    "events": ["email.received", "email.sent"],
    "description": "Production webhook"
  }'
{
  "success": true,
  "data": {
    "webhook": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "url": "https://your-server.com/webhooks/jasni",
      "events": ["email.received", "email.sent"],
      "active": true,
      "description": "Production webhook",
      "secret": "whsec_abc123def456ghi789...",
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
}

Request Body

url
string
required
Webhook endpoint URL (must be HTTP or HTTPS)
events
array
required
Events to subscribe to. At least one event is required.Available events:
  • email.received - New email received
  • email.sent - Email sent successfully
  • email.bounced - Email bounced
  • email.spam - Email marked as spam
  • email.deleted - Email deleted
description
string
Optional description for the webhook

Response

success
boolean
Indicates if the webhook was created successfully
data
object
curl -X POST https://api.jasni.ai/api/v1/webhooks \
  -H "Authorization: Bearer jsk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhooks/jasni",
    "events": ["email.received", "email.sent"],
    "description": "Production webhook"
  }'
{
  "success": true,
  "data": {
    "webhook": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "url": "https://your-server.com/webhooks/jasni",
      "events": ["email.received", "email.sent"],
      "active": true,
      "description": "Production webhook",
      "secret": "whsec_abc123def456ghi789...",
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
}
Save the secret immediately! It’s only returned when the webhook is created and cannot be retrieved later. You’ll need it to verify webhook signatures.

Limits

  • Maximum 10 webhooks per user
  • URL must use HTTP or HTTPS protocol

Verifying Webhook Signatures

Use the secret to verify that webhook requests are from Jasni:
const crypto = require('crypto');

function verifyWebhookSignature(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}
See the Webhook Security guide for more details.