Skip to main content
You’re viewing the current (v1) contract. The order snapshot carried here follows the v1 order.completed contract — order/product discounts, granular taxes, full itemType enum, deliveryConfirmationCode — plus the fiscal authorization block.
order.invoiced fires once the country’s fiscal authority authorizes the fiscal document associated with an order — SEFAZ in Brazil, SRI in Ecuador, DIAN in Colombia, AFIP in Argentina, SII in Chile, SENIAT in Venezuela. It is emitted by Fire’s fiscal pipeline, which integrates with your fiscal provider as the document provider. This event is separate from order.completed: the order is paid first (order.completed), then Fire requests fiscal emission via your fiscal provider, and order.invoiced fires only when the fiscal authority returns the authorization.

Trigger condition

Fire emits order.invoiced once per fiscal document, the first time all of these are true:
  • The order is in a store with fiscal billing enabled (storeFiscalConfig.enabled === true)
  • A fiscal document was emitted to your fiscal provider
  • your fiscal provider reports that the fiscal authority authorized the document (status transitions to authorized; in Brazil this maps to the SEFAZ cStat authorized code)
CoverageAll countries — Brazil (NFC-e/NF-e via SEFAZ) and CO/EC/CL/AR/VE via the generic fiscal callback. The country travels in fiscal.countryCode, no longer in the event name
Document typesVary by country — nfce/nfe (BR), electronic invoice (CO/EC/CL/AR/VE). Arrives in fiscal.docSubtype
Idempotency keyevent.id
Fires more than onceNo, unless retried
Latency relative to order.completedUsually seconds; can be minutes if the fiscal authority is degraded

What’s in trigger.data

Same V4 order snapshot as order.completed plus a top-level fiscal block carrying the authorized document references. Fields vary by country — Brazil is shown below (chaveAcesso, protocolo); other countries carry their own identifiers (cufe in CO, claveAcceso in EC, cae in AR, etc.). See the generic fiscal callback for the per-country contract. The order’s status remains "COMPLETED" and paymentStatus remains "SUCCEEDED" — fiscal authorization does not change order status.

Example — real production payload (BR, sanitized)

{
  "event": {
    "id": "...",
    "type": "order.invoiced",
    "createdAt": "2026-05-06T01:23:11.000Z"
  },
  "data": {
    "orderId": "8017b54c-af0c-4246-a60a-a0d4ae9a0fef",
    "orderCode": "OC-br-001",
    "businessDayDate": "2026-03-31",
    "externalOrderId": "8017b54c-af0c-4246-a60a-a0d4ae9a0fef",
    "status": "COMPLETED",
    "paymentStatus": "SUCCEEDED",
    "createdAt": "2026-05-06T01:22:56.488Z",
    "store": { /* same as order.completed — includes storeFiscalConfig with CNPJ, legalName */ },
    "client": { /* ... */ },
    "payments": { /* ... — includes payments.metadata.fiscal aggregates */ },
    "orderLines": [ /* ... */ ],
    "fulfillment": { /* ... */ },
    "device": { /* ... */ },
    "channel": { /* ... */ },
    "operator": { /* ... */ },
    "kds": { /* ... */ },
    "marketing": null,
    "metadata": {},

    "fiscal": {
      "status": "authorized",
      "docSubtype": "nfce",
      "chaveAcesso": "41201008187168000160558050010000131609769080",
      "numero": "1000013",
      "serie": null,
      "protocolo": "141200000956123",
      "providerDocId": "69fa97fe427d1240856e1282",
      "pdfUrl": "https://api.fiscal-provider.example/nfce/69fa97fe427d1240856e1282/pdf",
      "xmlUrl": "https://api.fiscal-provider.example/nfce/69fa97fe427d1240856e1282/xml",
      "dataAutorizacao": "2026-05-06T01:23:10.991Z",
      "cStat": null
    }
  },
  "_meta": { "executionId": "...", "flowId": "...", "attempt": "1" }
}

data.fiscal reference

fiscal
object
SEFAZ-authorized document references.

Where the fiscal totals live

The aggregate fiscal values (vBC, vNF, vICMS, etc.) are not inside data.fiscal — they’re in data.payments.metadata.fiscal, the same place order.completed carries them. order.invoiced does not duplicate them; treat the order snapshot as the single source of truth for monetary aggregates. Per-line classification (NCM, CFOP, CSOSN, fiscalCategoryCode) lives in data.orderLines[n].metadata.fiscal. Same as in order.completed. The data.store.storeFiscalConfig block carries the emitter identity (CNPJ, legalName, tradeName) — also unchanged from order.completed.

Handler example

async function onFiscalAuthorized(data) {
  const { orderId, fiscal, store } = data;

  // 1. Persist the SEFAZ authorization for audit
  await db.fiscalDocs.upsert({
    where: { providerDocId: fiscal.providerDocId },
    create: {
      providerDocId: fiscal.providerDocId,
      fireOrderId: orderId,
      country: "BR",
      cnpj: store.storeFiscalConfig.govIdNumber,
      docSubtype: fiscal.docSubtype,
      chaveAcesso: fiscal.chaveAcesso,
      protocolo: fiscal.protocolo,
      authorizedAt: new Date(fiscal.dataAutorizacao),
      status: "authorized",
    },
    update: {},
  });

  // 2. Fetch the canonical XML for archival (legally required in BR)
  const xml = await fetch(fiscal.xmlUrl).then(r => r.text());
  await archive.put(`xml/${fiscal.providerDocId}.xml`, xml);

  // 3. Notify the customer with the PDF link
  await mailer.send({
    to: data.client?.email,
    template: "fiscal-receipt",
    pdf: fiscal.pdfUrl,
  });
}

Common pitfalls

  • status === "authorized", not "COMPLETED". The data.status (the order status) is "COMPLETED"; the fiscal status is in data.fiscal.status.
  • pdfUrl and xmlUrl may be ephemeral. In production, your fiscal provider may sign/expire these links. Download and persist the artifacts on receipt rather than linking customers directly to your fiscal provider.
  • cStat is often null. Don’t make logic depend on it. Use status === "authorized" and protocolo as the authoritative signals.
  • No event for rejected / denied / error. If SEFAZ rejects the document, no event fires today. The fiscal document’s status is persisted internally but no flow is triggered. Watch for this in the roadmap.
  • The country no longer lives in the event name. order.invoiced fires for all countries; filter on fiscal.countryCode. The fiscal block fields vary per country (chaveAcesso/protocolo in BR, cufe in CO, claveAcceso in EC, etc.).

order.completed

Fires before this event — the order itself.

order.reversed

Fires later if the document gets cancelled at SEFAZ.