# Recetas de facturación

> Las facturas más comunes listas para copiar: con catálogo, a crédito (PPD), en dólares, con retenciones, global a público en general y en lote.

Todas van a [`POST /v1/invoices`](https://fiscalisto.com/docs/api/referencia/facturas/create-invoice) con su llave y una `Idempotency-Key` nueva. Solo cambia el cuerpo; lo que no manda tiene su valor usual (PUE, MXN, uso G03 o S01 con régimen 616, unidad E48, objeto de impuesto 02, IVA 16%, cantidad 1).

## Con su catálogo de clientes y productos

Guarde una vez al cliente y al producto, y facture con sus ids. El producto pone su clave, unidad, precio e impuestos; puede cambiar la cantidad o el precio en cada concepto.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/customers \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tax_id": "ICV060329BY0", "legal_name": "INMOBILIARIA CVA", "tax_system": "601", "zip": "33826", "email": "pagos@cva.example" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const customer = await fiscalisto.customers.create({
  tax_id: "ICV060329BY0",
  legal_name: "INMOBILIARIA CVA",
  tax_system: "601",
  zip: "33826",
  email: "pagos@cva.example",
});
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

customer = fiscalisto.customers.create({
    "tax_id": "ICV060329BY0",
    "legal_name": "INMOBILIARIA CVA",
    "tax_system": "601",
    "zip": "33826",
    "email": "pagos@cva.example",
})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$customer = $fiscalisto->customers->create([
    'tax_id' => 'ICV060329BY0',
    'legal_name' => 'INMOBILIARIA CVA',
    'tax_system' => '601',
    'zip' => '33826',
    'email' => 'pagos@cva.example',
]);
```

```go tab="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()

	customer, err := client.Customers.Create(ctx, &fiscalisto.CreateCustomerParams{
		TaxID:     "ICV060329BY0",
		LegalName: "INMOBILIARIA CVA",
		TaxSystem: "601",
		Zip:       "33826",
		Email:     fiscalisto.String("pagos@cva.example"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(customer.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.CreateCustomerParams;

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

var customer = fiscalisto.customers().create(new CreateCustomerParams()
        .setTaxId("ICV060329BY0")
        .setLegalName("INMOBILIARIA CVA")
        .setTaxSystem("601")
        .setZip("33826")
        .setEmail("pagos@cva.example"));
System.out.println(customer.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var customer = await fiscalisto.Customers.CreateAsync(new CreateCustomerParams
{
    TaxId = "ICV060329BY0",
    LegalName = "INMOBILIARIA CVA",
    TaxSystem = "601",
    Zip = "33826",
    Email = "pagos@cva.example",
});
```

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: pedido-A-1043" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": "cus_OufpKqnrvx9p1",
    "payment_form": "04",
    "items": [{ "product": "prd_OufpKqnrvx9p1", "quantity": 3 }],
    "send_email": true
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const invoice = await fiscalisto.invoices.create({
  customer: "cus_OufpKqnrvx9p1",
  payment_form: "04",
  items: [
    {
      product: "prd_OufpKqnrvx9p1",
      quantity: 3,
    },
  ],
  send_email: true,
}, { idempotencyKey: "pedido-A-1043" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

invoice = fiscalisto.invoices.create({
    "customer": "cus_OufpKqnrvx9p1",
    "payment_form": "04",
    "items": [
        {
            "product": "prd_OufpKqnrvx9p1",
            "quantity": 3,
        },
    ],
    "send_email": True,
}, idempotency_key="pedido-A-1043")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$invoice = $fiscalisto->invoices->create([
    'customer' => 'cus_OufpKqnrvx9p1',
    'payment_form' => '04',
    'items' => [
        [
            'product' => 'prd_OufpKqnrvx9p1',
            'quantity' => 3,
        ],
    ],
    'send_email' => true,
], ['idempotency_key' => 'pedido-A-1043']);
```

```go tab="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()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		Customer:    fiscalisto.IDOf[fiscalisto.InvoiceCreateCustomer]("cus_OufpKqnrvx9p1"),
		PaymentForm: fiscalisto.String("04"),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Product:  fiscalisto.String("prd_OufpKqnrvx9p1"),
				Quantity: fiscalisto.Float64(3),
			},
		},
		SendEmail: fiscalisto.Bool(true),
	}, fiscalisto.WithIdempotencyKey("pedido-A-1043"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

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

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCustomer("cus_OufpKqnrvx9p1")
        .setPaymentForm("04")
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setProduct("prd_OufpKqnrvx9p1")
                        .setQuantity(3)
        ))
        .setSendEmail(true), RequestOptions.idempotencyKey("pedido-A-1043"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    Customer = "cus_OufpKqnrvx9p1",
    PaymentForm = "04",
    Items = new()
    {
        new()
        {
            Product = "prd_OufpKqnrvx9p1",
            Quantity = 3,
        },
    },
    SendEmail = true,
}, new RequestOptions { IdempotencyKey = "pedido-A-1043" });
```

Con `send_email` le llega al cliente el PDF y el XML al correo de su ficha (o al de `customer.email`); sin ninguno contesta `400` `parameter_missing`, para que no se timbre una factura que no le llega a nadie. Un cliente nuevo también puede ir completo en `customer`, como en el [inicio rápido](https://fiscalisto.com/docs/api); no se guarda en el catálogo.

## A crédito (PPD)

Si el cliente le paga después o en partes, la factura va con método PPD y forma de pago 99 (por definir), que Fiscalisto pone sola. Cada pago se registra después con un [complemento de pago](https://fiscalisto.com/docs/api/pagos-y-notas-de-credito).

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: contrato-88-oct" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": { "tax_id": "ICV060329BY0", "legal_name": "INMOBILIARIA CVA", "tax_system": "601", "zip": "33826" },
    "payment_method": "PPD",
    "items": [{ "description": "Implementación del sistema", "product_key": "81111500", "unit_price": 45000 }]
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const invoice = await fiscalisto.invoices.create({
  customer: {
    tax_id: "ICV060329BY0",
    legal_name: "INMOBILIARIA CVA",
    tax_system: "601",
    zip: "33826",
  },
  payment_method: "PPD",
  items: [
    {
      description: "Implementación del sistema",
      product_key: "81111500",
      unit_price: 45000,
    },
  ],
}, { idempotencyKey: "contrato-88-oct" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

invoice = fiscalisto.invoices.create({
    "customer": {
        "tax_id": "ICV060329BY0",
        "legal_name": "INMOBILIARIA CVA",
        "tax_system": "601",
        "zip": "33826",
    },
    "payment_method": "PPD",
    "items": [
        {
            "description": "Implementación del sistema",
            "product_key": "81111500",
            "unit_price": 45000,
        },
    ],
}, idempotency_key="contrato-88-oct")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$invoice = $fiscalisto->invoices->create([
    'customer' => [
        'tax_id' => 'ICV060329BY0',
        'legal_name' => 'INMOBILIARIA CVA',
        'tax_system' => '601',
        'zip' => '33826',
    ],
    'payment_method' => 'PPD',
    'items' => [
        [
            'description' => 'Implementación del sistema',
            'product_key' => '81111500',
            'unit_price' => 45000,
        ],
    ],
], ['idempotency_key' => 'contrato-88-oct']);
```

```go tab="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()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		Customer: fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{
			TaxID:     "ICV060329BY0",
			LegalName: "INMOBILIARIA CVA",
			TaxSystem: "601",
			Zip:       "33826",
		}),
		PaymentMethod: fiscalisto.String("PPD"),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Description: fiscalisto.String("Implementación del sistema"),
				ProductKey:  fiscalisto.String("81111500"),
				UnitPrice:   fiscalisto.Float64(45000),
			},
		},
	}, fiscalisto.WithIdempotencyKey("contrato-88-oct"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateCustomer;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

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

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCustomer(new InvoiceCreateCustomer()
                .setTaxId("ICV060329BY0")
                .setLegalName("INMOBILIARIA CVA")
                .setTaxSystem("601")
                .setZip("33826"))
        .setPaymentMethod("PPD")
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setDescription("Implementación del sistema")
                        .setProductKey("81111500")
                        .setUnitPrice(45000)
        )), RequestOptions.idempotencyKey("contrato-88-oct"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    Customer = new InvoiceCreateCustomer
    {
        TaxId = "ICV060329BY0",
        LegalName = "INMOBILIARIA CVA",
        TaxSystem = "601",
        Zip = "33826",
    },
    PaymentMethod = "PPD",
    Items = new()
    {
        new()
        {
            Description = "Implementación del sistema",
            ProductKey = "81111500",
            UnitPrice = 45000,
        },
    },
}, new RequestOptions { IdempotencyKey = "contrato-88-oct" });
```

## En dólares

Mande la moneda y el tipo de cambio del día (el que publica el DOF el día hábil anterior). Los precios van en dólares.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: pedido-USD-17" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": { "tax_id": "ICV060329BY0", "legal_name": "INMOBILIARIA CVA", "tax_system": "601", "zip": "33826" },
    "payment_form": "03",
    "currency": "USD",
    "exchange_rate": 18.35,
    "items": [{ "description": "Licencia anual", "product_key": "43232400", "unit_price": 1200 }]
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const invoice = await fiscalisto.invoices.create({
  customer: {
    tax_id: "ICV060329BY0",
    legal_name: "INMOBILIARIA CVA",
    tax_system: "601",
    zip: "33826",
  },
  payment_form: "03",
  currency: "USD",
  exchange_rate: 18.35,
  items: [
    {
      description: "Licencia anual",
      product_key: "43232400",
      unit_price: 1200,
    },
  ],
}, { idempotencyKey: "pedido-USD-17" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

invoice = fiscalisto.invoices.create({
    "customer": {
        "tax_id": "ICV060329BY0",
        "legal_name": "INMOBILIARIA CVA",
        "tax_system": "601",
        "zip": "33826",
    },
    "payment_form": "03",
    "currency": "USD",
    "exchange_rate": 18.35,
    "items": [
        {
            "description": "Licencia anual",
            "product_key": "43232400",
            "unit_price": 1200,
        },
    ],
}, idempotency_key="pedido-USD-17")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$invoice = $fiscalisto->invoices->create([
    'customer' => [
        'tax_id' => 'ICV060329BY0',
        'legal_name' => 'INMOBILIARIA CVA',
        'tax_system' => '601',
        'zip' => '33826',
    ],
    'payment_form' => '03',
    'currency' => 'USD',
    'exchange_rate' => 18.35,
    'items' => [
        [
            'description' => 'Licencia anual',
            'product_key' => '43232400',
            'unit_price' => 1200,
        ],
    ],
], ['idempotency_key' => 'pedido-USD-17']);
```

```go tab="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()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		Customer: fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{
			TaxID:     "ICV060329BY0",
			LegalName: "INMOBILIARIA CVA",
			TaxSystem: "601",
			Zip:       "33826",
		}),
		PaymentForm:  fiscalisto.String("03"),
		Currency:     fiscalisto.String("USD"),
		ExchangeRate: fiscalisto.Float64(18.35),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Description: fiscalisto.String("Licencia anual"),
				ProductKey:  fiscalisto.String("43232400"),
				UnitPrice:   fiscalisto.Float64(1200),
			},
		},
	}, fiscalisto.WithIdempotencyKey("pedido-USD-17"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateCustomer;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

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

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCustomer(new InvoiceCreateCustomer()
                .setTaxId("ICV060329BY0")
                .setLegalName("INMOBILIARIA CVA")
                .setTaxSystem("601")
                .setZip("33826"))
        .setPaymentForm("03")
        .setCurrency("USD")
        .setExchangeRate(18.35)
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setDescription("Licencia anual")
                        .setProductKey("43232400")
                        .setUnitPrice(1200)
        )), RequestOptions.idempotencyKey("pedido-USD-17"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    Customer = new InvoiceCreateCustomer
    {
        TaxId = "ICV060329BY0",
        LegalName = "INMOBILIARIA CVA",
        TaxSystem = "601",
        Zip = "33826",
    },
    PaymentForm = "03",
    Currency = "USD",
    ExchangeRate = 18.35m,
    Items = new()
    {
        new()
        {
            Description = "Licencia anual",
            ProductKey = "43232400",
            UnitPrice = 1200,
        },
    },
}, new RequestOptions { IdempotencyKey = "pedido-USD-17" });
```

## Con retenciones

Las retenciones van por concepto, como tasa. Por ejemplo, un flete a una persona moral lleva retención de IVA del 4%:

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: flete-5521" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": { "tax_id": "ICV060329BY0", "legal_name": "INMOBILIARIA CVA", "tax_system": "601", "zip": "33826" },
    "payment_form": "03",
    "items": [{ "description": "Flete Monterrey–Saltillo", "product_key": "78101800", "unit_price": 8000, "iva_retention": 0.04 }]
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const invoice = await fiscalisto.invoices.create({
  customer: {
    tax_id: "ICV060329BY0",
    legal_name: "INMOBILIARIA CVA",
    tax_system: "601",
    zip: "33826",
  },
  payment_form: "03",
  items: [
    {
      description: "Flete Monterrey–Saltillo",
      product_key: "78101800",
      unit_price: 8000,
      iva_retention: 0.04,
    },
  ],
}, { idempotencyKey: "flete-5521" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

invoice = fiscalisto.invoices.create({
    "customer": {
        "tax_id": "ICV060329BY0",
        "legal_name": "INMOBILIARIA CVA",
        "tax_system": "601",
        "zip": "33826",
    },
    "payment_form": "03",
    "items": [
        {
            "description": "Flete Monterrey–Saltillo",
            "product_key": "78101800",
            "unit_price": 8000,
            "iva_retention": 0.04,
        },
    ],
}, idempotency_key="flete-5521")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$invoice = $fiscalisto->invoices->create([
    'customer' => [
        'tax_id' => 'ICV060329BY0',
        'legal_name' => 'INMOBILIARIA CVA',
        'tax_system' => '601',
        'zip' => '33826',
    ],
    'payment_form' => '03',
    'items' => [
        [
            'description' => 'Flete Monterrey–Saltillo',
            'product_key' => '78101800',
            'unit_price' => 8000,
            'iva_retention' => 0.04,
        ],
    ],
], ['idempotency_key' => 'flete-5521']);
```

```go tab="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()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		Customer: fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{
			TaxID:     "ICV060329BY0",
			LegalName: "INMOBILIARIA CVA",
			TaxSystem: "601",
			Zip:       "33826",
		}),
		PaymentForm: fiscalisto.String("03"),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Description:  fiscalisto.String("Flete Monterrey–Saltillo"),
				ProductKey:   fiscalisto.String("78101800"),
				UnitPrice:    fiscalisto.Float64(8000),
				IVARetention: fiscalisto.Float64(0.04),
			},
		},
	}, fiscalisto.WithIdempotencyKey("flete-5521"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateCustomer;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

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

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCustomer(new InvoiceCreateCustomer()
                .setTaxId("ICV060329BY0")
                .setLegalName("INMOBILIARIA CVA")
                .setTaxSystem("601")
                .setZip("33826"))
        .setPaymentForm("03")
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setDescription("Flete Monterrey–Saltillo")
                        .setProductKey("78101800")
                        .setUnitPrice(8000)
                        .setIvaRetention(0.04)
        )), RequestOptions.idempotencyKey("flete-5521"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    Customer = new InvoiceCreateCustomer
    {
        TaxId = "ICV060329BY0",
        LegalName = "INMOBILIARIA CVA",
        TaxSystem = "601",
        Zip = "33826",
    },
    PaymentForm = "03",
    Items = new()
    {
        new()
        {
            Description = "Flete Monterrey–Saltillo",
            ProductKey = "78101800",
            UnitPrice = 8000,
            IvaRetention = 0.04m,
        },
    },
}, new RequestOptions { IdempotencyKey = "flete-5521" });
```

La respuesta trae lo retenido en `taxes.iva_withheld` y `taxes.isr_withheld`, y el `total` ya con ellas restadas. Otras comunes: honorarios o arrendamiento de una persona física a una moral (`isr_retention: 0.10`, `iva_retention: 0.106667`) y RESICO a una persona moral (`isr_retention: 0.0125`).

## Global a público en general

Lo que vendió con ticket a quien no pidió factura va en una factura global por día, semana, mes o bimestre. El cliente es el público en general: RFC `XAXX010101000`, nombre `PUBLICO EN GENERAL`, régimen `616` y, como código postal, el del emisor (en pruebas, el del emisor de pruebas del SAT: `42501`). Cada concepto es una venta, con el número del ticket en `sku`.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: global-2026-10" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": { "tax_id": "XAXX010101000", "legal_name": "PUBLICO EN GENERAL", "tax_system": "616", "zip": "42501" },
    "global": { "periodicity": "04", "months": "10", "year": 2026 },
    "payment_form": "01",
    "items": [
      { "description": "Venta", "product_key": "01010101", "unit_key": "ACT", "sku": "T-1001", "unit_price": 431.03 },
      { "description": "Venta", "product_key": "01010101", "unit_key": "ACT", "sku": "T-1002", "unit_price": 862.07 }
    ]
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

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

const invoice = await fiscalisto.invoices.create({
  customer: {
    tax_id: "XAXX010101000",
    legal_name: "PUBLICO EN GENERAL",
    tax_system: "616",
    zip: "42501",
  },
  global: {
    periodicity: "04",
    months: "10",
    year: 2026,
  },
  payment_form: "01",
  items: [
    {
      description: "Venta",
      product_key: "01010101",
      unit_key: "ACT",
      sku: "T-1001",
      unit_price: 431.03,
    },
    {
      description: "Venta",
      product_key: "01010101",
      unit_key: "ACT",
      sku: "T-1002",
      unit_price: 862.07,
    },
  ],
}, { idempotencyKey: "global-2026-10" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

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

invoice = fiscalisto.invoices.create({
    "customer": {
        "tax_id": "XAXX010101000",
        "legal_name": "PUBLICO EN GENERAL",
        "tax_system": "616",
        "zip": "42501",
    },
    "global": {
        "periodicity": "04",
        "months": "10",
        "year": 2026,
    },
    "payment_form": "01",
    "items": [
        {
            "description": "Venta",
            "product_key": "01010101",
            "unit_key": "ACT",
            "sku": "T-1001",
            "unit_price": 431.03,
        },
        {
            "description": "Venta",
            "product_key": "01010101",
            "unit_key": "ACT",
            "sku": "T-1002",
            "unit_price": 862.07,
        },
    ],
}, idempotency_key="global-2026-10")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

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

$invoice = $fiscalisto->invoices->create([
    'customer' => [
        'tax_id' => 'XAXX010101000',
        'legal_name' => 'PUBLICO EN GENERAL',
        'tax_system' => '616',
        'zip' => '42501',
    ],
    'global' => [
        'periodicity' => '04',
        'months' => '10',
        'year' => 2026,
    ],
    'payment_form' => '01',
    'items' => [
        [
            'description' => 'Venta',
            'product_key' => '01010101',
            'unit_key' => 'ACT',
            'sku' => 'T-1001',
            'unit_price' => 431.03,
        ],
        [
            'description' => 'Venta',
            'product_key' => '01010101',
            'unit_key' => 'ACT',
            'sku' => 'T-1002',
            'unit_price' => 862.07,
        ],
    ],
], ['idempotency_key' => 'global-2026-10']);
```

```go tab="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()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		Customer: fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{
			TaxID:     "XAXX010101000",
			LegalName: "PUBLICO EN GENERAL",
			TaxSystem: "616",
			Zip:       "42501",
		}),
		Global: &fiscalisto.InvoiceCreateGlobal{
			Periodicity: "04",
			Months:      "10",
			Year:        2026,
		},
		PaymentForm: fiscalisto.String("01"),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Description: fiscalisto.String("Venta"),
				ProductKey:  fiscalisto.String("01010101"),
				UnitKey:     fiscalisto.String("ACT"),
				SKU:         fiscalisto.String("T-1001"),
				UnitPrice:   fiscalisto.Float64(431.03),
			},
			{
				Description: fiscalisto.String("Venta"),
				ProductKey:  fiscalisto.String("01010101"),
				UnitKey:     fiscalisto.String("ACT"),
				SKU:         fiscalisto.String("T-1002"),
				UnitPrice:   fiscalisto.Float64(862.07),
			},
		},
	}, fiscalisto.WithIdempotencyKey("global-2026-10"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateCustomer;
import com.fiscalisto.model.InvoiceCreateGlobal;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

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

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCustomer(new InvoiceCreateCustomer()
                .setTaxId("XAXX010101000")
                .setLegalName("PUBLICO EN GENERAL")
                .setTaxSystem("616")
                .setZip("42501"))
        .setGlobal(new InvoiceCreateGlobal()
                .setPeriodicity("04")
                .setMonths("10")
                .setYear(2026))
        .setPaymentForm("01")
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setDescription("Venta")
                        .setProductKey("01010101")
                        .setUnitKey("ACT")
                        .setSku("T-1001")
                        .setUnitPrice(431.03),
                new InvoiceCreateItem()
                        .setDescription("Venta")
                        .setProductKey("01010101")
                        .setUnitKey("ACT")
                        .setSku("T-1002")
                        .setUnitPrice(862.07)
        )), RequestOptions.idempotencyKey("global-2026-10"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

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

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    Customer = new InvoiceCreateCustomer
    {
        TaxId = "XAXX010101000",
        LegalName = "PUBLICO EN GENERAL",
        TaxSystem = "616",
        Zip = "42501",
    },
    Global = new() { Periodicity = "04", Months = "10", Year = 2026 },
    PaymentForm = "01",
    Items = new()
    {
        new()
        {
            Description = "Venta",
            ProductKey = "01010101",
            UnitKey = "ACT",
            Sku = "T-1001",
            UnitPrice = 431.03m,
        },
        new()
        {
            Description = "Venta",
            ProductKey = "01010101",
            UnitKey = "ACT",
            Sku = "T-1002",
            UnitPrice = 862.07m,
        },
    },
}, new RequestOptions { IdempotencyKey = "global-2026-10" });
```

## Muchas a la vez

Para cientos o miles de facturas (las cuotas del mes, la facturación de un marketplace), use un [lote](https://fiscalisto.com/docs/api/lotes): una sola solicitud con hasta 1,000.

## Para saber más

- Cada campo, con su nombre en el XML del SAT y su catálogo, está en la [referencia de `POST /v1/invoices`](https://fiscalisto.com/docs/api/referencia/facturas/create-invoice).
- Busque claves de producto y unidad con [`GET /v1/sat_catalogs/product_keys?q=…`](https://fiscalisto.com/docs/api/referencia/catalogos-del-sat/get-sat-catalog).
- [Complementos](https://fiscalisto.com/docs/api/complementos): Carta Porte, comercio exterior, instituciones educativas, impuestos locales y más.
