Webhooks
Receive real-time notifications when async jobs complete. No polling required.
Configuration
Include webhook_url in your request:
{
"source_image": "face.jpg",
"target_video": "video.mp4",
"webhook_url": "https://yoursite.com/api/deepswap-webhook"
}Webhook Payload
We POST to your URL when the job completes:
{
"event": "video_swap.completed",
"job_id": "vjob_xyz789",
"status": "completed",
"output_url": "https://cdn.deepswapai.com/results/xyz.mp4",
"processing_time": 118500,
"credits_used": 48,
"timestamp": "2026-01-28T12:00:00Z"
}Event Types
| Event | Description |
|---|---|
video_swap.completed | Video processing finished |
video_swap.failed | Video processing failed |
batch_swap.completed | Batch job finished |
batch_swap.failed | Batch job failed |
Verification
Verify webhook authenticity using the X-DeepSwapAI-Signature header:
import crypto from 'crypto';
function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}Best Practices
- • Return 200 status within 5 seconds
- • Process webhook data asynchronously
- • Implement idempotency (we may retry)
- • Always verify signatures