Authentication
Fiscalapi authenticates every HTTP request with two values. Your tenant (the space in Fiscalapi that holds your issuers, recipients, credits, and data) identifies you, and your API key authorizes the request. This guide shows how to send them.
Required HTTP headers
Include these two headers in every API request:
| Header | Value |
|---|---|
X-TENANT-KEY | Unique identifier of your tenant in Fiscalapi. |
X-API-KEY | API key that authenticates the request. |
The X-TIME-ZONE header is optional. By default, Fiscalapi reads and writes dates without a time zone in the JSON body in America/Mexico_City time. If your system works in another time zone, send it with its IANA name (for example, America/Tijuana). A value that isn't a valid time zone also uses Mexico City time. Each endpoint documents its exceptions, such as fields in UTC or in local time, and the dates of the webhooks.
Requests that create invoices or tickets, or that transfer or withdraw stamps (one credit, used each time you stamp a CFDI), also accept the optional Idempotency-Key header, so you can retry without duplicating the operation. See Idempotent requests.
An API key stays active until you revoke it in the dashboard. If you suspect that one of your API keys has leaked, revoke it right away to protect your resources.
Authenticate requests with the API key and tenant
To access a protected resource, send your API key and tenant in the headers above. This example uses Create an income invoice (POST /api/v4/invoices) to create an income (I) invoice, the regular sales invoice.
Request
curl --location 'https://test.fiscalapi.com/api/v4/invoices' \
--header 'X-TENANT-KEY: <my-tenant>' \
--header 'X-TIME-ZONE: America/Mexico_City' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <my-api-key>' \
--data '{
"versionCode": "4.0",
"series": "F",
"date": "2025-04-17T08:56:40",
"paymentFormCode": "01",
"paymentMethodCode": "PUE",
"currencyCode": "MXN",
"typeCode": "I",
"expeditionZipCode": "42501",
"exchangeRate": 1,
"exportCode": "01",
"issuer": {
"id": "78d380fd-1b69-4e3c-8bc0-4f57737f7d5f"
},
"recipient": {
"id": "bef56254-0892-4558-95c3-f9c8729e4b0e"
},
"items": [
{
"id": "310301b3-1ae9-441b-b463-51a8f9ca8ba2",
"quantity": 9.5,
"discount": 25.85
}
]
}'
Using the SDKs
The official SDKs (.NET, Node.js, Python, PHP, and Java) send the authentication headers for you. Set the tenant and API key once, when you create the client, as in the examples above.