Webhooks
A webhook endpoint is a URL of yours that Yona calls when something happens to your organization’s data: an invoice is registered by the authority, delivered or rejected, a payment is recorded, a buyer’s tax number is verified. Each delivery is signed, so you can check it came from Yona.
Endpoints
Create endpoints in the Yona app under Webhooks. Each has a URL, the events it subscribes to, and an environment. An organization may have up to 16 endpoints in each environment. The signing secret, whsec_ followed by 43 characters, is shown once.
Which endpoints receive an event depends on the event. Invoice, buyer and tax connection events go to the endpoints of the environment they happened in, so a sandbox endpoint only hears about sandbox invoices. Organization, member and invitation events go to endpoints of both environments. Billing events about real money, such as billing.balance.low, go to live endpoints only.
With an API key you can list and read endpoints, send a test event, read deliveries and ask for a redelivery. Creating, changing, deleting or rotating an endpoint’s secret is done in the app.
| Operation | Path |
|---|---|
| List endpoints | GET /n/v1/webhook-endpoints |
| Send a test event | POST /n/v1/webhook-endpoints/{id}/test |
| List deliveries | GET /n/v1/webhook-deliveries |
| Redeliver | POST /n/v1/webhook-deliveries/{id}/redeliver |
| Event catalogue | GET /n/v1/webhook-event-types |
Events
The catalogue at GET /n/v1/webhook-event-types lists every event type with its status, the capability a subscription needs and whether your key holds it (subscribable). Subscribe with exact names, or with patterns: invoice.* matches every type that starts invoice., and * matches all.
A type whose status is future or pending_source is defined but delivers nothing yet. invoice.received, for invoices other businesses send you, is one of them: to see new received invoices, read GET /i/v1/inbound-invoices.
The events most integrations want follow an invoice’s submission to the authority. Every one carries invoiceId and submissionId in data:
| Event | When | Also in data |
|---|---|---|
invoice.submitted | A submission was queued; the invoice’s status is queued | status, attempt |
invoice.signed | The authority registered it; status signed | status, authorityState (registered), authorityReference (the IRN) |
invoice.transmitted | The authority sent it on to the buyer’s access point | status, authorityState, authorityReference |
invoice.accepted | The authority confirmed the buyer received it; status accepted | status, authorityState (delivered), authorityReference |
invoice.rejected | The authority refused it before registering it | status, reasons (the authority’s codes) |
invoice.parked | The submission is on hold; the invoice’s status is failed | status, parkReason |
invoice.retry_scheduled | A submission on hold is being tried again | runNo |
The submission steps handed_off and withdrawn have no event of their own. handed_off is an internal step: the invoice stays queued. A withdrawal is told by the event of the change that caused it, such as invoice.cancelled. The rest of the invoice family (invoice.created, invoice.finalised, invoice.cancelled, invoice.payment_status.updated and others) and the buyer, tax connection, organization and billing families are in the catalogue.
A delivery
Yona sends an HTTP POST with a JSON body:
{
"id": "0b6f2c1e-8d4a-4e7b-9c3f-5a1d2e3f4a5b",
"type": "invoice.signed",
"version": 1,
"createdAt": "2026-10-01T10:00:05.000Z",
"mode": "sandbox",
"organizationId": "9f8e7d6c-5b4a-4321-8edc-ba9876543210",
"data": {
"invoiceId": "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6",
"status": "signed",
"submissionId": "e2a7c9d1-4b3f-4c5e-8d6a-7f9b0c1d2e3f",
"authorityState": "registered",
"authorityReference": "INV00042-94ND90NR-20261001"
}
}A test event sent from the app or with POST /n/v1/webhook-endpoints/{id}/test also carries "test": true. The headers:
| Header | Content |
|---|---|
Yona-Signature | t=<unix seconds>,v1=<hex>; during a secret rotation a second v1= signed with the previous secret is appended |
Yona-Event-Id | The event’s id; the same event is never two ids |
Yona-Event-Type | The event type |
Yona-Delivery-Id | This delivery’s id |
Yona-Delivery-Attempt | 1 for the first attempt, then 2, 3, … |
User-Agent | Yona-Webhooks/1.0 |
Answer with any 2xx within 10 seconds, connection included, and do the work afterwards; a slower answer counts as a failure. Deduplicate on Yona-Event-Id: a retry carries the same id. Yona sends at most 10 deliveries to one endpoint at a time.
Verifying the signature
The signature is HMAC-SHA256 over the string t + "." + body, where body is the raw request body, byte for byte, and the key is your endpoint secret. Compare in constant time, and reject timestamps more than five minutes from your clock. Every attempt is signed afresh with a new t; the body of a retry never changes.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const SECRET = process.env.YONA_WEBHOOK_SECRET; // whsec_…
app.post('/webhooks/yona', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('Yona-Signature') ?? '';
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const t = Number(parts.t);
const given = header.split(',').filter((p) => p.startsWith('v1=')).map((p) => p.slice(3));
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return res.status(400).end();
const expected = crypto.createHmac('sha256', SECRET).update(`${t}.${req.body}`).digest('hex');
const ok = given.some((sig) => sig.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(sig, 'hex'), Buffer.from(expected, 'hex')));
if (!ok) return res.status(400).end();
const event = JSON.parse(req.body);
res.status(200).end();
// handle event, keyed by req.get('Yona-Event-Id')
});Parse the JSON only after the signature checks. Frameworks that parse bodies before your handler runs change the bytes; use the raw body.
Every Yona SDK ships this check as one function (verifyWebhook, verify_webhook in Python, VerifyWebhook in Go) that also accepts both signatures while a rotated secret overlaps, so you can call it instead of writing the comparison yourself.
Retries
A delivery that fails, times out or gets a non-2xx answer is retried with growing delays and a little jitter: eight attempts over about 45 hours. A Retry-After on a 429 or 503, up to one hour, replaces the scheduled delay. An endpoint that has failed for 24 hours is marked failing; after 72 hours of consecutive failures and at least 20 failed attempts it is disabled. Fix the receiver and re-enable it in the app. You can also redeliver any delivery by hand.
Treat events as a nudge
A delivery tells you something changed. Read the current state through the API before acting on it, especially for an invoice: the ladder may have moved on since the event was created.