Skip to main content

Webhooks

Webhooks allow you to receive HTTP callbacks when your jobs complete or fail, eliminating the need for polling.

Overview

Instead of repeatedly polling GET /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 a webhookUrl 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

Signature Verification

Every webhook request is signed so you can verify it came from PixelByte.

Signature Headers

How Verification Works

The signature is computed as:
Where:
  • timestamp is the value from the X-PixelByte-Timestamp header
  • rawPayload is the raw request body string
  • webhookSecret is your webhook secret from the dashboard

Verification Examples

Always use constant-time comparison (timingSafeEqual in Node.js, hmac.compare_digest in Python) to prevent timing attacks.

Retry Policy

If your endpoint doesn’t respond with a 2xx status code, PixelByte retries the webhook delivery using exponential backoff: After 5 failed attempts, the webhook is marked as failed.

Webhook Delivery Status

Best Practices

1

Respond 200 Quickly

Return a 200 response immediately before doing any processing. Heavy processing should happen asynchronously to avoid timeouts.
2

Verify Signatures

Always verify the X-PixelByte-Signature header to ensure the webhook is authentic. Never skip this step, even in development.
3

Handle Idempotency

Webhooks may be delivered more than once (due to retries). Use the jobId to deduplicate and ensure your handler is idempotent.
4

Process Asynchronously

Queue webhook payloads for background processing. This ensures you respond quickly and can retry your own processing if needed.
5

Use HTTPS

Always use HTTPS URLs for webhook endpoints. HTTP URLs will be rejected.
6

Monitor Delivery

Track webhook delivery status in the PixelByte dashboard and set up alerts for repeated failures.
Webhook URLs must be publicly accessible and respond within 30 seconds. If your endpoint consistently times out, webhooks will be marked as failed.