API Reference
Webhooks & HMAC Verification
Verify webhook signatures using HMAC-SHA256 and the key's webhook secret.
When a webhookUrl is specified, Transpera sends an HTTP POST request upon job completion or failure. Every webhook includes an HMAC-SHA256 signature in the x-transpera-signature header.
Headers Sent
| Header | Description |
|---|---|
| x-transpera-timestamp | Unix timestamp in seconds when the webhook was generated |
| x-transpera-signature | Formatted as t=<timestamp>,v1=<hex_signature> |
| content-type | application/json |
Verification Code Example
import * as crypto from "node:crypto";
function verifyWebhook(secret: string, timestamp: string, rawBody: string, signature: string): boolean {
const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}