FISCALISTO / API
SDKs: TypeScript, Python, PHP, .NET, Go and Java
Stamp from Node, Bun, Deno, Workers, Python, PHP, .NET, Go or Java with types for every field, safe retries and webhooks verified in one line.
The six SDKs are the same API with their language's names: they're generated from the same OpenAPI document, so they have every route and every field, with its description and the name it carries in SAT's XML. None has dependencies, except Jackson in Java.
| SDK | Runs on | Install |
|---|---|---|
| TypeScript | Node 20 or newer, Bun, Deno, Cloudflare Workers | npm install fiscalisto |
| Python | Python 3.10 or newer | pip install fiscalisto |
| PHP | PHP 8.1 or newer, with curl and json | composer require fiscalisto/fiscalisto |
| .NET (C#) | .NET 8 or newer | dotnet add package Fiscalisto |
| Go | Go 1.23 or newer | go get fiscalisto.com/go |
| Java | Java 17 or newer (Kotlin too) | Maven com.fiscalisto:fiscalisto |
import { Fiscalisto } from "fiscalisto";
const fiscalisto = new Fiscalisto(); // la llave viene de FISCALISTO_API_KEY
const invoice = await fiscalisto.invoices.create(
{
customer: { tax_id: "ICV060329BY0", legal_name: "INMOBILIARIA CVA", tax_system: "601", zip: "33826" },
payment_form: "03",
items: [{ description: "Mensualidad", product_key: "86121700", quantity: 2, unit_price: 2500 }],
},
{ idempotencyKey: "pedido-A-1042" },
);
console.log(invoice.uuid, invoice.total);You can also pass the key when creating the client: new Fiscalisto("fk_test_…"), Fiscalisto("fk_test_…"), new Fiscalisto('fk_test_…'), new FiscalistoClient("fk_test_…") (in C# and Java) or fiscalisto.NewClient("fk_test_…"). With an fk_test_ key everything is stamped in SAT's test environment; with an fk_live_ one, in live (see Test and live).
One method per route
Methods carry the resource's name and what they do. Fields are the API's own, in English with underscores, so the reference applies as is: every page has the example in all six languages.
| Route | TypeScript | Python | PHP |
|---|---|---|---|
POST /v1/invoices | invoices.create({…}) | invoices.create({…}) | invoices->create([…]) |
GET /v1/invoices/{id} | invoices.get("inv_…") | invoices.get("inv_…") | invoices->get('inv_…') |
GET /v1/invoices/{id}/pdf | invoices.pdf(id): Uint8Array | invoices.pdf(id): bytes | invoices->pdf($id): string |
GET /v1/invoices/{id}/xml | invoices.xml(id) | invoices.xml(id) | invoices->xml($id) |
POST /v1/invoices/{id}/cancel | invoices.cancel(id, { motive: "02" }) | invoices.cancel(id, {"motive": "02"}) | invoices->cancel($id, ['motive' => '02']) |
POST /v1/payments | payments.create({…}) | payments.create({…}) | payments->create([…]) |
POST /v1/credit_notes | creditNotes.create({…}) | credit_notes.create({…}) | creditNotes->create([…]) |
POST /v1/invoice_batches | invoiceBatches.create({…}) | invoice_batches.create({…}) | invoiceBatches->create([…]) |
POST /v1/payroll_batches | payrollBatches.create({…}) | payroll_batches.create({…}) | payrollBatches->create([…]) |
GET /v1/sat_catalogs/{name} | satCatalogs.get("product_keys", { q }) | sat_catalogs.get("product_keys", {"q": q}) | satCatalogs->get('product_keys', ['q' => $q]) |
POST /v1/webhook_endpoints/{id}/roll_secret | webhookEndpoints.rollSecret(id) | webhook_endpoints.roll_secret(id) | webhookEndpoints->rollSecret($id) |
In Python resources and methods use underscores (credit_notes, roll_secret); in TypeScript and PHP, creditNotes and rollSecret; in C#, capitalized with Async (fiscalisto.CreditNotes.CreateAsync(…), fiscalisto.WebhookEndpoints.RollSecretAsync(id)), and fields as properties (TaxId, UnitPrice). In TypeScript each answer has its type (Invoice, Customer…); in Python it's a TypedDict your editor and mypy check; in PHP it's an array with its shape documented for PHPStan and Psalm; in C# it's a class (Invoice, Customer…) with each field's description in your editor, and so is what you send (InvoiceCreate, CancelInvoiceParams…), with required on what's mandatory so the compiler warns you.
In Go, each resource is a field of the client (client.Invoices.Create(ctx, …), client.WebhookEndpoints.RollSecret(ctx, id, nil)), what you send is a struct (InvoiceCreate, CancelInvoiceParams…) and optional values are pointers: fiscalisto.String("PUE"), fiscalisto.Float64(2500), fiscalisto.Int64(10). A customer is an id or its data: fiscalisto.IDOf[fiscalisto.InvoiceCreateCustomer]("cus_…") or fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{…}). In Java, each resource is a method (fiscalisto.invoices().create(…), fiscalisto.webhookEndpoints().rollSecret(id)) and each class has chained setters (new InvoiceCreate().setPaymentForm("03")); amounts are BigDecimal and setters accept a number too.
import { writeFile } from "node:fs/promises";
await writeFile("factura.pdf", await fiscalisto.invoices.pdf(invoice.id));Idempotency-Key without thinking
Whatever stamps always carries its Idempotency-Key. If you don't pass one, the SDK creates one per call and repeats it on its retries, so a network drop never stamps twice. Pass yours (idempotencyKey, idempotency_key=, 'idempotency_key' =>, new RequestOptions { IdempotencyKey = … }, fiscalisto.WithIdempotencyKey(…) or RequestOptions.idempotencyKey(…)) when you want repeating the call from your system, even after a restart, to answer the same invoice. See Idempotency.
Safe retries
Each SDK sends a new Idempotency-Key on each POST (the same on its retries) and retries twice, with a growing wait (half a second, one, two… up to eight), only what can't do anything twice:
429s (honoringRetry-Afterup to 60 seconds) and requests with the sameIdempotency-Keystill in progress (409request_in_progress).- Network errors and
5xxs: reads and deletes change nothing when repeated, and aPOSTwith the same key answers what it did the first time.
If you pass your own key (your order's id), your retries are protected too even if your process restarts. A custom request without a key, through the generic request method, isn't repeated if it may have arrived. Change how many retries and how long to wait for each answer, for the whole client or for one call:
const fiscalisto = new Fiscalisto(undefined, { maxRetries: 4, timeout: 30_000 }); // milisegundos
await fiscalisto.invoices.get("inv_…", { maxRetries: 0 });In .NET you can pass your own HttpClient (for example from IHttpClientFactory) in FiscalistoClientOptions.HttpClient; use a single FiscalistoClient across the application (register it as a singleton). In Go pass your own *http.Client with fiscalisto.WithHTTPClient(…) and in Java your HttpClient with ClientOptions.builder().httpClient(…); the Go and Java clients are also shared across threads and goroutines.
By default each answer is awaited 80 seconds: stamping can take as long as the PAC takes.
Lists
Walking a list gives you every object, page by page, without handling starting_after. For a single page, read data and has_more:
for await (const invoice of fiscalisto.invoices.list({ status: "valid", created_gte: "2026-10-01", limit: 100 })) {
console.log(invoice.uuid, invoice.total);
}
const page = await fiscalisto.customers.list({ limit: 10 });
console.log(page.data.length, page.has_more);Errors
An API error throws FiscalistoError (in PHP, C# and Java, FiscalistoException; in Go the call returns a *fiscalisto.Error) with the same data as the error body. Decide with the code; show the message. Every code is in ErrorCode (ErrorCode.InvoiceRejected, ErrorCode.INVOICE_REJECTED in Python, ErrorCode::INVOICE_REJECTED in PHP, ErrorCode.INVOICE_REJECTED in Java, fiscalisto.CodeInvoiceRejected in Go), with its description in your editor: a misspelled code doesn't compile.
| Data | TypeScript | Python | PHP | C# | Go | Java |
|---|---|---|---|---|---|---|
Type (invalid_request_error, invoice_error…) | error.type | e.type | $e->type | e.Type | e.Type | e.getType() |
Code (invoice_rejected…) | error.code | e.code | $e->errorCode | e.Code | e.Code | e.getCode() |
| What to fix | error.message | e.message | $e->getMessage() | e.Message | e.Message | e.getMessage() |
| Field with the problem | error.param | e.param | $e->param | e.Param | e.Param | e.getParam() |
SAT code (CFDI40145…) | error.satCode | e.sat_code | $e->satCode | e.SatCode | e.SatCode | e.getSatCode() |
| The document that remained | error.invoice | e.invoice | $e->invoice | e.Invoice | e.Invoice | e.getInvoice() |
| HTTP status | error.status | e.status | $e->status | e.StatusCode | e.StatusCode | e.getStatusCode() |
| Request id, for support | error.requestId | e.request_id | $e->requestId | e.RequestId | e.RequestID | e.getRequestId() |
import { ErrorCode, Fiscalisto, FiscalistoError } from "fiscalisto";
try {
await fiscalisto.invoices.create(datos, { idempotencyKey: pedido.id });
} catch (error) {
if (error instanceof FiscalistoError && error.code === ErrorCode.InvoiceRejected) {
// El SAT no la aceptó: error.message dice qué corregir, error.param en qué campo.
await avisarAlCliente(error.message);
} else {
throw error;
}
}If the API doesn't answer, the type is connection_error (code timeout or connection_failed). With whatever stamps, repeat the call with the same Idempotency-Key to find out whether it was stamped. If what answered isn't the API (a proxy's page or a network portal's), the type is api_error with the code invalid_response.
Webhooks
Verifying a webhook doesn't need the API key, only the endpoint's secret (whsec_…): verifyWebhook (TypeScript), verify_webhook (Python), Webhook::verify (PHP), FiscalistoClient.Webhooks.Verify (C#), fiscalisto.VerifyWebhook (Go) and Webhooks.verify (Java) check the signature and the time and give you the event: depending on type, data.object is an invoice, a withholding certificate or a batch. Pass the body exactly as it arrived, without parsing it. If the signature isn't valid or the event is more than 5 minutes old, it throws FiscalistoWebhookError (in PHP, WebhookException; in C#, FiscalistoWebhookException; in Java, Webhooks.VerificationException; in Go it returns an error with errors.Is(err, fiscalisto.ErrWebhookSignature)): answer 400.
// Next.js (app/webhooks/fiscalisto/route.ts); en Bun, Deno, Hono o Workers es igual.
import { FiscalistoWebhookError, verifyWebhook } from "fiscalisto";
export async function POST(request: Request) {
try {
const event = await verifyWebhook(
await request.text(),
request.headers,
process.env.FISCALISTO_WEBHOOK_SECRET as string,
);
if (event.type === "invoice.stamped") await guardar(event.data.object.uuid);
return new Response(null, { status: 200 });
} catch (error) {
if (error instanceof FiscalistoWebhookError) return new Response(null, { status: 400 });
throw error;
}
}With a client already created, fiscalisto.webhooks.verify(…) ($fiscalisto->webhooks->verify(…) in PHP) does the same. During a secret roll two signatures arrive and one matching is enough. See Webhooks.
Starter projects
A small app that already stamps, to copy what you need: a form that stamps a test invoice with its Idempotency-Key, the PDF and XML download, handling a SAT rejection and webhooks with the signature verified. None needs a database.
| Project | Download | Run it |
|---|---|---|
| Next.js (App Router) | nextjs.zip | npm install && npm run dev |
| Laravel | laravel.zip | composer install && php artisan serve |
| Django | django.zip | pip install -r requirements.txt && python manage.py runserver |
| ASP.NET Core | aspnet.zip | dotnet run |
Put your key in FISCALISTO_API_KEY (each one has its .env.example and README) and, for webhooks on your computer, run npx fiscalisto listen --forward-to http://localhost:…/webhooks/fiscalisto (see CLI).
Postman, Bruno and Insomnia
To try it without writing code, import the API collection: one folder per resource, each route with its example and a new Idempotency-Key on whatever stamps. Postman opens it directly; in Bruno use Import Collection › Postman Collection, and in Insomnia Import. The key goes in the collection's apiKey variable. When you create a test key in Desarrolladores › Llaves, download it with your key already set.
Other languages
For Ruby, Rust or anything else, call the API with your HTTP client (every reference page has the example with curl and fetch) or generate a client from the OpenAPI document.
Was this page helpful?
Test and live
Test for free with fk_test_ keys and go live with your issuer, your timbres and an fk_live_ key.
CLI: invoicing from your terminal
Sign in through the browser, set up the SDK in your project, stamp, cancel and receive webhooks on your computer with a single command. With --json, for agents and scripts.