# API examples

Copy-ready requests, from the simplest to the less common tax cases. The same JSON works for TicketBAI (Araba, Bizkaia and Gipuzkoa) and for Verifactu: the API applies the differences of each system based on the issuer NIF.

 All requests go to the test environment `https://api-test.ticketbaiws.eus` with the headers `Token` (your test token) and `Nif` (the issuer NIF, the Spanish tax ID). Line amounts are **VAT-exclusive**. Want to try them without an account? Open them in the [test console](https://ticketbaiws.eus/en/desarrolladores/terminal/).

## Simplified invoice (receipt)

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

The most common case in POS and e-commerce: a sale to an end consumer without customer details. With `simplificada: true` you do not need to send a NIF (Spanish tax ID), name or address.

Line amounts are **VAT-exclusive**. You can send up to 4 decimals in `importe_unitario` so that the VAT-inclusive total matches to the cent.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "T2026",
    "numero": "1024",
    "simplificada": true,
    "lineas": [
        {
            "descripcion": "Café con leche",
            "cantidad": 2,
            "importe_unitario": 1.3636,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Pintxo de tortilla",
            "cantidad": 1,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        }
    ],
    "total_factura": 6.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "T2026",
    "numero": "1024",
    "simplificada": true,
    "lineas": [
        {
            "descripcion": "Café con leche",
            "cantidad": 2,
            "importe_unitario": 1.3636,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Pintxo de tortilla",
            "cantidad": 1,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        }
    ],
    "total_factura": 6.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-j7MuFGnhmY+e6-062",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-j7MuFGnhmY%2Be6-062&s=T2026&nf=1024&i=6&cr=234"
    },
    "msg": null
}
```

## Full invoice to a company

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

A standard invoice with the recipient details. In Araba and Gipuzkoa the address and postal code are required; in Bizkaia and Verifactu the NIF and name are enough, but we recommend always sending them.

`fecha_operacion` (transaction date) is optional: use it when the service or delivery took place on a date different from the issue date (never a later one).

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "fecha_operacion": "28/11/2026",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000153",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 3,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 308.55
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "fecha_operacion": "28/11/2026",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000153",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 3,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 308.55
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-WbGbDliAHpHkM-232",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-WbGbDliAHpHkM-232&s=A2026&nf=000153&i=308.55&cr=254"
    },
    "msg": null
}
```

## Multiple VAT rates and discounts

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Each line has its own VAT rate, and the API groups the tax bases by rate in the breakdown. `descuento` is a percentage discount on the line.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000154",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Auriculares",
            "cantidad": 1,
            "importe_unitario": 49.5868,
            "tipo_iva": 21,
            "tipo_req": 0,
            "descuento": 10
        },
        {
            "descripcion": "Caja de galletas",
            "cantidad": 4,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Libro de texto",
            "cantidad": 2,
            "importe_unitario": 19.2308,
            "tipo_iva": 4,
            "tipo_req": 0
        }
    ],
    "total_factura": 106.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000154",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Auriculares",
            "cantidad": 1,
            "importe_unitario": 49.5868,
            "tipo_iva": 21,
            "tipo_req": 0,
            "descuento": 10
        },
        {
            "descripcion": "Caja de galletas",
            "cantidad": 4,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Libro de texto",
            "cantidad": 2,
            "importe_unitario": 19.2308,
            "tipo_iva": 4,
            "tipo_req": 0
        }
    ],
    "total_factura": 106.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-pnph2qfncM2AB-160",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-pnph2qfncM2AB-160&s=A2026&nf=000154&i=106&cr=157"
    },
    "msg": null
}
```

## Sale of goods to an EU company

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Exempt intra-community supply: the customer has a valid EU VAT number (NIF-IVA) in another EU country. Set `intracomunitaria: true`, give the country in `pais_cliente` and send the lines with 0 VAT.

Check the customer VAT number in VIES first (the API has a `POST` endpoint for VIES validation). `tipo_documento` defaults to `02` (NIF-IVA, EU VAT number) for EU customers.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "512345678",
    "tipo_documento": "02",
    "nombre": "Exemplo Comércio, Lda",
    "direccion": "Rua das Flores 25",
    "cp": "4050-262",
    "pais_cliente": "PT",
    "serie": "A2026",
    "numero": "000155",
    "simplificada": false,
    "rectificativa": false,
    "intracomunitaria": true,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Pinza ER32 Ø21",
            "cantidad": 10,
            "importe_unitario": 15,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 150.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "512345678",
    "tipo_documento": "02",
    "nombre": "Exemplo Comércio, Lda",
    "direccion": "Rua das Flores 25",
    "cp": "4050-262",
    "pais_cliente": "PT",
    "serie": "A2026",
    "numero": "000155",
    "simplificada": false,
    "rectificativa": false,
    "intracomunitaria": true,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Pinza ER32 Ø21",
            "cantidad": 10,
            "importe_unitario": 15,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 150.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-Lvv848/Jq7SAF-104",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-Lvv848%2FJq7SAF-104&s=A2026&nf=000155&i=150&cr=006"
    },
    "msg": null
}
```

## Services to an EU company

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

B2B services to a company in another EU country: the transaction is not subject to Spanish VAT and the customer self-assesses it. Same as for goods, but with `tipo_operacion: "servicios"`; the API reports it as not subject under the place-of-supply rules.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "FR12345678901",
    "tipo_documento": "02",
    "nombre": "Exemple Conseil SARL",
    "direccion": "10 Rue de la Paix",
    "cp": "75002",
    "pais_cliente": "FR",
    "serie": "A2026",
    "numero": "000156",
    "simplificada": false,
    "rectificativa": false,
    "intracomunitaria": true,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Consultoría — septiembre",
            "cantidad": 1,
            "importe_unitario": 1800,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 1800.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "FR12345678901",
    "tipo_documento": "02",
    "nombre": "Exemple Conseil SARL",
    "direccion": "10 Rue de la Paix",
    "cp": "75002",
    "pais_cliente": "FR",
    "serie": "A2026",
    "numero": "000156",
    "simplificada": false,
    "rectificativa": false,
    "intracomunitaria": true,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Consultoría — septiembre",
            "cantidad": 1,
            "importe_unitario": 1800,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 1800.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-CtyQXr30bxiiH-175",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-CtyQXr30bxiiH-175&s=A2026&nf=000156&i=1800&cr=000"
    },
    "msg": null
}
```

## Distance sale to an EU consumer (OSS)

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

If you exceed the €10,000 annual threshold for distance sales within the EU, you charge the VAT of the buyer's country and declare it through the One-Stop Shop (OSS). Send `regimen_iva: 17`, the destination country in `pais_cliente` and that country's VAT rate in the lines. The API adds the `IE` cause (foreign tax) automatically.

Use the **delivery** country, not the billing country: it is the one that determines where the tax is due.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "W2026",
    "numero": "8812",
    "simplificada": true,
    "pais_cliente": "PT",
    "regimen_iva": 17,
    "tipo_operacion": "bienes",
    "lineas": [
        {
            "descripcion": "Zapatillas trail T42",
            "cantidad": 1,
            "importe_unitario": 89.4309,
            "tipo_iva": 23,
            "tipo_req": 0
        }
    ],
    "total_factura": 110.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "W2026",
    "numero": "8812",
    "simplificada": true,
    "pais_cliente": "PT",
    "regimen_iva": 17,
    "tipo_operacion": "bienes",
    "lineas": [
        {
            "descripcion": "Zapatillas trail T42",
            "cantidad": 1,
            "importe_unitario": 89.4309,
            "tipo_iva": 23,
            "tipo_req": 0
        }
    ],
    "total_factura": 110.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-5Exa5S6KxL2a7-167",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-5Exa5S6KxL2a7-167&s=W2026&nf=8812&i=110&cr=115"
    },
    "msg": null
}
```

## Export of goods outside the EU

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Goods leaving the EU: exempt under article 21 (`causa_exencion: "E2"`). Set `exportacion: true`. For an ID document that is not an EU VAT number, use `tipo_documento: "06"` (the default outside the EU).

If Spanish VAT was charged on the sale (for example, the customer picks the goods up in store), it is not an export: send it as a domestic invoice.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "93-1995874",
    "tipo_documento": "06",
    "nombre": "Example Bearings Inc.",
    "direccion": "16 Main Street, Unit 500",
    "cp": "01862",
    "pais_cliente": "US",
    "serie": "A2026",
    "numero": "000157",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": true,
    "causa_exencion": "E2",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Rodamiento HC7016",
            "cantidad": 10,
            "importe_unitario": 442.99,
            "tipo_iva": 0,
            "tipo_req": 0
        },
        {
            "descripcion": "Portes",
            "cantidad": 1,
            "importe_unitario": 135,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 4564.9
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "93-1995874",
    "tipo_documento": "06",
    "nombre": "Example Bearings Inc.",
    "direccion": "16 Main Street, Unit 500",
    "cp": "01862",
    "pais_cliente": "US",
    "serie": "A2026",
    "numero": "000157",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": true,
    "causa_exencion": "E2",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Rodamiento HC7016",
            "cantidad": 10,
            "importe_unitario": 442.99,
            "tipo_iva": 0,
            "tipo_req": 0
        },
        {
            "descripcion": "Portes",
            "cantidad": 1,
            "importe_unitario": 135,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 4564.9
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-6mm9NQoYl/HS/-090",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-6mm9NQoYl%2FHS%2F-090&s=A2026&nf=000157&i=4564.9&cr=145"
    },
    "msg": null
}
```

## Services to a non-EU company

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

B2B services to a company established outside the EU (for example, in the United Kingdom): not subject to Spanish VAT. Send them with `exportacion: true` and `tipo_operacion: "servicios"`.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "GB123456789",
    "tipo_documento": "06",
    "nombre": "Example Clinical Ltd",
    "direccion": "100 Long Avenue, Reading",
    "cp": "RG2 6GP",
    "pais_cliente": "GB",
    "serie": "A2026",
    "numero": "000158",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": true,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Estudio clínico — fase 2, centro 246",
            "cantidad": 1,
            "importe_unitario": 8764.78,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 8764.78
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "GB123456789",
    "tipo_documento": "06",
    "nombre": "Example Clinical Ltd",
    "direccion": "100 Long Avenue, Reading",
    "cp": "RG2 6GP",
    "pais_cliente": "GB",
    "serie": "A2026",
    "numero": "000158",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": true,
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Estudio clínico — fase 2, centro 246",
            "cantidad": 1,
            "importe_unitario": 8764.78,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 8764.78
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-oSl5G4+zCcsJD-085",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-oSl5G4%2BzCcsJD-085&s=A2026&nf=000158&i=8764.78&cr=121"
    },
    "msg": null
}
```

## Exempt transaction (art. 20)

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`

VAT-exempt services to customers in Spain: healthcare, education, insurance… Send `causa_exencion: "E1"` and the lines at 0 VAT. Do not set `exportacion`: it is a domestic transaction.

Available causes: `E1` to `E6`, `OT`, `RL`, `IE` and `VT`. If you do not give one on a 0 VAT line, the API determines it.

In Verifactu the API works out the exemption cause from the rest of the data; you do not need to send it.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "12345678Z",
    "nombre": "Ane Etxeberria Garai",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "C2026",
    "numero": "0071",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": false,
    "regimen_iva": "01",
    "causa_exencion": "E1",
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Sesión de fisioterapia",
            "cantidad": 4,
            "importe_unitario": 45,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 180.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "12345678Z",
    "nombre": "Ane Etxeberria Garai",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "C2026",
    "numero": "0071",
    "simplificada": false,
    "rectificativa": false,
    "exportacion": false,
    "regimen_iva": "01",
    "causa_exencion": "E1",
    "tipo_operacion": "servicios",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Sesión de fisioterapia",
            "cantidad": 4,
            "importe_unitario": 45,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 180.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-elZvKygUde3f/-010",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-elZvKygUde3f%2F-010&s=C2026&nf=0071&i=180&cr=227"
    },
    "msg": null
}
```

## Sale to a retailer under the equivalence surcharge

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

When you sell to a retailer under the equivalence surcharge scheme, you also charge the surcharge. It goes per line in `tipo_req`: 5.2% with 21% VAT, 1.4% with 10% VAT and 0.5% with 4% VAT.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "12345678Z",
    "nombre": "Mikel Lasa Ugarte (Ferretería Lasa)",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000159",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Taladro percutor",
            "cantidad": 2,
            "importe_unitario": 64.9,
            "tipo_iva": 21,
            "tipo_req": 5.2
        },
        {
            "descripcion": "Bolsa de pienso 3 kg",
            "cantidad": 6,
            "importe_unitario": 8.5,
            "tipo_iva": 10,
            "tipo_req": 1.4
        }
    ],
    "total_factura": 220.62
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "12345678Z",
    "nombre": "Mikel Lasa Ugarte (Ferretería Lasa)",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000159",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "bienes",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Taladro percutor",
            "cantidad": 2,
            "importe_unitario": 64.9,
            "tipo_iva": 21,
            "tipo_req": 5.2
        },
        {
            "descripcion": "Bolsa de pienso 3 kg",
            "cantidad": 6,
            "importe_unitario": 8.5,
            "tipo_iva": 10,
            "tipo_req": 1.4
        }
    ],
    "total_factura": 220.62
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-vgJFp/txb60t0-215",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-vgJFp%2Ftxb60t0-215&s=A2026&nf=000159&i=220.62&cr=133"
    },
    "msg": null
}
```

## Issuer under the equivalence surcharge

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`

If **you** are the retailer under the equivalence surcharge scheme, set `modo_recargo_equivalencia: true`. If a line falls under the general scheme (for example, a service), mark it with `regimen_general: true`.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "BS2026",
    "numero": "243",
    "simplificada": true,
    "modo_recargo_equivalencia": true,
    "lineas": [
        {
            "descripcion": "Batido de vainilla 780 g",
            "cantidad": 4,
            "importe_unitario": 44.4545,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Asesoramiento nutricional",
            "cantidad": 1,
            "importe_unitario": 20,
            "tipo_iva": 21,
            "tipo_req": 0,
            "regimen_general": true
        }
    ],
    "total_factura": 219.8
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "BS2026",
    "numero": "243",
    "simplificada": true,
    "modo_recargo_equivalencia": true,
    "lineas": [
        {
            "descripcion": "Batido de vainilla 780 g",
            "cantidad": 4,
            "importe_unitario": 44.4545,
            "tipo_iva": 10,
            "tipo_req": 0
        },
        {
            "descripcion": "Asesoramiento nutricional",
            "cantidad": 1,
            "importe_unitario": 20,
            "tipo_iva": 21,
            "tipo_req": 0,
            "regimen_general": true
        }
    ],
    "total_factura": 219.8
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-jqQ4qZYx13cnK-093",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-jqQ4qZYx13cnK-093&s=BS2026&nf=243&i=219.8&cr=205"
    },
    "msg": null
}
```

## Reverse charge

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Transactions in which the customer self-assesses the VAT (construction work, scrap metal, investment gold…). Set `inversion_sujeto_pasivo: true` and send the lines at 0 VAT.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000160",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "inversion_sujeto_pasivo": true,
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Rehabilitación de fachada — certificación 2",
            "cantidad": 1,
            "importe_unitario": 12500,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 12500.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000160",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "inversion_sujeto_pasivo": true,
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Rehabilitación de fachada — certificación 2",
            "cantidad": 1,
            "importe_unitario": 12500,
            "tipo_iva": 0,
            "tipo_req": 0
        }
    ],
    "total_factura": 12500.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-52qeyb1uPLp0g-011",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-52qeyb1uPLp0g-011&s=A2026&nf=000160&i=12500&cr=133"
    },
    "msg": null
}
```

## Self-employed professional with IRPF withholding

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

`retencion` is the withheld **amount** in euros (not the percentage): here, 15% of €850. `total_factura` is tax base + VAT, without subtracting the withholding: that is what the tax authority record requires. The net amount payable (base + VAT − withholding) belongs on your PDF invoice.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "P2026",
    "numero": "042",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "retencion": 127.5,
    "lineas": [
        {
            "descripcion": "Dirección de obra",
            "cantidad": 1,
            "importe_unitario": 850.0,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 1028.5
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "P2026",
    "numero": "042",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "retencion": 127.5,
    "lineas": [
        {
            "descripcion": "Dirección de obra",
            "cantidad": 1,
            "importe_unitario": 850.0,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 1028.5
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-X7oBr7IgZ0SpN-056",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-X7oBr7IgZ0SpN-056&s=P2026&nf=042&i=1028.5&cr=254"
    },
    "msg": null
}
```

## Invoice issued by a third party or by the recipient

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

If an accounting firm or a platform issues the invoice on your behalf, use `emitida_terceros: "T"`. If the customer issues it (self-billing), use `"D"`. The default is `"N"`.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "T2026",
    "numero": "0005",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "emitida_terceros": "T",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Comisión de venta — octubre",
            "cantidad": 1,
            "importe_unitario": 310,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 375.1
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "T2026",
    "numero": "0005",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "emitida_terceros": "T",
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Comisión de venta — octubre",
            "cantidad": 1,
            "importe_unitario": 310,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 375.1
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-GNUmers9cHezr-147",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-GNUmers9cHezr-147&s=T2026&nf=0005&i=375.1&cr=052"
    },
    "msg": null
}
```

## Self-employed individual in Bizkaia with several IAE activity codes

  `POST`  /tbai/  `Bizkaia`

In Batuz (LROE form 140), a self-employed individual with several activities states on each invoice which IAE activity code it belongs to. If you do not send it, the code in the company profile is used. You can also give it per line with `epigrafe` inside each line.

Look up the codes with the Bizkaia IAE activity code list endpoint.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "BS2026",
    "numero": "244",
    "simplificada": true,
    "epigrafe": "165240",
    "lineas": [
        {
            "descripcion": "Clase de yoga — bono 5 sesiones",
            "cantidad": 1,
            "importe_unitario": 41.3223,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 50.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "BS2026",
    "numero": "244",
    "simplificada": true,
    "epigrafe": "165240",
    "lineas": [
        {
            "descripcion": "Clase de yoga — bono 5 sesiones",
            "cantidad": 1,
            "importe_unitario": 41.3223,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 50.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-a4POpy/7EOWxd-183",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-a4POpy%2F7EOWxd-183&s=BS2026&nf=244&i=50&cr=086"
    },
    "msg": null
}
```

## Credit note or corrective invoice by differences

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Partial or full refund: you send only the difference, as a negative amount. `tipo_rectificativa: "I"` (by differences, the default) and `clave_rectificativa: "R1"` (legally founded error or refund; the default). The original invoice goes in `rectificadas`.

If the original was issued with Ticketbai WS, its series, number and date are enough: the API retrieves the rest.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0031",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "I",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "A2026",
            "numero": "000154",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Devolución: auriculares",
            "cantidad": -1,
            "importe_unitario": 49.5868,
            "tipo_iva": 21,
            "tipo_req": 0,
            "descuento": 10
        }
    ],
    "total_factura": -54.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0031",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "I",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "A2026",
            "numero": "000154",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Devolución: auriculares",
            "cantidad": -1,
            "importe_unitario": 49.5868,
            "tipo_iva": 21,
            "tipo_req": 0,
            "descuento": 10
        }
    ],
    "total_factura": -54.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-yiyia1SeOi7Lh-013",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-yiyia1SeOi7Lh-013&s=R2026&nf=0031&i=-54&cr=210"
    },
    "msg": null
}
```

## Corrective invoice by substitution

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Fully replaces the original invoice: the lines are the **correct** ones, not the difference. `tipo_rectificativa: "S"`. The API also reports the amount of the original invoice (`ImporteRectificacionSustitutiva` block); if you do not want it to, use `"SN"`.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0032",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "S",
    "tipo_operacion": "servicios",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "A2026",
            "numero": "000153",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 2,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 254.1
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0032",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "S",
    "tipo_operacion": "servicios",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "A2026",
            "numero": "000153",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 2,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 254.1
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-SN3srgPHtcb/5-073",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-SN3srgPHtcb%2F5-073&s=R2026&nf=0032&i=254.1&cr=126"
    },
    "msg": null
}
```

## Refund of a simplified invoice (R5)

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

To correct a simplified invoice, use the code `R5`; the corrective invoice is also simplified.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "TR2026",
    "numero": "0012",
    "simplificada": true,
    "rectificativa": true,
    "clave_rectificativa": "R5",
    "tipo_rectificativa": "I",
    "rectificadas": [
        {
            "serie": "T2026",
            "numero": "1024",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Devolución: pintxo de tortilla",
            "cantidad": -1,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        }
    ],
    "total_factura": -3.0
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "serie": "TR2026",
    "numero": "0012",
    "simplificada": true,
    "rectificativa": true,
    "clave_rectificativa": "R5",
    "tipo_rectificativa": "I",
    "rectificadas": [
        {
            "serie": "T2026",
            "numero": "1024",
            "fecha": "28/11/2026"
        }
    ],
    "lineas": [
        {
            "descripcion": "Devolución: pintxo de tortilla",
            "cantidad": -1,
            "importe_unitario": 2.7273,
            "tipo_iva": 10,
            "tipo_req": 0
        }
    ],
    "total_factura": -3.0
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-q6uAmSZvgd7Tz-082",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-q6uAmSZvgd7Tz-082&s=TR2026&nf=0012&i=-3&cr=126"
    },
    "msg": null
}
```

## Correct an invoice issued with other software

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

If the original invoice was not sent through Ticketbai WS (for example, you issued it before switching software), also give its `base` (tax base), `cuota` (tax amount) and `recargo` (surcharge) in `rectificadas`.

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0033",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "I",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "SS",
            "numero": "800255",
            "fecha": "15/09/2026",
            "base": 593.96,
            "cuota": 124.73,
            "recargo": 0
        }
    ],
    "lineas": [
        {
            "descripcion": "Abono: 5 uds. ref. 16ER-AG60",
            "cantidad": -5,
            "importe_unitario": 28.38,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": -171.7
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "R2026",
    "numero": "0033",
    "simplificada": false,
    "rectificativa": true,
    "clave_rectificativa": "R1",
    "tipo_rectificativa": "I",
    "tipo_operacion": "bienes",
    "retencion": 0,
    "rectificadas": [
        {
            "serie": "SS",
            "numero": "800255",
            "fecha": "15/09/2026",
            "base": 593.96,
            "cuota": 124.73,
            "recargo": 0
        }
    ],
    "lineas": [
        {
            "descripcion": "Abono: 5 uds. ref. 16ER-AG60",
            "cantidad": -5,
            "importe_unitario": 28.38,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": -171.7
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-PIVmLaY+OG5Bg-082",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-PIVmLaY%2BOG5Bg-082&s=R2026&nf=0033&i=-171.7&cr=002"
    },
    "msg": null
}
```

## Resubmit a rejected invoice (Zuzendu)

  `POST`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

If the tax authority rejected an invoice, or registered it with wrong data that does **not** change the series, number or total amount (customer NIF or name, exemption cause…), resend it with the corrected data and `zuzendu: true`.

**In Bizkaia** `zuzendu: true` also works for invoices that Batuz **rejected**. Batuz has no Zuzendu as such: the API sends the correction through subchapter 1.2 of the LROE and keeps the TBAI identifier, the fingerprint and the QR code of the invoice you handed over. If you correct it again, it is sent as a modification of the same record. If the invoice was **accepted** and its data must change, issue a corrective invoice.

If you send an invoice that already exists with different data and without `zuzendu`, the API responds OK with the fingerprint already registered and warns you in `msg`: _"Previously sent with different values… Set zuzendu to true in case you want to change it"_.

```json
{
    "fecha": "28/11/2026",
    "hora": "10:30:00",
    "nif": "B87654323",
    "nombre": "Nombre Corregido S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000153",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "zuzendu": true,
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 3,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 308.55
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "28/11/2026",
    "hora": "10:30:00",
    "nif": "B87654323",
    "nombre": "Nombre Corregido S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "serie": "A2026",
    "numero": "000153",
    "simplificada": false,
    "rectificativa": false,
    "tipo_operacion": "servicios",
    "zuzendu": true,
    "retencion": 0,
    "lineas": [
        {
            "descripcion": "Mantenimiento web — octubre",
            "cantidad": 1,
            "importe_unitario": 120,
            "tipo_iva": 21,
            "tipo_req": 0
        },
        {
            "descripcion": "Horas de soporte",
            "cantidad": 3,
            "importe_unitario": 45,
            "tipo_iva": 21,
            "tipo_req": 0
        }
    ],
    "total_factura": 308.55
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-281126-ErBJO2dop3rpQ-153",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-281126-ErBJO2dop3rpQ-153&s=A2026&nf=000153&i=308.55&cr=249"
    },
    "msg": null
}
```

## Turn simplified invoices into a full invoice

  `POST`  /tbai-completar/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

The customer asks for an invoice for one or more receipts (simplified invoices) already issued. Send the customer details and the list of simplified invoices in `simplificadas`; the API generates the full invoice with the lines of those receipts (an invoice replacing simplified invoices).

```json
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "simplificada": false,
    "serie": "F2026",
    "numero": "0088",
    "zuzendu": false,
    "simplificadas": [
        {
            "serie": "T2026",
            "numero": "1024",
            "fecha": "28/11/2026"
        },
        {
            "serie": "T2026",
            "numero": "1031",
            "fecha": "28/11/2026"
        }
    ]
}
```

```bash
curl -X POST 'https://api-test.ticketbaiws.eus/tbai-completar/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "fecha": "29/11/2026",
    "hora": "10:30:00",
    "nif": "B12345674",
    "nombre": "Cliente Ejemplo S.L.",
    "direccion": "Calle Mayor 1",
    "cp": "01001",
    "pais_cliente": "ES",
    "simplificada": false,
    "serie": "F2026",
    "numero": "0088",
    "zuzendu": false,
    "simplificadas": [
        {
            "serie": "T2026",
            "numero": "1024",
            "fecha": "28/11/2026"
        },
        {
            "serie": "T2026",
            "numero": "1031",
            "fecha": "28/11/2026"
        }
    ]
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-cgDBZ2tr000g2-117",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-cgDBZ2tr000g2-117&s=F2026&nf=0088&i=0&cr=144"
    },
    "msg": null
}
```

## Cancel an invoice

  `DEL`  /tbai/  `Araba`  `Bizkaia`  `Gipuzkoa`  `Verifactu`

Cancels an invoice issued by mistake (for example, a duplicate or one issued to the wrong customer). You only need the series and number. If the transaction did take place and money has to be refunded, do not cancel it: issue a corrective invoice.

The response includes the fingerprint of the cancellation record.

```json
{
    "serie": "A2026",
    "numero": "000160"
}
```

```bash
curl -X DELETE 'https://api-test.ticketbaiws.eus/tbai/' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Token: YOUR_TEST_TOKEN' \
  -H 'Nif: B89670855' \
  --data-binary @- <<'JSON'
{
    "serie": "A2026",
    "numero": "000160"
}
JSON
```

**Sample response**

```json
{
    "result": "OK",
    "return": {
        "huella_tbai": "TBAI-B89670855-291126-YmMgkIPqt6WQ5-181",
        "qr": "iVBORw0KGgo… (PNG en base64)",
        "url": "https://batuz.eus/QRTBAI/?id=TBAI-B89670855-291126-YmMgkIPqt6WQ5-181&s=A2026&nf=000160&i=0&cr=222"
    },
    "msg": null
}
```

## How to read the response

- The API always responds with HTTP 200. Check the `result` field: `OK`, `PENDING` (Verifactu, queued) or `ERROR`.
- In TicketBAI, `return.huella_tbai` is the TBAI identifier printed on the invoice. In Verifactu you get `return.huella` (chained SHA-256 fingerprint).
- `return.qr` is the QR code as a PNG (base64), ready to print. `return.url` is the verification URL it contains.
- If the tax authority returns warnings for an accepted invoice, they arrive in `msg`. With `ERROR`, `msg` holds the reasons separated by `;`.
- Submission to the tax authority happens in the background. To find out about a later rejection, set up a [webhook](https://ticketbaiws.eus/en/api-documentation/) (you can ask to be notified of errors only with `solo_errores`).

Source: https://ticketbaiws.eus/en/desarrolladores/ejemplos/
