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" }
Delete a webhook endpoint
// 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);
// 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}`); } }
// 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, }), });