Webhooks
Webhooks allow you to receive HTTP callbacks when your jobs complete or fail, eliminating the need for polling.Overview
Instead of repeatedly pollingGET /v1/jobs/{jobId} for status updates, you can provide a webhookUrl when submitting a job. PixelByte will send an HTTP POST to your URL when the job reaches a terminal state.
Setting Up Webhooks
Include awebhookUrl in your job submission request:
Webhook Payload
When a job completes or fails, PixelByte sends a POST request to your webhook URL with the following payload:Success Payload
Failure Payload
| Field | Type | Description |
|---|---|---|
jobId | string | The unique job identifier |
requestId | string | The original request ID |
status | string | completed or failed |
output | object | Job output (only on success) |
error | object | Error details (only on failure) |
completedAt | string | ISO 8601 timestamp |
Signature Verification
Every webhook request is signed so you can verify it came from PixelByte.Signature Headers
| Header | Description |
|---|---|
X-PixelByte-Timestamp | Unix timestamp (seconds) when the webhook was sent |
X-PixelByte-Signature | HMAC-SHA256 signature in format sha256=... |
How Verification Works
The signature is computed as:timestampis the value from theX-PixelByte-TimestampheaderrawPayloadis the raw request body stringwebhookSecretis your webhook secret from the dashboard
Verification Examples
Retry Policy
If your endpoint doesn’t respond with a2xx status code, PixelByte retries the webhook delivery using exponential backoff:
| Attempt | Delay | Cumulative Time |
|---|---|---|
| 1st retry | 1 second | 1s |
| 2nd retry | 4 seconds | 5s |
| 3rd retry | 16 seconds | 21s |
| 4th retry | 64 seconds | ~1.4 min |
| 5th retry | 256 seconds | ~5.7 min |
failed.
Webhook Delivery Status
| Status | Description |
|---|---|
pending | Webhook is queued for delivery |
sent | Successfully delivered (received 2xx response) |
failed | All retry attempts exhausted |
Best Practices
Respond 200 Quickly
Return a
200 response immediately before doing any processing. Heavy processing should happen asynchronously to avoid timeouts.Verify Signatures
Always verify the
X-PixelByte-Signature header to ensure the webhook is authentic. Never skip this step, even in development.Handle Idempotency
Webhooks may be delivered more than once (due to retries). Use the
jobId to deduplicate and ensure your handler is idempotent.Process Asynchronously
Queue webhook payloads for background processing. This ensures you respond quickly and can retry your own processing if needed.
Webhook URLs must be publicly accessible and respond within 30 seconds. If your endpoint consistently times out, webhooks will be marked as failed.