Receiving webhooks
How Fungies delivers webhook events: the request, the signature, retries and versions.
A webhook endpoint is a URL on your server that Fungies sends events to. Add one in the dashboard
or with POST /v1/webhook-endpoints, naming the
event types it subscribes to. The URL must be HTTPS on port 443 to a public host.
The create answers the endpoint's signing secret, once: store it. A retry of the same create
under its Idempotency-Key answers the endpoint without it.
The delivery
A delivery is an HTTPS POST with a JSON body. Answer 2xx as soon as you have stored the
event, and do the work afterwards. Anything else, a 4xx included, or no answer in time, is a
failure and is retried.
A 307 or 308 redirect is followed with the same method, headers and body, up to three hops,
only within the registrable domain of your URL and never from https to http. Any other
redirect is a failure.
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | Fungies-Webhooks/2 |
Fngs-Event-Id | The event's id, the same as the body's id, on every attempt and retry. |
Fngs-Webhook-Id | The endpoint the delivery is addressed to. |
Fngs-Api-Version | The version the endpoint is pinned to. |
Fngs-Delivery-Attempt | Which attempt this is, counting from 1. |
Fngs-Signature | t=<unix seconds>,v2=<hex>, with a second v2= while a secret rotation overlaps. |
The body's fields are on Webhook events.
Verify the signature
The signature is HMAC-SHA256, keyed on your endpoint's secret, over the timestamp, a dot and the exact body bytes. Verify it before you parse the body, and reject a delivery whose timestamp is more than 300 seconds from now.
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
// rawBody: the body bytes as received. Parsing and re-serialising them breaks the signature.
// secrets: your endpoint's secrets; two are live while a rotation overlaps.
export function verifyFungiesSignature(rawBody, header, secrets, nowSeconds) {
if (typeof header !== "string" || header.length === 0) return false;
let timestamp = null;
const candidates = [];
for (const part of header.split(",")) {
const separator = part.indexOf("=");
if (separator === -1) return false;
const key = part.slice(0, separator).trim();
const value = part.slice(separator + 1).trim();
if (key === "t" && /^\d{1,15}$/.test(value)) timestamp = Number(value);
// Skip a key you do not know: a later scheme is added beside v2.
else if (key === "v2" && /^[0-9a-f]{64}$/.test(value)) candidates.push(value);
}
if (timestamp === null || candidates.length === 0) return false;
if (Math.abs(nowSeconds - timestamp) > TOLERANCE_SECONDS) return false;
let matched = false;
for (const secret of secrets) {
const expected = createHmac("sha256", secret)
.update(Buffer.from(`${timestamp}.`, "utf8"))
.update(rawBody)
.digest();
for (const candidate of candidates) {
const given = Buffer.from(candidate, "hex");
if (given.length === expected.length && timingSafeEqual(given, expected)) matched = true;
}
}
return matched;
}Duplicates and order
id belongs to the event, not the delivery: every retry of one event carries the same id.
Store it, and drop a delivery whose id you have already handled.
sequence increases for each object (aggregate) of a workspace. A delivery with a lower
sequence than one you already handled for that object is stale: drop it rather than trusting
the order deliveries arrive in. The numbers may skip; compare them, never count on them.
Retries
A failed delivery is retried, up to 12 attempts in all, with each wait jittered by up to 20%:
| After attempt | Next attempt waits |
|---|---|
| 1 | 30 s |
| 2 | 1 min |
| 3 | 2 min |
| 4 | 4 min |
| 5 | 8 min |
| 6 | 16 min |
| 7 | 32 min |
| 8 to 11 | about 22 h |
An endpoint that is back within three days still gets every event it missed. After the 12th
failed attempt a delivery is not retried again; you can retry it yourself with
POST /v1/webhook-deliveries/{deliveryId}/retry.
Ten deliveries in a row that fail every attempt disable the endpoint, with disabledReason
consecutive_failures. Enabling it again starts the count over. The workspace's other endpoints
are told with webhook_endpoint.disabled.
Test events
POST /v1/webhook-endpoints/{endpointId}/test sends one event
of a type the endpoint subscribes to, with sample data and liveMode: false.
Versions
An endpoint is pinned to an apiVersion when you create it, and Fungies never moves it. Adding a
field, an event type or an enum value does not make a new version: ignore keys you do not know.
A new date is made only for a change you could not ignore, such as a field removed or renamed.
apiVersion | |
|---|---|
2026-09-08 | What an endpoint gets when it names no version. The event catalogue shows this version. |
2026-10-28 | Drops fields that repeat others, listed below. |
2026-11-05 | As 2026-10-28, and sends a subscription's incomplete and unpaid statuses as they are. |
What 2026-10-28 changes against 2026-09-08:
| Field | At 2026-10-28 |
|---|---|
order.fee | Removed. A fee is payment.fee. |
order.lastPaymentId, order.lastPaymentNumber | Removed: payment carries the charge. |
items[].plan | Removed: it repeated variant. |
payment.status | One of pending, requires_action, succeeded, failed, cancelled. |
payment.type | Renamed billingReason. Ignore a value you do not know. |
payment.coupon.value, .currency | A fixed coupon states amount; a percentage one states percentBps. |
subscription.orderStatus | Removed: the first order is its own object. |
subscription.lastPaymentId, .lastPaymentNumber | Removed: payment carries the charge. |
customer.username, .firstName, .lastName | Removed: name is the buyer's name. |
customer.phoneDialCode, .phoneNumber | Replaced by phone, in E.164 (+31201234567), or null when it does not parse. |
At 2026-11-05, subscription.status is sent as incomplete (the first payment is still owed)
and unpaid (renewal retries ended). Earlier dates send past_due for both.
Endpoints that were set up for the v0 webhooks are pinned to v1, and keep getting the payloads
described in the v0 webhook pages. An event page names the type
such an endpoint gets, where there is one.
Last updated