API > SPFE - Received invoices

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 and Edit company details 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 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
56
id integer optional
A specific invoice
57
estado string optional
pendiente (pending), pagada (paid) or rechazada (rejected)
pendiente
nif_emisor string optional
Invoices from a supplier
B01000012
factura string optional
Series and number of the invoice
F2026-0153
desde string optional
Invoice date from, in dd/mm/yyyy format
01/11/2026
hasta string optional
Invoice date to, in dd/mm/yyyy format
30/11/2026
limite integer optional
Maximum number of invoices. Default 100, maximum 500
100
ubl boolean optional
true to include in each invoice the full UBL XML exactly as delivered by the AEAT
false


RESPONSE (return, one row per invoice)

id integer
ID of the received invoice in Ticketbai WS
57
factura string
Series and number of the invoice
F2026-0153
fecha_factura string
Issue date (dd/mm/yyyy)
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
380
copia boolean
It is a copy of the invoice
false
nif_emisor / nombre_emisor string
Supplier issuing the invoice
B01000012
base / cuota / total number
Tax base, VAT amount and total payable
302.5
vencimiento string
Due date (dd/mm/yyyy) or null
03/12/2026
estado string
pendiente (pending), pagada (paid) or rechazada (rejected)
pendiente
localizador string
Invoice locator (reference) in the SPFE
fecha_descarga string
Date Ticketbai WS downloaded it from the AEAT
04/11/2026 10:05:12
ubl string
UBL XML of the invoice (only with ubl=true)


GET https://{entorno}.ticketbaiws.eus/spfe-recibidas/
$ curl --request GET \
     --url 'https://api-test.ticketbaiws.eus/spfe-recibidas/?desde_id=56' \
     --header 'Accept: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';

$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'test']);

$r = $tbai->spfe()->recibidas([
    'desde_id' => '56',
]);

if ($r->isError()) {
    echo $r->getMessageText();
} else {
    print_r($r->getData());
}
$ python -m pip install requests
import requests

url = "https://api-test.ticketbaiws.eus/spfe-recibidas/?desde_id=56"
headers = {"Accept": "application/json", "Token": "xxx", "Nif": "00000014Z"}
response = requests.request("GET", url, headers=headers)
print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api-test.ticketbaiws.eus/spfe-recibidas/?desde_id=56");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Token: xxx");
headers = curl_slist_append(headers, "Nif: 00000014Z");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api-test.ticketbaiws.eus/spfe-recibidas/?desde_id=56")
  .get()
  .addHeader("Accept", "application/json")
  .addHeader("Token", "xxx")
  .addHeader("Nif", "00000014Z")
  .build();

Response response = client.newCall(request).execute();
{ } Response 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"
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods