Skip to main content
DELETE
/
api
/
v1
/
webhooks
curl -X DELETE "https://api.jasni.ai/api/v1/webhooks?id=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer jsk_your_api_key"
{
  "success": true,
  "message": "Webhook deleted"
}

Request

id
string
required
Webhook ID to delete

Response

success
boolean
Indicates if the deletion was successful
message
string
Confirmation message
curl -X DELETE "https://api.jasni.ai/api/v1/webhooks?id=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer jsk_your_api_key"
{
  "success": true,
  "message": "Webhook deleted"
}
Deleting a webhook is permanent and cannot be undone. All pending deliveries will be cancelled.

Behavior

When you delete a webhook:
  1. Immediate effect: The webhook stops receiving events immediately
  2. Pending deliveries cancelled: Any retries in queue are cancelled
  3. Logs preserved: Delivery logs may be retained for a period (check your plan)
  4. Cannot recover: The webhook and its secret are permanently deleted

Use Cases

Replace a Webhook

To change the webhook secret, delete and recreate:
// Delete old webhook
await fetch(
  `https://api.jasni.ai/api/v1/webhooks?id=${oldWebhookId}`,
  {
    method: 'DELETE',
    headers: { 'Authorization': 'Bearer jsk_your_api_key' },
  }
);

// Create new webhook with new secret
const response = await fetch('https://api.jasni.ai/api/v1/webhooks', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer jsk_your_api_key',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://your-server.com/webhooks',
    events: ['email.received', 'email.sent'],
  }),
});

const { data } = await response.json();
console.log('New secret:', data.webhook.secret);

Cleanup Old Webhooks

// List all webhooks
const response = await fetch('https://api.jasni.ai/api/v1/webhooks', {
  headers: { 'Authorization': 'Bearer jsk_your_api_key' },
});

const { data } = await response.json();

// Delete inactive webhooks
for (const webhook of data.webhooks) {
  if (!webhook.active) {
    await fetch(
      `https://api.jasni.ai/api/v1/webhooks?id=${webhook.id}`,
      {
        method: 'DELETE',
        headers: { 'Authorization': 'Bearer jsk_your_api_key' },
      }
    );
    console.log(`Deleted inactive webhook: ${webhook.url}`);
  }
}

Alternative: Disable Instead

If you might need the webhook again, consider disabling instead of deleting:
// Disable (can be re-enabled later)
await fetch('https://api.jasni.ai/api/v1/webhooks', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer jsk_your_api_key',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    id: webhookId,
    active: false,
  }),
});