# Record a receipt

`POST https://api.fiscalisto.com/v1/tickets`

A sale your buyer invoices themselves: with the code (code) and the total on the issuer's portal (url, which you can embed in your page with fiscalisto.js), they give their tax data and the invoice is stamped at once with your account's stamps. What nobody invoices goes on its own into the period's global invoice. Recording the same folio again with the same total answers the receipt that already exists (retries are safe); with another total, 409. A sale of several line items (a hotel folio) goes in lines, each with its SAT key, description, taxes and amount.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header |  | Optional (the SDKs send it on their own). If the response is lost, repeat the request with the same value within 24 hours: it answers the same, with idempotent-replayed: true, and doesn't do it twice (it doesn't create, send emails or charge). |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `issuer` | string |  | The issuer (iss_…) that sold. By default, your only issuer. |
| `folio` | string | yes | The sale's folio in your system, unique per issuer: letters, numbers, - _ / and period. Recording the same folio with the same total answers the receipt that already exists. (up to 40 characters) |
| `total` | number |  | What was charged, taxes included and without tip. With `lines` you can leave it out (it's their sum); if you send it, it must be equal. (greater than 0 and up to 10000000) |
| `tip` | number |  | Tip: it doesn't go on the invoice. The customer can type the total with it or without it. (from 0 to 10000000) |
| `payment_form` | string | yes | The sale's c_FormaPago: 01 cash, 04 credit card… |
| `sold_at` | string |  | When it was sold: ISO 8601 (2026-10-02T13:45:00-06:00) or Mexico City time without a zone. By default, now. (up to 40 characters) |
| `product` | string |  | A product (prd_…) from your catalog: the invoice's line item. |
| `description` | string |  | The line item. With `product`, it replaces its description; without it, it goes with `product_key`. (up to 1000 characters) |
| `product_key` | string |  | c_ClaveProdServ (8 digits), if you don't use `product`. |
| `unit_key` | string |  | c_ClaveUnidad. By default, that of the product key. |
| `iva` | `0`, `0.16`, `0.08`, `exento` |  | VAT rate included in the total. 0.16 by default. |
| `local_taxes` | array of object |  | Local taxes included in its total, like the 3.5% ISH on lodging, with `product_key` (a product carries its own). Each one is calculated on this line item's base and the invoice adds them up by name and rate in the local taxes complement. (up to 20) |
| `local_taxes[].retention` | boolean | yes | `false`: a local transferred tax that's added (the ISH). `true`: a local withholding the customer subtracts (the cedular); the global invoice, to the general public, doesn't carry it. |
| `local_taxes[].name` | string | yes | Its name in the CFDI (ImpLocTrasladado or ImpLocRetenido), like «ISH». (up to 100 characters) |
| `local_taxes[].rate` | number | yes | The rate as a percentage: 3.5 is 3.5%. (greater than 0 and up to 100) |
| `ieps` | number or null |  | IEPS included in its total, with `product_key` (a product carries its own): a c_TasaOCuota rate such as 0.08 (snacks) or, with `ieps_factor` `Cuota`, pesos per unit. The factura global breaks it out (RMF 2026 rule 2.7.1.21); the invoice of a customer who doesn't pay IEPS carries it inside the price (LIEPS art. 19 section II). |
| `ieps_factor` | `Tasa`, `Cuota` |  | `Tasa` (the default) or `Cuota` (pesos per unit). |
| `buyer` | object |  | Who paid, to recognize the sale in Tickets. It isn't the invoice's recipient (the buyer types that on the portal) and nothing is sent to them. |
| `buyer.name` | string |  | Their name or their company's, as your system knows it. (up to 200 characters) |
| `buyer.email` | string (email) |  | Their email. (up to 254 characters) |
| `branch` | string |  | Branch (brn_…) where the sale was made: its invoice is stamped from there (its postal code in LugarExpedicion) and the portal shows the branch's trade name and logo. Without it, the head office. (up to 80 characters) |
| `lines` | array of object |  | A sale of several line items (a hotel folio: nights, breakfasts, laundry), each with its product or its keys, its taxes and what was charged for it; up to 200. Instead of `product`, `description`, `product_key`, `unit_key` and `iva`. The customer's invoice carries one line item per line; the global invoice, one for each combination of taxes on the receipt. (up to 200) |
| `lines[].product` | string |  | A product (prd_…) from your catalog: its keys, VAT and local taxes. |
| `lines[].description` | string |  | The line item. With `product`, it replaces its description; without it, it goes with `product_key`. (up to 1000 characters) |
| `lines[].product_key` | string |  | c_ClaveProdServ (8 digits), if you don't use `product`. |
| `lines[].unit_key` | string |  | c_ClaveUnidad. By default, that of the product key. |
| `lines[].iva` | `0`, `0.16`, `0.08`, `exento` |  | VAT rate included in its total. 0.16 by default. |
| `lines[].local_taxes` | array of object |  | Local taxes included in its total, like the 3.5% ISH on lodging, with `product_key` (a product carries its own). Each one is calculated on this line item's base and the invoice adds them up by name and rate in the local taxes complement. (up to 20) |
| `lines[].local_taxes[].retention` | boolean | yes | `false`: a local transferred tax that's added (the ISH). `true`: a local withholding the customer subtracts (the cedular); the global invoice, to the general public, doesn't carry it. |
| `lines[].local_taxes[].name` | string | yes | Its name in the CFDI (ImpLocTrasladado or ImpLocRetenido), like «ISH». (up to 100 characters) |
| `lines[].local_taxes[].rate` | number | yes | The rate as a percentage: 3.5 is 3.5%. (greater than 0 and up to 100) |
| `lines[].ieps` | number or null |  | IEPS included in its total, with `product_key` (a product carries its own): a c_TasaOCuota rate such as 0.08 (snacks) or, with `ieps_factor` `Cuota`, pesos per unit. The factura global breaks it out (RMF 2026 rule 2.7.1.21); the invoice of a customer who doesn't pay IEPS carries it inside the price (LIEPS art. 19 section II). |
| `lines[].ieps_factor` | `Tasa`, `Cuota` |  | `Tasa` (the default) or `Cuota` (pesos per unit). |
| `lines[].detail` | string |  | What only this sale says, like a stay's nights, dates and reservation number. With it, the invoice says «Hospedaje · 6 noches, del 14 al 20 de noviembre»; when it goes is decided by the self-invoicing `invoice_concepts.line_detail` (by default, the customer chooses at the portal). (up to 200 characters) |
| `lines[].quantity` | number |  | Units (nights, pieces). 1 by default. (greater than 0 and up to 9999) |
| `lines[].total` | number | yes | What was charged for this line item, taxes included. (greater than 0 and up to 10000000) |

Example:

```json
{
  "folio": "A1042",
  "total": 580,
  "payment_form": "04",
  "product_key": "90101501",
  "description": "Consumo de alimentos",
  "sold_at": "2026-10-24T14:32:00-06:00"
}
```

## With the TypeScript SDK

```ts
import { Fiscalisto } from "fiscalisto";

// La llave viene de FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const ticket = await fiscalisto.tickets.create({
  folio: "A1042",
  total: 580,
  payment_form: "04",
  product_key: "90101501",
  description: "Consumo de alimentos",
  sold_at: "2026-10-24T14:32:00-06:00",
}, { idempotencyKey: "pedido-A-1042" });
```

## With the Python SDK

```python
from fiscalisto import Fiscalisto

# La llave viene de FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

ticket = fiscalisto.tickets.create({
    "folio": "A1042",
    "total": 580,
    "payment_form": "04",
    "product_key": "90101501",
    "description": "Consumo de alimentos",
    "sold_at": "2026-10-24T14:32:00-06:00",
}, idempotency_key="pedido-A-1042")
```

## With the PHP SDK

```php
<?php

use Fiscalisto\Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$ticket = $fiscalisto->tickets->create([
    'folio' => 'A1042',
    'total' => 580,
    'payment_form' => '04',
    'product_key' => '90101501',
    'description' => 'Consumo de alimentos',
    'sold_at' => '2026-10-24T14:32:00-06:00',
], ['idempotency_key' => 'pedido-A-1042']);
```

## With the .NET SDK

```csharp
using Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var ticket = await fiscalisto.Tickets.CreateAsync(new CreateTicketParams
{
    Folio = "A1042",
    Total = 580,
    PaymentForm = "04",
    ProductKey = "90101501",
    Description = "Consumo de alimentos",
    SoldAt = "2026-10-24T14:32:00-06:00",
}, new RequestOptions { IdempotencyKey = "pedido-A-1042" });
```

## With the Go SDK

```go
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// La llave viene de FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	ticket, err := client.Tickets.Create(ctx, &fiscalisto.CreateTicketParams{
		Folio:       "A1042",
		Total:       fiscalisto.Float64(580),
		PaymentForm: "04",
		ProductKey:  fiscalisto.String("90101501"),
		Description: fiscalisto.String("Consumo de alimentos"),
		SoldAt:      fiscalisto.String("2026-10-24T14:32:00-06:00"),
	}, fiscalisto.WithIdempotencyKey("pedido-A-1042"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(ticket.ID)
}
```

## With the Java SDK

```java
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreateTicketParams;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var ticket = fiscalisto.tickets().create(new CreateTicketParams()
        .setFolio("A1042")
        .setTotal(580)
        .setPaymentForm("04")
        .setProductKey("90101501")
        .setDescription("Consumo de alimentos")
        .setSoldAt("2026-10-24T14:32:00-06:00"), RequestOptions.idempotencyKey("pedido-A-1042"));
System.out.println(ticket.getId());
```

## Response 201

OK.

A `Ticket` object:

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"ticket"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer that sold. |
| `folio` | string | yes | The sale's folio in your system. |
| `code` | string | yes | What your buyer types in the portal along with the total: the folio and 4 random characters (A123-K7QX). Print it on the ticket or send it with the purchase. |
| `status` | `pending`, `invoiced`, `global`, `cancelled` | yes | pending (can be invoiced), invoiced (your buyer invoiced it: the invoice in invoice), global (it went into the period's global invoice) or cancelled. |
| `url` | string or null | yes | The portal page with the ticket's code (c) and total (t): the portal finds it on its own and the buyer only gives their details. Anyone with the link can invoice the ticket: give it only to the buyer (like the printed ticket). You can embed it with fiscalisto.js. null if it is no longer pending. |
| `total` | number | yes | What was charged, taxes included and without tip. |
| `tip` | number | yes | The tip (it doesn't go on the invoice). |
| `payment_form` | string | yes | The sale's c_FormaPago. |
| `description` | string | yes | The invoice's line item (the first one, if it has several). |
| `product_key` | string | yes | The line item's c_ClaveProdServ (the first one, if it has several). |
| `lines` | array of object | yes | Its line items, in order: just one if it was recorded without lines. Each with its product (prd_… or null), description, SAT codes, IVA (null if not subject to tax), units and what was charged for it, taxes included. |
| `lines[].product` | string or null | yes | A product from your catalog (prd_…): takes its key, unit, price and taxes. |
| `lines[].description` | string | yes | Description. |
| `lines[].product_key` | string | yes | Product or service key (ClaveProdServ), 8 digits from c_ClaveProdServ. Look it up with GET /v1/sat_catalogs/product_keys?q=… |
| `lines[].unit_key` | string | yes | Unit key (ClaveUnidad) from c_ClaveUnidad: E48 service unit, H87 piece, ACT activity… By default H87 if the product key is for goods (segments 10 to 60) and E48 if it's for a service. |
| `lines[].iva` | string or null | yes | Transferred VAT rate: 0.16 (the default), 0.08 (border region), 0 or exento. |
| `lines[].local_taxes` | array of object | yes | Its local taxes (its product's or the ones you sent), included in its total. |
| `lines[].local_taxes[].retention` | boolean | yes | true if it's a local withholding; false if it's a transfer. |
| `lines[].local_taxes[].name` | string | yes | Name of the local tax (ImpLocTrasladado or ImpLocRetenido), like ISH. |
| `lines[].local_taxes[].rate` | number | yes | Rate in percent (TasadeTraslado or TasadeRetencion). |
| `lines[].ieps` | number or null | yes | Its IEPS (its product's or the one you sent), included in its total: a rate or, with `ieps_factor` `Cuota`, pesos per unit. `null`: no IEPS. |
| `lines[].ieps_factor` | `Tasa`, `Cuota` or null | yes | Tasa or Cuota (IEPS TipoFactor). |
| `lines[].detail` | string or null | yes | The detail you sent (nights, dates, reservation): it goes after the description on the invoice as the self-invoicing `invoice_concepts.line_detail` says. |
| `lines[].quantity` | number | yes | Quantity (Cantidad). 1 by default. |
| `lines[].total` | number | yes | Total in the receipt's currency (Total). |
| `sold_at` | string (date-time) | yes | When it was sold. |
| `invoiceable_until` | string | yes | The last day (YYYY-MM-DD) the buyer can invoice it; after that it goes into the global invoice. |
| `invoice` | string or null | yes | The invoice (inv_…) your buyer made, or null. |
| `global_invoice` | string or null | yes | The global invoice (inv_…) it went into, or null. |
| `invoiced_amount` | number | yes | What the invoices of a receipt split into several already cover (self-invoicing allows it with `split_max`), taxes included. 0 if it hasn't been split; a `pending` receipt above 0 has `total - invoiced_amount` left to invoice with the same code, and a split `invoiced` receipt has `invoice` null. |
| `customer` | object or null | yes | Who it was invoiced to, or null. |
| `customer.tax_id` | string | yes | RFC (Rfc), 12 characters for a persona moral and 13 for a persona física. |
| `customer.legal_name` | string or null | yes | Name or razón social exactly as on the constancia de situación fiscal, without the capital regime (without «S.A. de C.V.»). |
| `branch` | string or null | yes | The branch (brn_…) where the sale was made, or null (the Matriz). Its invoice is stamped from there and the portal shows its name and logo. |
| `buyer` | object or null | yes | Who paid, as the sale's source knows them (the `buyer` you sent, or the customer of a Stripe payment). It isn't the invoice's recipient (`customer`). |
| `buyer.name` | string or null | yes | Name. |
| `buyer.email` | string or null | yes | Email to send it to (several separated by commas). Only used if sending is requested. |
| `created_at` | string (date-time) or null | yes | When it was recorded. |

```json
{
  "id": "tkt_OufpKqnrvx9p6hW1yQbT3mZr8sKdLx0VeN",
  "object": "ticket",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "folio": "A1042",
  "code": "A1042-K7QX",
  "status": "pending",
  "url": "https://fiscalisto.com/autofactura/Tx8mQ2vLp9WnR4c?c=A1042-K7QX&t=580",
  "total": 580,
  "tip": 0,
  "payment_form": "04",
  "description": "Consumo de alimentos",
  "product_key": "90101501",
  "lines": [
    {
      "product": null,
      "description": "Consumo de alimentos",
      "product_key": "90101501",
      "unit_key": "E48",
      "iva": "0.16",
      "local_taxes": [],
      "ieps": null,
      "ieps_factor": null,
      "detail": null,
      "quantity": 1,
      "total": 580
    }
  ],
  "sold_at": "2026-10-24T14:32:00-06:00",
  "invoiceable_until": "2026-10-31",
  "invoice": null,
  "global_invoice": null,
  "invoiced_amount": 0,
  "customer": null,
  "branch": null,
  "buyer": {
    "name": "Laura Méndez",
    "email": "laura@example.com"
  },
  "created_at": "2026-10-24T14:32:05-06:00"
}
```

## Errors

- `daily_limit` (429): You reached today's limit of something not paid with stamps. Retry-After says how many seconds until midnight in Mexico City.
- `feature_not_in_plan` (403): Live, this part of the API (inventario, portal de proveedores, pedidos, comprobación de gastos) follows the empresa's plan, as in the app: it comes with Operaciones (added to any paid plan; included in Corporativo). The books (the /v1/accounting routes except DIOT, cross checks, IVA refunds and fixed assets) come with Contabilidad (added to Independiente, Emprendedor or Negocio; included in Despacho and Corporativo): without it, changing the books answers this error, and reading them works only up to the last month it had it. Add either in Ajustes › Plan y pagos; test mode has everything.
- `issuer_archived` (400): The issuer is archived and no longer stamps. Its documents can still be read and canceled.
- `issuer_linked_empresa` (403): That issuer is an empresa of the app connected to your account: through the API it only offers its Portal de proveedores (/v1/portal_suppliers and /v1/supplier_invoices) and, once someone who may pay suppliers and change Configurar pagos turned them on, its supplier payouts (/v1/payouts and /v1/payroll_payouts). It also stops when whoever connected it (or turned its payouts on) no longer has that permission in the empresa: message_es says which. Do everything else in the app.
- `issuer_missing` (404): There is no such issuer in the account (or it belongs to the other mode).
- `issuer_not_allowed` (403): This key can't use that issuer.
- `issuer_required` (400): The account has several issuers and the request doesn't say which: send `issuer` (iss_…).
- `livemode_mismatch` (400): The object belongs to the other mode: an fk_test_ key only sees test data and an fk_live_ key only live data.
- `ticket_folio_taken` (400): That folio is already registered for the issuer with another total or tip. With the same total the existing ticket is returned.
- `ticket_invalid` (400): The ticket couldn't be registered (invalid folio, a sale date in the future or over a year ago, a product no longer in the catalog…). `message_es` says which.

Plus those of any call (key, fields, limits): https://fiscalisto.com/en/docs/api/errores.md.
