Skip to content

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.

Open in ChatGPTOpen in ClaudeOpen in Cursor

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.

SDKRuns onInstall
TypeScriptNode 20 or newer, Bun, Deno, Cloudflare Workersnpm install fiscalisto
PythonPython 3.10 or newerpip install fiscalisto
PHPPHP 8.1 or newer, with curl and jsoncomposer require fiscalisto/fiscalisto
.NET (C#).NET 8 or newerdotnet add package Fiscalisto
GoGo 1.23 or newergo get fiscalisto.com/go
JavaJava 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.

RouteTypeScriptPythonPHP
POST /v1/invoicesinvoices.create({…})invoices.create({…})invoices->create([…])
GET /v1/invoices/{id}invoices.get("inv_…")invoices.get("inv_…")invoices->get('inv_…')
GET /v1/invoices/{id}/pdfinvoices.pdf(id): Uint8Arrayinvoices.pdf(id): bytesinvoices->pdf($id): string
GET /v1/invoices/{id}/xmlinvoices.xml(id)invoices.xml(id)invoices->xml($id)
POST /v1/invoices/{id}/cancelinvoices.cancel(id, { motive: "02" })invoices.cancel(id, {"motive": "02"})invoices->cancel($id, ['motive' => '02'])
POST /v1/paymentspayments.create({…})payments.create({…})payments->create([…])
POST /v1/credit_notescreditNotes.create({…})credit_notes.create({…})creditNotes->create([…])
POST /v1/invoice_batchesinvoiceBatches.create({…})invoice_batches.create({…})invoiceBatches->create([…])
POST /v1/payroll_batchespayrollBatches.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_secretwebhookEndpoints.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 (honoring Retry-After up to 60 seconds) and requests with the same Idempotency-Key still in progress (409 request_in_progress).
  • Network errors and 5xxs: reads and deletes change nothing when repeated, and a POST with 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.

DataTypeScriptPythonPHPC#GoJava
Type (invalid_request_error, invoice_error…)error.typee.type$e->typee.Typee.Typee.getType()
Code (invoice_rejected…)error.codee.code$e->errorCodee.Codee.Codee.getCode()
What to fixerror.messagee.message$e->getMessage()e.Messagee.Messagee.getMessage()
Field with the problemerror.parame.param$e->parame.Parame.Parame.getParam()
SAT code (CFDI40145…)error.satCodee.sat_code$e->satCodee.SatCodee.SatCodee.getSatCode()
The document that remainederror.invoicee.invoice$e->invoicee.Invoicee.Invoicee.getInvoice()
HTTP statuserror.statuse.status$e->statuse.StatusCodee.StatusCodee.getStatusCode()
Request id, for supporterror.requestIde.request_id$e->requestIde.RequestIde.RequestIDe.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.

ProjectDownloadRun it
Next.js (App Router)nextjs.zipnpm install && npm run dev
Laravellaravel.zipcomposer install && php artisan serve
Djangodjango.zippip install -r requirements.txt && python manage.py runserver
ASP.NET Coreaspnet.zipdotnet 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?