Receiving webhooks
Outbound request format, event types, retries and signature verification.
Conceito Fiscal sends a JSON POST to your registered URL. Respond with HTTP 2xx within 10 seconds; enqueue slow work in your receiver.
Request format
- Method:
POST. - Headers:
Content-Type: application/json,X-Conceito-Signature: t=<unix>,v1=<hex>,X-Conceito-Event-Id: <id>,X-Conceito-Event-Type: <event>. - Body: a JSON envelope with
id,type,environment,createdAtanddata.
json
{
"id": "evt_identifier",
"type": "nfse.invoice.authorized",
"environment": "test",
"createdAt": "2026-10-10T14:00:00.000Z",
"data": {
"invoiceId": "INVOICE_UUID",
"companyId": "COMPANY_UUID",
"environment": "test",
"status": "authorized",
"documentsStatus": "pending",
"emailStatus": null,
"stage": "authorized",
"accessKey": "ACCESS_KEY",
"nfseNumber": 123
}
}data varies by event; in the fiscal flow it includes the invoice's identification and state. Authorization adds accessKey/nfseNumber, rejection adds errorCode/errorMessage, manual review adds reason, ready documents add accessKey/nfseNumber/documentsReadyAt, and a sent email adds sentAt. The test event carries { "message": "This is a test webhook event" }.
Event types
| Event type | When |
|---|---|
nfse.invoice.authorized | The invoice was authorized; adds accessKey/nfseNumber. |
nfse.invoice.rejected | Authorization was rejected; adds errorCode/errorMessage. |
nfse.invoice.failed | Processing failed. |
nfse.invoice.reconciliation_required | Reconciliation is required. |
nfse.invoice.manual_review | Manual review is required; adds reason. |
nfse.invoice.documents_ready | Documents are ready; adds accessKey/nfseNumber/documentsReadyAt. |
nfse.invoice.email_sent | The notification email was sent; adds sentAt. |
nfse.invoice.email_failed | The notification email failed. |
nfse.invoice.fiscal_discrepancy | invoiceId, status and differences[] (field, local, authorized, delta, kind): difference between Conceito Fiscal's calculation and the authorized NFS-e, above R$ 0.01 per tax. The authorized XML is not changed. |
nfse.invoice.cancelled | The invoice was cancelled; adds reason. When it was cancelled directly on the national portal, it also adds source: "portal". |
nfse.invoice.cancellation_rejected | The Sefin refused the cancellation; the invoice is authorized again; adds errorCode and errorMessage. |
nfse.invoice.taker_rejected | The taker rejected the invoice on the national portal; it stays authorized; adds reason (may be null) and source: "portal". |
webhook.test | Sent by the test route; carries { "message": "This is a test webhook event" }. |
Signature verification
The signature is the HMAC-SHA256 of <t>.<rawBody> (Unix timestamp + dot + raw JSON body bytes) with the configuration's secret, in hex. Verify the raw received body bytes — do not parse and stringify before verifying — and reject timestamps outside your tolerance window (default: 300 seconds).
javascript
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyWebhookSignature(rawBody, signatureHeader, secret, toleranceSec = 300) {
if (typeof signatureHeader !== "string") return false;
const parts = Object.fromEntries(signatureHeader.split(",").map((p) => p.split("=")));
const timestamp = Number(parts.t);
if (!Number.isFinite(timestamp) || !/^[a-f0-9]{64}$/.test(parts.v1 ?? "")) return false;
if (Math.abs(Math.floor(Date.now() / 1000) - timestamp) > toleranceSec) return false;
const payload = Buffer.concat([Buffer.from(`${parts.t}.`), Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody)]);
const expected = createHmac("sha256", secret).update(payload).digest();
return timingSafeEqual(Buffer.from(parts.v1, "hex"), expected);
}Retries and delivery semantics
- The outbox makes up to 5 attempts, with intervals after a failure of 60 seconds, 160 seconds, 15 minutes and 30 minutes; execution depends on the worker.
- Retries preserve the original payload — deduplicate by the event
id. - The receiver may get the same event again; the current signature has no separate verification timestamp, so deduplication on the receiver is required.
- Do not assume a global delivery order.