FISCALISTO / API
Webhooks
Receive on your server every invoice stamped, rejected or cancelled, with signed events retried for 3 days.
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.
| Event | When it arrives | data.object |
|---|---|---|
invoice.stamped | A 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.failed | SAT 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_pending | You 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.canceled | It 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_rejected | The 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_failed | Fiscalisto 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_paid | A 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.paid | An 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_bounced | An 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_complained | The customer marked an invoice's email as spam. | Invoice, with email.status: "complained" |
retention.stamped | A withholding certificate was stamped. | Certificate (ret_…), status: "valid" |
retention.failed | SAT or the PAC rejected a certificate. | Certificate, status: "rejected" |
retention.canceled | A certificate was cancelled (they need no acceptance). | Certificate, status: "canceled" |
invoice_batch.completed | No 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.completed | No 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.ready | A 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.completed | A customer sent their tax data with a link. | Request (cdr_…), status: "completed" |
sat_download.completed | A SAT download finished: its invoices are in GET /v1/sat_invoices. | Download (sdl_…), status: "completed" |
sat_download.failed | SAT couldn't finish a download; the reason comes in error. | Download (sdl_…), status: "failed" |
sat_declaration.created | A tax return lookup found a new one. Its files and figures may arrive later. | Tax return (dcl_…) |
sat_declaration.updated | A return's PDF, receipt, financial statements or figures arrived. | Tax return (dcl_…), as it stands |
sat_refresh.completed | A SAT query (returns, opinion, certificate or mailbox) finished and its timbre was used. | SAT query (srf_…), with what it brought in result |
sat_refresh.failed | SAT didn't answer a query; its timbre came back. | SAT query (srf_…), with the reason in error |
ticket.invoiced | Your 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.failed | A 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.viewed | The customer opened a quote's link for the first time. | Quote (quo_…) |
quote.accepted | A quote was accepted: by the customer on its link or by you with POST /v1/quotes/{id}/accept. | Quote, with decided_by |
quote.changes_requested | The customer asked for changes on the link. At most once every 10 minutes. | Quote, with what they wrote in customer_comment |
quote.rejected | The 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.withdrawn | You withdrew the quote: its link no longer lets it be accepted. | Quote, status: "withdrawn" |
sales_order.confirmed | An order was confirmed: it can be delivered and invoiced now. | Order, status: "confirmed" |
sales_order.customer_confirmed | Your customer confirmed the order on its link. | Order, with customer_confirmed_at |
sales_order.delivered | Everything in the order went out. | Order, with delivered_at |
sales_order.paid | The order's invoices were paid. | Order, status: "paid" |
sales_order.canceled | An order was cancelled. | Order, status: "canceled" |
supplier_invoice.received | A supplier sent an invoice through the supplier portal. | Supplier invoice (spi_…), status: "received" |
supplier_invoice.approved | A supplier invoice was approved, at all its levels: it can go to your ERP now. | Supplier invoice, status: "approved" |
supplier_invoice.rejected | A supplier invoice was rejected. | Supplier invoice, with rejection_reason |
supplier_invoice.scheduled | A supplier invoice's payment date was scheduled or changed. | Supplier invoice, with scheduled_on |
supplier_invoice.paid | A supplier invoice was marked paid. | Supplier invoice, status: "paid" |
portal_supplier.approved | A portal supplier's registration was approved: it can send invoices now. | Portal supplier (sup_…), status: "approved" |
payout.approved | A supplier pago has all its signatures: it goes out on its date. | Pago (pyo_…), status: "approved" |
payout.paid | Every transfer of a pago arrived. | Pago, status: "paid" |
payout.partially_paid | A pago ended with transfers that didn't arrive. | Pago, status: "partially_paid" |
payout.failed | No transfer of a pago arrived. | Pago, status: "failed" |
payout.canceled | A pago was canceled before going out. | Pago, with cancel_reason |
payout_transfer.succeeded | A transfer to a supplier arrived. | Transfer (pyt_…), with tracking_key |
payout_transfer.failed | A transfer to a supplier didn't go out. | Transfer, with failure_reason |
payout_transfer.returned | The supplier's bank returned a transfer. | Transfer, with failure_reason |
ticket.included_in_global | A ticket nobody invoiced went into the period's global invoice. | Ticket (tkt_…), status: "global", with the global invoice in global_invoice |
balance.low | The 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.high | The 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.ready | A test clock finished moving forward: each day's work is done. Test only. | Test clock (object: "test_clock") |
rule.matched | A 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.
{
"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", "...": "..." }
}
}| Field | What it is |
|---|---|
id | The event's id. It's the same in the webhook-id header and on every retry: use it to avoid processing it twice. |
type | One of the events in the table. |
api_version | The API version the object was built with. |
livemode | false if it comes from test (fk_test_), true from live. |
created_at | When it happened, Mexico City time. |
data.object | The 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:
| Header | What it is |
|---|---|
webhook-id | The event's id (evt_…). It's the same on every retry. |
webhook-timestamp | When this try was sent, in seconds since 1970. |
webhook-signature | v1, 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).
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);
});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 "", 200Without a library
The signature is the HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body} with your secret without the whsec_ prefix, decoded from base64:
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:
- Add a test webhook with your tunnel's address (see above).
- Stamp an invoice with your test key: with
curl, with an SDK or with Probar in the reference.invoice.stampedarrives. - For
invoice.failed, stamp to one of the test RFCs, likeNOM010101FK9; forinvoice.canceled, cancel the invoice with"motive": "02". - 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
2xxstatus 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-idof those you already processed and ignore repeats. - Events may arrive out of order. To know a document's current state use the
statusof the object the event carries or look it up withGET.
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=falseEach 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?