Skip to content
Concepts

FISCALISTO / API

Webhooks

Receive on your server every invoice stamped, rejected or cancelled, with signed events retried for 3 days.

Open in ChatGPTOpen in ClaudeOpen in Cursor

A webhook is an address on your server where Fiscalisto sends an event every time a document in your account changes. With them your system learns what doesn't happen in a request's answer: a cancellation the customer accepts days later, an invoice the PAC took a while to stamp or a batch that finished.

Event types

These are all there are. Each one carries in data.object the whole object, the same as its GET, with the state it had when it happened. Open one to see the whole event as it arrives, field by field.

EventWhen it arrivesdata.object
invoice.stampedA CFDI was stamped: invoice, payment complement, credit note, advance, its application note, replacement or payroll receipt. It also arrives when one that stayed processing (the PAC didn't answer) is stamped later.Invoice (inv_…), status: "valid"
invoice.failedSAT or the PAC rejected a CFDI. It arrives even if the request already answered 422, and when one in processing ends rejected.Invoice, status: "rejected", with error
invoice.cancellation_pendingYou asked for the cancellation and it isn't done yet: the customer must accept it in their buzón tributario (see when), SAT is finishing it, or Fiscalisto asks again on its own because SAT doesn't accept it yet (see when). It stays valid meanwhile.Invoice, cancellation.status: "pending" (with status: "pending") or "scheduled"
invoice.canceledIt was cancelled: right away, or because the customer accepted or didn't answer in 3 business days.Invoice, status: "canceled", cancellation.status: "accepted"
invoice.cancellation_rejectedThe customer rejected the cancellation, or SAT never got the request. It stays valid; you can ask again.Invoice, status: "valid", cancellation.status: "rejected" or "lapsed"
invoice.cancellation_failedFiscalisto stopped requesting a cancellation SAT didn't accept. It stays valid; request it again.Invoice, status: "valid", cancellation.status: "failed", with cancellation.error
invoice.partially_paidA payment for part of a PPD invoice arrived: a payment complement or a credit note. See Accounts receivable.Invoice, with what's left in amount_due
invoice.paidAn income invoice no longer owes anything: its last complement, a credit note, a reconciled deposit or mark_paid.Invoice, with payment_status: paid
invoice.email_bouncedAn invoice's email didn't reach an address: the mailbox doesn't exist, is full or the domain doesn't take email. Once per address and send.Invoice, with the address and the reason in email.recipients
invoice.email_complainedThe customer marked an invoice's email as spam.Invoice, with email.status: "complained"
retention.stampedA withholding certificate was stamped.Certificate (ret_…), status: "valid"
retention.failedSAT or the PAC rejected a certificate.Certificate, status: "rejected"
retention.canceledA certificate was cancelled (they need no acceptance).Certificate, status: "canceled"
invoice_batch.completedNo invoice of the batch is left to stamp: each was stamped or failed. Each invoice of the batch also sends its invoice.stamped or invoice.failed.Batch (bat_…), status: "completed"
payroll_batch.completedNo receipt of the payroll batch is left to stamp. It carries each employee's receipt: the stamped ones, with their invoice, and the rest, with their error. Each receipt also sends its invoice.stamped or invoice.failed.Payroll batch (pyb_…), with receipts
issuer.readyA live issuer can stamp now: it has its CSD and signed the contract with the PAC. In test, when an onboarding link is finished.Issuer (iss_…), status: "active"
customer_data_request.completedA customer sent their tax data with a link.Request (cdr_…), status: "completed"
sat_download.completedA SAT download finished: its invoices are in GET /v1/sat_invoices.Download (sdl_…), status: "completed"
sat_download.failedSAT couldn't finish a download; the reason comes in error.Download (sdl_…), status: "failed"
sat_declaration.createdA tax return lookup found a new one. Its files and figures may arrive later.Tax return (dcl_…)
sat_declaration.updatedA return's PDF, receipt, financial statements or figures arrived.Tax return (dcl_…), as it stands
sat_refresh.completedA SAT query (returns, opinion, certificate or mailbox) finished and its timbre was used.SAT query (srf_…), with what it brought in result
sat_refresh.failedSAT didn't answer a query; its timbre came back.SAT query (srf_…), with the reason in error
ticket.invoicedYour buyer invoiced a ticket on the self-invoicing portal. Its invoice's invoice.stamped arrives too.Ticket (tkt_…), status: "invoiced", with the invoice in invoice
recurring_invoice.failedA recurring invoice couldn't stamp its period (no timbres, the customer deleted, SAT rejected it). It arrives once; it's tried again each day.Recurring invoice (rin_…), with the reason in last_error
quote.viewedThe customer opened a quote's link for the first time.Quote (quo_…)
quote.acceptedA quote was accepted: by the customer on its link or by you with POST /v1/quotes/{id}/accept.Quote, with decided_by
quote.changes_requestedThe customer asked for changes on the link. At most once every 10 minutes.Quote, with what they wrote in customer_comment
quote.rejectedThe quote was rejected: by the customer on its link or by you with POST /v1/quotes/{id}/reject.Quote, with decided_by and the reason in customer_comment
quote.withdrawnYou withdrew the quote: its link no longer lets it be accepted.Quote, status: "withdrawn"
sales_order.confirmedAn order was confirmed: it can be delivered and invoiced now.Order, status: "confirmed"
sales_order.customer_confirmedYour customer confirmed the order on its link.Order, with customer_confirmed_at
sales_order.deliveredEverything in the order went out.Order, with delivered_at
sales_order.paidThe order's invoices were paid.Order, status: "paid"
sales_order.canceledAn order was cancelled.Order, status: "canceled"
supplier_invoice.receivedA supplier sent an invoice through the supplier portal.Supplier invoice (spi_…), status: "received"
supplier_invoice.approvedA supplier invoice was approved, at all its levels: it can go to your ERP now.Supplier invoice, status: "approved"
supplier_invoice.rejectedA supplier invoice was rejected.Supplier invoice, with rejection_reason
supplier_invoice.scheduledA supplier invoice's payment date was scheduled or changed.Supplier invoice, with scheduled_on
supplier_invoice.paidA supplier invoice was marked paid.Supplier invoice, status: "paid"
portal_supplier.approvedA portal supplier's registration was approved: it can send invoices now.Portal supplier (sup_…), status: "approved"
payout.approvedA supplier pago has all its signatures: it goes out on its date.Pago (pyo_…), status: "approved"
payout.paidEvery transfer of a pago arrived.Pago, status: "paid"
payout.partially_paidA pago ended with transfers that didn't arrive.Pago, status: "partially_paid"
payout.failedNo transfer of a pago arrived.Pago, status: "failed"
payout.canceledA pago was canceled before going out.Pago, with cancel_reason
payout_transfer.succeededA transfer to a supplier arrived.Transfer (pyt_…), with tracking_key
payout_transfer.failedA transfer to a supplier didn't go out.Transfer, with failure_reason
payout_transfer.returnedThe supplier's bank returned a transfer.Transfer, with failure_reason
ticket.included_in_globalA ticket nobody invoiced went into the period's global invoice.Ticket (tkt_…), status: "global", with the global invoice in global_invoice
balance.lowThe account has few live timbres left: when it drops to low_balance_at and again when they run out, once each until it has more again. See What a timbre costs.Balance (object: "balance"), like GET /v1/balance; always livemode: true
usage.highThe API used 80 % of its live requests of the last 30 days, and again at 100 % (once each per month). See Requests per month.Usage (object: "usage"); always livemode: true
test_clock.readyA test clock finished moving forward: each day's work is done. Test only.Test clock (object: "test_clock")
rule.matchedA rule with the webhook action matched. It only reaches that rule's webhook, even if others listen to every event.Which rule, the record and every field of its conditions (object: "rule_match"); always livemode: true

What sends no event: creating or changing customers, products, issuers and webhooks (your system does that and already has the answer), and email sends.

invoice.stamped
{
  "id": "evt_0PKhIdhYuAGwzmMQYfkc",
  "object": "event",
  "type": "invoice.stamped",
  "api_version": "2026-10-24",
  "livemode": false,
  "created_at": "2026-10-24T10:15:42-06:00",
  "data": {
    "object": { "id": "inv_OufpKqnrvx9p28SINJVjjWKYRhojBTJb8P", "object": "invoice", "status": "valid", "...": "..." }
  }
}
FieldWhat it is
idThe event's id. It's the same in the webhook-id header and on every retry: use it to avoid processing it twice.
typeOne of the events in the table.
api_versionThe API version the object was built with.
livemodefalse if it comes from test (fk_test_), true from live.
created_atWhen it happened, Mexico City time.
data.objectThe whole object.

Each event's page (in the table above) has a complete example of what it sends, and GET /v1/events returns those of the last 30 days.

Adding a webhook

Each url goes in a single endpoint per mode, so no event arrives twice: creating another with the same one answers 400 endpoint_exists with the id of the one that has it, to change it with POST /v1/webhook_endpoints/{id}.

curl https://api.fiscalisto.com/v1/webhook_endpoints \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://mi-plataforma.mx/webhooks/fiscalisto",
    "events": ["invoice.stamped", "invoice.failed", "invoice.canceled"]
  }'

The answer carries the secret (whsec_…) once: keep it on your server. Without events it receives all of them. You can also add it in Desarrolladores › Webhooks. Each mode has its own webhooks: one created with an fk_test_ key only receives test events.

The address must be https and public. Redirects aren't followed: use the final address. To test on your computer you don't need a tunnel: npx fiscalisto listen --forward-to http://localhost:3000/webhooks/fiscalisto forwards your test account's events to you signed just like the real ones, and npx fiscalisto trigger invoice.stamped triggers one (see CLI). If you'd rather register a real endpoint, open a tunnel (cloudflared tunnel --url http://localhost:3000 or ngrok http 3000) and register the https address it gives you.

Verifying the signature

Every event arrives as a POST with three headers, per Standard Webhooks:

HeaderWhat it is
webhook-idThe event's id (evt_…). It's the same on every retry.
webhook-timestampWhen this try was sent, in seconds since 1970.
webhook-signaturev1, and the HMAC-SHA256 signature in base64. It may carry several separated by spaces.

Always verify the signature before trusting the event: anyone can send a POST to your address. With the SDKs it's one line and doesn't need the API key: verifyWebhook(body, headers, secret) in TypeScript, verify_webhook(…) in Python, Webhook::verify(…) in PHP, fiscalisto.VerifyWebhook(…) in Go, Webhooks.verify(…) in Java and FiscalistoClient.Webhooks.Verify(…) in C#. In another language, the standardwebhooks library does the same (Ruby, Rust and the rest).

Node.js (Express) with the SDK
import express from "express";
import { verifyWebhook } from "fiscalisto";

const app = express();

// El cuerpo tal como llegó, sin convertirlo a JSON: la firma es de esos bytes.
app.post("/webhooks/fiscalisto", express.raw({ type: "application/json" }), async (req, res) => {
  let event;
  try {
    event = await verifyWebhook(req.body, req.headers, process.env.FISCALISTO_WEBHOOK_SECRET);
  } catch {
    return res.status(400).send("Firma inválida");
  }
  res.sendStatus(200); // Responda rápido; procese después.
  procesar(event);
});
Python (Flask) with the SDK
import os
from flask import Flask, request
from fiscalisto import FiscalistoWebhookError, verify_webhook

app = Flask(__name__)

@app.post("/webhooks/fiscalisto")
def fiscalisto():
    try:
        event = verify_webhook(
            request.get_data(), request.headers, os.environ["FISCALISTO_WEBHOOK_SECRET"]
        )
    except FiscalistoWebhookError:
        return "Firma inválida", 400
    procesar(event)
    return "", 200

Without a library

The signature is the HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body} with your secret without the whsec_ prefix, decoded from base64:

verificar.py
import base64, hashlib, hmac, json, time

def verificar(secreto, headers, cuerpo: bytes):
    msg_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > 300:
        raise ValueError("Evento viejo: puede ser una repetición maliciosa")
    llave = base64.b64decode(secreto.removeprefix("whsec_"))
    firmado = f"{msg_id}.{timestamp}.".encode() + cuerpo
    esperada = base64.b64encode(hmac.new(llave, firmado, hashlib.sha256).digest()).decode()
    for firma in headers["webhook-signature"].split(" "):
        version, _, valor = firma.partition(",")
        if version == "v1" and hmac.compare_digest(valor, esperada):
            return json.loads(cuerpo)
    raise ValueError("Firma inválida")

Reject events more than 5 minutes off in webhook-timestamp: that way nobody can replay an old one.

Testing your webhooks

With an fk_test_ key everything happens in test and your test webhooks receive real events:

  1. Add a test webhook with your tunnel's address (see above).
  2. Stamp an invoice with your test key: with curl, with an SDK or with Probar in the reference. invoice.stamped arrives.
  3. For invoice.failed, stamp to one of the test RFCs, like NOM010101FK9; for invoice.canceled, cancel the invoice with "motive": "02".
  4. In Desarrolladores › Webhooks see each delivery with what your server answered, and resend it as many times as you like while you fix your code. Desarrolladores › Eventos has every event, with what was sent and each delivery.

A test event, without stamping

To test your code with any event, send a test one to your webhook. It arrives right away, once, signed like real ones, with a sample object (its ids don't exist), even if the webhook doesn't listen to that type:

curl https://api.fiscalisto.com/v1/webhook_endpoints/whe_8Kq2ZtR4mNw1Lp0sXc7V/test \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "type": "invoice.failed" }'

The answer carries the event that was sent and what your server answered:

{
  "object": "webhook_test",
  "event": { "id": "evt_0PKhIdhYuAGwzmMQYfkc", "object": "event", "type": "invoice.failed", "...": "..." },
  "delivery": { "ok": true, "status": 200, "error": null, "response_body": "{\"received\":true}", "duration_ms": 182 }
}

Without type it sends invoice.stamped. In the dashboard it's Mandar evento de prueba, on each webhook. The test event doesn't show in GET /v1/events, but it does in the webhook's deliveries, and you can resend it.

Responding

  • Answer a 2xx status in under 15 seconds. Any other status, a redirect or not answering in time counts as a failure.
  • Answer first and process later (in a queue or in the background), so you don't go over 15 seconds.
  • An event may arrive more than once. Keep the webhook-id of those you already processed and ignore repeats.
  • Events may arrive out of order. To know a document's current state use the status of the object the event carries or look it up with GET.

Retries

If your server fails, we retry the same event for about 3 days: after 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 10 hours, then every 12 hours four more times, so a server down over a weekend loses no events. Each try carries the same webhook-id and a new webhook-timestamp.

A webhook that fails every retry goes to status: "failing". If it stays like that 5 days, it's turned off ("disabled") and stops receiving events; turn it back on with POST /v1/webhook_endpoints/{id} and "disabled": false, or in the dashboard. If your server answers 410 Gone, we take it that the address no longer exists: the webhook is turned off right then (disabled_reason: "gone"), without waiting 5 days. In Desarrolladores › Webhooks each webhook shows its last 7 days (delivered, failed, error rate and average response) and its deliveries with what your server answered, and you can resend any. Reenviar (resend) is a separate try, now: it doesn't change the automatic retries, and if it arrives, there are no more retries.

When a production webhook has received nothing for a few hours, we email the account's owners and admins, with the address and what your server answered; and again if it's turned off. Test webhooks send no email.

If you missed events, GET /v1/events has those of the last 30 days; filter by type (one, or all of a resource's with a wildcard: invoice.*), by object (the document's id) or with delivery_success=false for those some webhook didn't receive:

curl "https://api.fiscalisto.com/v1/events?type=invoice.*&delivery_success=false" \
  -H "Authorization: Bearer $FISCALISTO_API_KEY"

Once your server answers, send each one again with POST /v1/events/{id}/resend. With endpoint it goes only to that webhook; without it, to all the enabled ones that listen to that event type. It's the dashboard's same Reenviar: a separate try, now, with the same webhook-id, so your server recognizes it if it already processed it.

curl https://api.fiscalisto.com/v1/events/evt_0PKhIdhYuAGwzmMQYfkc/resend \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "endpoint": "whe_8Kq2ZtR4mNw1Lp0sXc7V" }'

Seeing a webhook's deliveries

GET /v1/webhook_endpoints/{id}/deliveries tells you what happened with each event on that webhook, most recent first: whether it arrived (succeeded), what your server answered (status, error, duration_ms), how many tries it has had (attempts) and when the next retry goes (next_retry_at). It's the same Entregas list as the dashboard. With succeeded=false you see only those your server didn't receive:

curl -G https://api.fiscalisto.com/v1/webhook_endpoints/whe_8Kq2ZtR4mNw1Lp0sXc7V/deliveries \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -d succeeded=false

Each row is an event with its last try; for the next page send the id (whd_…) of the last one in starting_after.

Recovering everything that didn't arrive

After your server was down, POST /v1/webhook_endpoints/{id}/recover sends again, now, every event since since that the webhook listens to and didn't receive: those whose tries all failed and those that happened while it was turned off. They go out oldest first, up to 1,000 per call; if more are left, next_since says where to call again from. Each one carries its usual webhook-id, so your server can drop the ones it already had. since must be within the last 30 days (what we keep), and the webhook must be turned on. In the dashboard it's Reenviar fallidas (resend failed), on each webhook.

curl https://api.fiscalisto.com/v1/webhook_endpoints/whe_8Kq2ZtR4mNw1Lp0sXc7V/recover \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "since": "2026-11-20T09:00:00-06:00" }'

Rolling the secret

POST /v1/webhook_endpoints/{id}/roll_secret gives you a new secret. The old one keeps signing for 24 hours: meanwhile each event carries two signatures, one with each secret, and verification passes with either. Switch your server to the new one within that time. For another term send previous_secret_expires_in in seconds; if the secret leaked, send 0 and the old one stops signing right then.

curl -X POST https://api.fiscalisto.com/v1/webhook_endpoints/whe_0q1Vmmw52sbDpmtsKD1E/roll_secret \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "previous_secret_expires_in": 0 }'

Was this page helpful?