Receive E-Invoicing Webhooks
Get notified when an invoice is signed, fails in the background, is delivered, or is acknowledged, and verify that each event came from Duplo.
Most e-invoicing calls answer in their own response: create, update, a synchronous submit, and a transmit all return the result directly. Some outcomes arrive later, after the call that started them has returned. Duplo sends a webhook for each of those, so you do not have to poll for them. The sign endpoint is the exception: it returns the signed invoice and also sends INVOICE_SIGNED, the same event a handed-off submit sends, so you can handle signing in one place.
| Event | When it is sent |
|---|---|
INVOICE_SIGNED | NRS signed the invoice, either through the sign endpoint or after a submit that was handed off to background processing. The IRN is now valid. A submit that signs synchronously returns the signed invoice in its response instead |
INVOICE_VALIDATION_FAILED | Background validation failed. The invoice is back to created, so you can edit it and submit again. Sent once per failure, so one invoice can produce several |
INVOICE_SIGN_FAILED | Background signing failed for good and the invoice is rejected, including when the e-invoicing charge was declined. Recover with the resubmit endpoint |
INVOICE_TRANSMITTED | NRS confirmed delivery to the buyer after a transmit whose outcome was not known when the call returned |
INVOICE_ACKNOWLEDGED | The buyer acknowledged an invoice you sent |
Treat any other event_type value as one you do not handle yet: acknowledge it and move on rather than failing the delivery.
Setting up your endpoint
In Duplo Dashboard, open Settings › Developer API, scroll to Webhook, enter your URL, and click Save. When you save, Duplo sends a GET to the URL and keeps it only if that returns a 2xx response.

Test and live mode each keep their own URL, and saving sets the one for the mode your business is in at the time, so save it again after you go live. Events for an invoice go to the URL saved for that invoice's mode, and only while your business has an active API key in that mode.
Your endpoint must:
- Use HTTPS on the default port, at a domain that resolves only to public IP addresses.
- Answer with a
2xxwithout redirecting. Neither the check on save nor a delivery follows redirects. - Respond within 5 seconds. Store the event and return, then do the real work afterwards.
Parsing an event
Every event is a JSON POST with the same envelope:
{
"event_type": "INVOICE_SIGN_FAILED",
"data": {
"invoiceId": "9c1f3b2a-77e4-4c1d-9b6a-2f5d8e0a4c73",
"invoiceReferenceNumber": "DUP00000001-2A3A045D-20240123",
"invoiceNumber": "INV-2024-001",
"status": "rejected",
"nrsStatus": "rejected",
"transmissionStatus": "not_sent",
"environment": "sandbox",
"occurredAt": "2026-11-06T10:00:00.000Z",
"reason": { "code": "nrs_sign_rejected" }
}
}| Field | What it holds |
|---|---|
event_type | One of the event names at the top of this page |
data | A snapshot of the invoice when the event happened: its IDs, status, nrsStatus, and transmissionStatus |
data.environment | sandbox for an invoice made with a test key (sk_test_…), live for a live key (sk_live_…) |
data.occurredAt | When the change happened, in UTC |
data.reason | A machine-readable code on failure events, and null on the others |
The body has no event ID. Each event's ID arrives in the x-duplo-delivery-id header instead.
Events can arrive out of order, for example a retried older event after a newer one. Ignore an event that is older than the state you already hold, and when in doubt, read the invoice back with Get invoice, which is always current.
Each request also carries these headers:
| Header | Value |
|---|---|
x-duplo-delivery-id | Unique per event. Retries of the same event reuse it, so use it to drop duplicates |
x-duplo-event | The event name, the same as the body's event_type |
x-duplo-timestamp | Unix time in seconds when this attempt was signed |
x-duplo-signature | One or more v1=<hex> signatures, separated by commas |
Verifying the signature
Every delivery is signed, so check the signature before you trust the body. Each v1 value is an HMAC-SHA256 of <x-duplo-delivery-id>.<x-duplo-timestamp>.<raw request body>, keyed with one of your secret API keys for the event's data.environment: sk_test_… for sandbox and sk_live_… for live. Your public key (pk_…) is never used.
Duplo signs with every active secret key in that mode, plus any key revoked or deactivated in the last 24 hours, and sends one v1 value per key. A delivery therefore verifies with whichever key you hold, including while you rotate keys. Accept it if any v1 value matches.
- Read the raw request bytes. Parsing the JSON and serializing it again changes them.
- Reject the request if
x-duplo-timestampis more than 5 minutes from your clock. - Compute the HMAC and compare it with each
v1value in constant time. - Return a
2xxquickly, including for a duplicate you have already processed.
import express from "express";
import { createHmac, timingSafeEqual } from "crypto";
function isValidDuploWebhook(
rawBody: Buffer,
headers: Record<string, string>,
secretKey: string,
): boolean {
const id = headers["x-duplo-delivery-id"];
const timestamp = Number(headers["x-duplo-timestamp"]);
if (!id || !Number.isFinite(timestamp)) return false;
if (Math.abs(Date.now() / 1000 - timestamp) > 300) return false;
const expected = createHmac("sha256", secretKey)
.update(`${id}.${timestamp}.${rawBody.toString("utf8")}`)
.digest();
return (headers["x-duplo-signature"] ?? "")
.split(",")
.map((part) => Buffer.from(part.trim().replace(/^v1=/, ""), "hex"))
.some(
(given) =>
given.length === expected.length && timingSafeEqual(given, expected),
);
}
const app = express();
// Read this route's body as raw bytes, ahead of any global express.json().
app.post(
"/webhooks/duplo",
express.raw({ type: "application/json" }),
(req, res) => {
const headers = req.headers as Record<string, string>;
if (!isValidDuploWebhook(req.body, headers, process.env.DUPLO_SECRET_KEY!)) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body.toString("utf8"));
// Store the event unless this x-duplo-delivery-id was already seen, then queue the work.
res.sendStatus(200);
},
);
app.use(express.json());The mistakes that most often break verification are parsing the JSON before verifying it, using the other mode's secret key or the public key, checking only the first v1 value, and comparing with == or === instead of a constant-time function.
Retries
Delivery is at least once. A response other than 2xx, or no response within 5 seconds, is retried after 30 seconds, and the wait doubles after each failed attempt, for up to 8 attempts in all. The last attempt comes about an hour after the first. Every retry is signed again with a fresh timestamp but keeps the same x-duplo-delivery-id, so the same event can reach you more than once.
Because a delivery can still be missed, for instance while your endpoint is down for longer than the retries last, do not rely on webhooks alone for anything that matters. Read the invoice back, or list your invoices, to reconcile on a schedule.
Related guides
How is this guide?
Last updated on