## SPFE - Received invoices

`GET`  https://{entorno}.ticketbaiws.eus/spfe-recibidas/

Spanish **Law 18/2022 "Crea y Crece"**  (implemented by RD 238/2026 and Order HAC/1028/2026) requires invoices between companies and self-employed professionals to be issued in electronic format and their status to be reported: **payment, collection, rejection or non-payment** . Ticketbai WS automatically sends the full invoices you issue through the API to Spanish customers with a NIF (Spanish tax ID) to the **SPFE (Solución Pública de Facturación Electrónica), the Spanish public B2B e-invoicing platform run by the AEAT (Spanish Tax Agency)** , in UBL format, and downloads the invoices you receive from your suppliers.

These methods are only available to companies that have sending to the SPFE enabled. It is enabled in the company details in the private area (**Factura electrónica B2B** , B2B e-invoicing) or with the **spfe**  parameter of the [New company](https://ticketbaiws.eus/en/empresas-post/) and [Edit company details](https://ticketbaiws.eus/en/empresas-put/) methods. Once enabled, invoices are sent from that day on.

Returns the invoices your company has received from its suppliers through the SPFE. Ticketbai WS queries and downloads them from the AEAT automatically every hour, together with their status (whether their payment or rejection has already been reported).

To keep your software in sync, store the highest **id**  received and pass it in **desde_id**  on the next call: you will get only the new invoices, from oldest to newest. To report the payment or rejection of an invoice, use [POST spfe-estados](https://ticketbaiws.eus/en/spfe-estados-post/) with its **factura** , **fecha_factura** , **nif_emisor**  and **nombre_emisor**  fields.

**Authorization:**  the AEAT only allows the company itself or an authorized representative to query received invoices. Ticketbai WS runs the query with the digital certificate uploaded to the company record. If there is no certificate, it has expired or the AEAT reports it as revoked, the response says so in **msg** .

**GET methods accept the parameters either in the body as a JSON payload or as a query string in the URL, as shown in the cURL example.**

**PARAMETERS**

- `desde_id` (integer, optional): Only invoices with an id greater than this one, in ascending order. Use it to fetch new invoices since the last query. Ejemplo: `56`
- `id` (integer, optional): A specific invoice. Ejemplo: `57`
- `estado` (string, optional): **pendiente**  (pending), **pagada**  (paid) or **rechazada**  (rejected) Ejemplo: `pendiente`
- `nif_emisor` (string, optional): Invoices from a supplier. Ejemplo: `B01000012`
- `factura` (string, optional): Series and number of the invoice. Ejemplo: `F2026-0153`
- `desde` (string, optional): Invoice date from, in dd/mm/yyyy format. Ejemplo: `01/11/2026`
- `hasta` (string, optional): Invoice date to, in dd/mm/yyyy format. Ejemplo: `30/11/2026`
- `limite` (integer, optional): Maximum number of invoices. Default 100, maximum 500. Ejemplo: `100`
- `ubl` (boolean, optional): true to include in each invoice the full UBL XML exactly as delivered by the AEAT. Ejemplo: `false`

**RESPONSE (return, one row per invoice)**

- `id` (integer, ID of the received invoice in Ticketbai WS) Ejemplo: `57`
- `factura` (string, Series and number of the invoice) Ejemplo: `F2026-0153`
- `fecha_factura` (string, Issue date (dd/mm/yyyy)) Ejemplo: `03/11/2026`
- `tipo_factura` (string, UBL invoice type code: 380 invoice, 381 credit note, 384 corrective invoice, 389 self-billed invoice, 386 prepayment invoice) Ejemplo: `380`
- `copia` (boolean, It is a copy of the invoice) Ejemplo: `false`
- `nif_emisor / nombre_emisor` (string, Supplier issuing the invoice) Ejemplo: `B01000012`
- `base / cuota / total` (number, Tax base, VAT amount and total payable) Ejemplo: `302.5`
- `vencimiento` (string, Due date (dd/mm/yyyy) or null) Ejemplo: `03/12/2026`
- `estado` (string, **pendiente**  (pending), **pagada**  (paid) or **rechazada**  (rejected)) Ejemplo: `pendiente`
- `localizador` (string, Invoice locator (reference) in the SPFE)
- `fecha_descarga` (string, Date Ticketbai WS downloaded it from the AEAT) Ejemplo: `04/11/2026 10:05:12`
- `ubl` (string, UBL XML of the invoice (only with ubl=true))

**GET** `https://{entorno}.ticketbaiws.eus/spfe-recibidas/`

```bash
$ curl --request GET \
     --url 'https://api-test.ticketbaiws.eus/spfe-recibidas/?desde_id=56' \
     --header 'Accept: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
```

Respuesta:

```json
HTTP/1.1 200 OK
{
    "result": "OK",
    "return": [
        {
            "id": 57,
            "factura": "F2026-0153",
            "fecha_factura": "03\/11\/2026",
            "tipo_factura": "380",
            "copia": false,
            "nif_emisor": "B01000012",
            "nombre_emisor": "Empresa de ejemplo S.L.",
            "base": 250.0,
            "cuota": 52.5,
            "total": 302.5,
            "vencimiento": "03\/12\/2026",
            "estado": "pendiente",
            "localizador": "LOCGENV1:O:NdjdSHy1PAqwlw\/WxTadoIW1lNqFECdDUIGVNyLwO2eDPnFUDys2wo6vFeQGNwGM5pf27bTi1w1Vx4mLbSVJg=",
            "fecha_descarga": "04\/11\/2026 10:05:12"
        },
        {
            "id": 58,
            "factura": "2026\/0098",
            "fecha_factura": "05\/11\/2026",
            "tipo_factura": "380",
            "copia": false,
            "nif_emisor": "A48000016",
            "nombre_emisor": "Suministros del Norte S.A.",
            "base": 1200.0,
            "cuota": 252.0,
            "total": 1452.0,
            "vencimiento": "05\/01\/2027",
            "estado": "pagada",
            "localizador": "LOCGENV1:O:tqkR9VoBCDcZ6NEtjWWCxChWU4M5+dYPjdhQzpsJwP2yfWATu9pJ+PCR+6HUgFJxUiVfBKSPtFzbSg=",
            "fecha_descarga": "06\/11\/2026 09:15:40"
        }
    ],
    "msg": null
}
```

Response without permission to query:

```json
HTTP/1.1 200 OK
{
    "result": "OK",
    "return": [],
    "msg": "SPFE: not authorized to query received invoices (10\/11\/2026 09:40). Upload the company certificate or grant power of attorney to Berein at the AEAT"
}
```

Fuente: https://ticketbaiws.eus/en/spfe-recibidas-get/
