API > SPFE - Get payments, collections, rejections and non-payments

SPFE - Get payments, collections, rejections and non-payments

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

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 last 100 statuses (pago, cobro, rechazo, impago: payment, collection, rejection, non-payment) reported to the SPFE with POST spfe-estados or from the private area, with the result of each one: PENDING (queued), OK (accepted by the AEAT) or ERROR (with the list of errors). All filters are optional and can be combined.

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

id integer optional
ID returned by POST spfe-estados
128
serie string optional
Series of an issued invoice
A
numero string optional
Number of an issued invoice
2026000245
factura string optional
Series and number of the invoice (issued or received)
F2026-0153
nif_emisor string optional
NIF (Spanish tax ID) of the invoice issuer
B01000012


RESPONSE (return, one row per status)

id integer
ID of the status in Ticketbai WS
128
estado / baja
Reported status and whether it is a cancellation
pago
factura, fecha_factura, nif_emisor
Invoice it refers to
F2026-0153
fecha / vencimiento
Reported dates (dd/mm/yyyy)
10/11/2026
result string
PENDING queued, OK accepted by the AEAT, ERROR rejected (see errores)
OK
errores array
List of AEAT errors: codigo and descripcion


GET https://{entorno}.ticketbaiws.eus/spfe-estados/
$ curl --request GET \
     --url 'https://api-test.ticketbaiws.eus/spfe-estados/?factura=F2026-0153&nif_emisor=B01000012' \
     --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()->estados([
    'factura'    => 'F2026-0153',
    'nif_emisor' => 'B01000012',
]);

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-estados/?factura=F2026-0153&nif_emisor=B01000012"
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-estados/?factura=F2026-0153&nif_emisor=B01000012");

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-estados/?factura=F2026-0153&nif_emisor=B01000012")
  .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": 128,
            "estado": "pago",
            "baja": false,
            "factura": "F2026-0153",
            "fecha_factura": "03\/11\/2026",
            "nif_emisor": "B01000012",
            "fecha": "10\/11\/2026",
            "vencimiento": "03\/12\/2026",
            "result": "OK",
            "errores": []
        },
        {
            "id": 131,
            "estado": "cobro",
            "baja": false,
            "factura": "A2026000245",
            "fecha_factura": "28\/10\/2026",
            "nif_emisor": "00000014Z",
            "fecha": "09\/11\/2026",
            "vencimiento": "27\/11\/2026",
            "result": "OK",
            "errores": []
        }
    ],
    "msg": null
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods