DocsPlatform
Webhooks
Receive signed HTTP callbacks when jobs finish, translations change or a project is published, with verification code for Node and Cloudflare Workers.
On this page
A webhook is a URL on your server that Generic Translation calls with a JSON POST when something happens in your organization. Use them to refresh a cache after a publish, to start a deploy when a job finishes, or to log reviews. Webhooks belong to an organization and fire for events in any of its projects. Manage them on the dashboard’s Webhooks page or with the webhooks API (session token, admin role).
Events
| Event | Sent when |
|---|---|
job.completed |
A batch, file or glossary job finished (including a job with nothing to do). |
job.failed |
A job finished with every item failed. |
translation.updated |
A translation was edited or retranslated. |
translation.approved |
A translation became approved. |
project.published |
A publish completed. |
webhook.test is additionally sent by the Send test button and POST .../test; you cannot subscribe to it. Each webhook subscribes to a list of the five real events.
Delivery
Generic Translation sends one HTTP POST per event per matching webhook, with content-type: application/json and a body like:
{
"id": "evt_9f3k2m1q8z4t7w0a",
"type": "project.published",
"createdAt": "2026-11-30T10:15:00.000Z",
"data": {
"projectId": "prj_abc123",
"locales": ["es", "fr"],
"version": "v1x9k2m3",
"publishedAt": "2026-11-30T10:15:00.000Z"
}
}
Headers:
| Header | Value |
|---|---|
generic-translation-signature |
t=<unix seconds>,v1=<hex HMAC-SHA256> (see below). |
generic-translation-event |
The event type. |
generic-translation-delivery |
The event id (evt_…). Use it to de-duplicate. |
user-agent |
Generic-Translation-Webhooks/1.0 |
The data of each event:
| Event | data fields |
|---|---|
job.completed, job.failed |
jobId, projectId, type (entries, file, glossary), status, total, completed, failed, and error when set |
translation.updated, translation.approved |
projectId, hash, locale, text, status, updatedBy |
project.published |
projectId, locales, version, publishedAt |
Your endpoint must answer with a 2xx within 10 seconds. Redirects are not followed. Anything else (a non-2xx status, a timeout, a connection error) counts as a failed attempt.
Retries
A failed delivery is retried automatically, up to 6 attempts in total (the first try plus 5 retries). The waits after each failed attempt are:
| After attempt | Wait before the next |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 6 hours |
Retries are driven by a cron that runs once a minute, so a retry can arrive a little after its nominal time. Every attempt is its own row in the delivery list, with an attempt number (1-based) and nextRetryAt (when the next retry is due, or null). All attempts for an event carry the same event id (generic-translation-delivery), and each attempt is signed afresh with its own timestamp. A retry is skipped if the webhook has been disabled or deleted in the meantime, and the webhook.test event is never retried.
Delivery is at-least-once, not guaranteed: after the last attempt Generic Translation gives up. Keep your handler fast (acknowledge, then do the work), make it idempotent using generic-translation-delivery, and reconcile from the API if you were down for longer than about nine hours.
URLs must be public http:// or https:// addresses. localhost, .local and .internal names, and private or link-local IP ranges are rejected. For local development, use a tunnel.
The secret
Creating a webhook returns a secret beginning with whsec_. It is shown once; Generic Translation keeps it to sign deliveries and never returns it again. Store it as a secret in your app. To rotate it, create a new webhook and delete the old one.
Verifying signatures
Anyone who learns your endpoint URL can send it fake events. Always verify the signature before trusting a payload.
The samples below were run, not just written: the Node.js and WebCrypto functions, the Express handler and the openssl command were all checked against real signed deliveries (a webhook.test, a job.completed and a project.published event) sent by the hosted API to a request-capture endpoint. They accepted every genuine delivery and rejected a changed body, a wrong secret and a stale timestamp.
The signature header is generic-translation-signature: t=<unix>,v1=<hex>, where:
tis the time the delivery was signed, in Unix seconds.v1is the lowercase hex HMAC-SHA256 of the string"<t>.<raw request body>", using the webhook secret (the wholewhsec_…string, as UTF-8) as the key.
To verify:
- Read the raw body bytes as text before any JSON parsing. Re-serializing parsed JSON changes the bytes and breaks the signature.
- Split the header into
tandv1. - Compute the HMAC over
`${t}.${rawBody}`. - Compare with
v1in constant time. - Reject if
tis too old (for example more than five minutes), to block replays of captured requests.
Node.js
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyGenericTranslationSignature(
rawBody: string,
header: string | undefined,
secret: string,
toleranceSeconds = 300,
): boolean {
if (!header) return false;
const parts = Object.fromEntries(
header.split(",").map((kv) => {
const i = kv.indexOf("=");
return [kv.slice(0, i).trim(), kv.slice(i + 1).trim()];
}),
);
const t = Number(parts.t);
const v1 = parts.v1;
if (!Number.isFinite(t) || !v1) return false;
if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(expected, "utf8");
const b = Buffer.from(v1, "utf8");
return a.length === b.length && timingSafeEqual(a, b);
}
With Express, capture the raw body for this route:
import express from "express";
const app = express();
app.post("/hooks/generic-translation", express.text({ type: "application/json" }), (req, res) => {
const ok = verifyGenericTranslationSignature(req.body, req.header("generic-translation-signature"), process.env.GENERIC_TRANSLATION_WEBHOOK_SECRET!);
if (!ok) return res.status(400).send("bad signature");
const event = JSON.parse(req.body);
if (event.type === "project.published") {
// e.g. clear a translation cache; see clearTranslationCache() in @generic-translation/node
}
res.sendStatus(204);
});
Cloudflare Workers, Deno, Bun and browsers (WebCrypto)
const encoder = new TextEncoder();
function hexToBytes(hex: string): Uint8Array | null {
if (hex.length % 2 !== 0 || /[^0-9a-f]/i.test(hex)) return null;
const out = new Uint8Array(hex.length / 2);
for (let i = 0; i < out.length; i++) out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
return out;
}
export async function verifyGenericTranslationSignature(
rawBody: string,
header: string | null,
secret: string,
toleranceSeconds = 300,
): Promise<boolean> {
if (!header) return false;
const parts = Object.fromEntries(
header.split(",").map((kv) => {
const i = kv.indexOf("=");
return [kv.slice(0, i).trim(), kv.slice(i + 1).trim()];
}),
);
const t = Number(parts.t);
const sig = parts.v1 ? hexToBytes(parts.v1) : null;
if (!Number.isFinite(t) || !sig) return false;
if (Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const key = await crypto.subtle.importKey(
"raw",
encoder.encode(secret),
{ name: "HMAC", hash: "SHA-256" },
false,
["verify"],
);
// crypto.subtle.verify compares in constant time
return crypto.subtle.verify("HMAC", key, sig, encoder.encode(`${t}.${rawBody}`));
}
export default {
async fetch(request: Request, env: { GENERIC_TRANSLATION_WEBHOOK_SECRET: string }): Promise<Response> {
const body = await request.text(); // raw body, before JSON.parse
const ok = await verifyGenericTranslationSignature(body, request.headers.get("generic-translation-signature"), env.GENERIC_TRANSLATION_WEBHOOK_SECRET);
if (!ok) return new Response("bad signature", { status: 400 });
const event = JSON.parse(body);
// handle event.type ...
return new Response(null, { status: 204 });
},
};
Testing
Create the webhook, then use Send test on the dashboard (or POST /v1/orgs/:orgId/webhooks/:webhookId/test). It sends a signed webhook.test event to your URL and shows the response, so you can check verification end to end. You can also compute a signature by hand:
body='{"id":"evt_test","type":"webhook.test","createdAt":"2026-11-30T10:00:00.000Z","data":{}}'
t=$(date +%s)
sig=$(printf '%s' "$t.$body" | openssl dgst -sha256 -hmac "$SECRET" -hex | sed 's/^.* //')
curl -X POST http://localhost:3000/hooks/generic-translation \
-H "content-type: application/json" \
-H "generic-translation-signature: t=$t,v1=$sig" \
-d "$body"
Pausing and deleting
The enabled switch pauses deliveries without losing the secret. Deleting a webhook also deletes its delivery history. Webhook creation, changes, deletion and tests are recorded in the audit log.
Something wrong or unclear on this page? Open an issue.