# Webhooks

> Lefine sends a signed POST to your address when a release goes live, so you can rebuild a site or tell a channel.

A webhook is an `https` address that Lefine calls when something happens. Today there is one event: `strings.release.published`, a release went live on the CDN and every language was read back.

You do not need a webhook for your app to get new texts. SDKs pick up a new release from the CDN on their own. A webhook makes it happen at once, or starts something else (a build, a message).

## Add a webhook

Owners and admins open **Settings → Webhooks** and press **New webhook**.

1. **URL:** a public `https://` address. Not an IP address and not `localhost`.
2. **Events:** pick `strings.release.published`.
3. **App:** one app, or leave it empty for every app in the workspace.

Lefine then shows the signing secret (`whsec_…`) **once**. Copy it into your server's environment. Later you only see its last 4 characters.

A workspace can have up to 20 webhooks. **Send test** sends a `webhook.test` event to one address now, so you can see what your receiver gets.

## What Lefine sends

```http
POST /hooks/lefine HTTP/1.1
Content-Type: application/json
User-Agent: Lefine-Webhooks/1
X-Lefine-Event: strings.release.published
X-Lefine-Id: evt_…
X-Lefine-Signature: t=1793030400,v1=5f2c…
```

```json
{
  "id": "evt_…",
  "type": "strings.release.published",
  "workspaceId": "ws_…",
  "createdAt": "2026-10-27T09:00:00.000Z",
  "data": {
    "app": { "id": "app_…", "name": "Web" },
    "release": {
      "id": "…",
      "version": 12,
      "previousVersion": 11,
      "locales": ["en", "de", "fr"],
      "keysAdded": ["pricing.cta"],
      "keysChanged": ["home.title"],
      "publishedAt": "2026-10-27T09:00:00.000Z",
      "publishedBy": "…"
    },
    "run": { "id": "…", "status": "succeeded", "live": 412 }
  }
}
```

`X-Lefine-Id` is the same on every retry and every **Send again**. Use it to drop repeats.

## Check the signature

`X-Lefine-Signature` is `t=<unix seconds>,v1=<hex>`. `v1` is HMAC-SHA256 of `` `${t}.${body}` ``, keyed with the whole secret (`whsec_…` as text). Check it against the **raw** body, before you parse the JSON. Reject a `t` older than five minutes.

```ts
import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyLefine(rawBody: string, header: string | null, secret: string): boolean {
  const parts = Object.fromEntries((header ?? "").split(",").map((p) => p.split("=", 2)));
  const t = Number(parts.t);
  if (!Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const got = String(parts.v1 ?? "");
  return got.length === expected.length && timingSafeEqual(Buffer.from(got), Buffer.from(expected));
}
```

On Next.js you do not need this: `export const POST = lefine.revalidate` checks the signature for you. See [Next.js](https://lefine.ai/en/docs/strings/sdk/?fw=next#fw-next-show-a-publish-at-once).

## Answer, retries and the log

Answer with any `2xx` within 10 seconds. A redirect counts as a failure: give the final address.

When a delivery fails, Lefine tries again after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours. Six attempts in total, then it stops. A webhook switched off (the **On** switch) is not tried again.

Each webhook has a **Deliveries** log with its newest 50 deliveries: status, attempts, your HTTP status, the error in words ("Answered 500", "No answer within 10 s") and the time. From the log you can **Send again** one delivery.

## Make a new secret

**New signing secret** (in the webhook's menu) makes a new secret. The old one stops working at once, so update your server right after.

Source: https://lefine.ai/en/docs/strings/webhooks/
