API > SPFE - Report payment, collection, rejection or non-payment

SPFE - Report payment, collection, rejection or non-payment

POST  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.

This method reports the status of an invoice to the SPFE:

  • cobro (collection) or impago (non-payment) of an invoice you have issued with Ticketbai WS. It is identified by serie and numero.
  • pago (payment) or rechazo (rejection) of an invoice you have received. It is identified by factura, fecha_factura, nif_emisor and nombre_emisor: these are the same fields returned by GET spfe-recibidas, so you can pass them on as they are.

By default the status is queued and sent to the AEAT within the next few minutes (result: PENDING). Check the result later with GET spfe-estados, or send sincrono: true to report it immediately and get the AEAT response right away (OK or ERROR, with details in msg). If the issued invoice has not reached the SPFE yet, the status waits until it does.

To cancel a status reported by mistake, send the same request with baja: true.

PARAMETERS

estado string required
Status to report:
cobro → issued invoice collected
impago → issued invoice unpaid at the due date
pago → received invoice paid
rechazo → received invoice rejected
pago
baja boolean optional
true to cancel a previously reported status
false
serie string required for cobro and impago
Series of the invoice issued with Ticketbai WS
A
numero string required for cobro and impago
Number of the invoice issued with Ticketbai WS
2026000245
factura string required for pago and rechazo
Series and number of the received invoice, exactly as reported by the issuer
F2026-0153
fecha_factura string required for pago and rechazo
Issue date of the invoice in dd/mm/yyyy format. For cobro and impago it is optional and only used to tell apart invoices with the same series and number
03/11/2026
nif_emisor string required for pago and rechazo
NIF (Spanish tax ID) of the issuer of the received invoice
B01000012
nombre_emisor string required for pago and rechazo
Name or company name of the issuer of the received invoice
Empresa de ejemplo S.L.
fecha string optional
Date of the payment, collection or rejection in dd/mm/yyyy format. Cannot be in the future. Defaults to today
10/11/2026
vencimiento string required for pago and impago
Due date of the invoice in dd/mm/yyyy format (for impago, the date it should have been paid). Optional for cobro
03/12/2026
motivo_rechazo string optional (rechazo)
Reason for rejection:
01 → Commercial rejection (default)
02 → Private consumption or not related to the business activity
01
fecha_recepcion_mercancia string optional
Date the goods or services were received (dd/mm/yyyy), if relevant for calculating the payment term (Law 3/2004 on late payment)
05/11/2026
fecha_recepcion_factura string optional
Date the invoice was received (dd/mm/yyyy). If not given, the payment term runs from the issue date
04/11/2026
financiacion boolean optional (cobro)
The collection was made through a financing instrument arranged by the issuer
false
rectificada boolean optional (pago)
The paid invoice has been corrected (the payment does not need to match the original amount)
false
rectificativa_negativa boolean optional (pago)
Negative corrective invoice, with no associated payment
false
sincrono boolean optional
true to send the status to the AEAT immediately and return its response. By default it is queued
true


RESPONSE (return)

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


POST https://{entorno}.ticketbaiws.eus/spfe-estados/
$ curl --request POST \
     --url https://api-test.ticketbaiws.eus/spfe-estados/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z' \
     --data '
{
    "estado": "pago",
    "factura": "F2026-0153",
    "fecha_factura": "03/11/2026",
    "nif_emisor": "B01000012",
    "nombre_emisor": "Empresa de ejemplo S.L.",
    "fecha": "10/11/2026",
    "vencimiento": "03/12/2026",
    "sincrono": true
}'
$ 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()->comunicarEstado([
    'estado'        => 'pago',
    'factura'       => 'F2026-0153',
    'fecha_factura' => '03/11/2026',
    'nif_emisor'    => 'B01000012',
    'nombre_emisor' => 'Empresa de ejemplo S.L.',
    'fecha'         => '10/11/2026',
    'vencimiento'   => '03/12/2026',
    'sincrono'      => true,
]);

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/"
payload = {
    "estado": "pago",
    "factura": "F2026-0153",
    "fecha_factura": "03/11/2026",
    "nif_emisor": "B01000012",
    "nombre_emisor": "Empresa de ejemplo S.L.",
    "fecha": "10/11/2026",
    "vencimiento": "03/12/2026",
    "sincrono": True
}
headers = {"Accept": "application/json", "Content-Type": "application/json", "Token": "xxx", "Nif": "00000014Z"}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api-test.ticketbaiws.eus/spfe-estados/");

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

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"estado\": \"pago\", \"factura\": \"F2026-0153\", \"fecha_factura\": \"03/11/2026\", \"nif_emisor\": \"B01000012\", \"nombre_emisor\": \"Empresa de ejemplo S.L.\", \"fecha\": \"10/11/2026\", \"vencimiento\": \"03/12/2026\", \"sincrono\": true}");

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

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"estado\": \"pago\", \"factura\": \"F2026-0153\", \"fecha_factura\": \"03/11/2026\", \"nif_emisor\": \"B01000012\", \"nombre_emisor\": \"Empresa de ejemplo S.L.\", \"fecha\": \"10/11/2026\", \"vencimiento\": \"03/12/2026\", \"sincrono\": true}");
Request request = new Request.Builder()
  .url("https://api-test.ticketbaiws.eus/spfe-estados/")
  .post(body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "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": []
    },
    "msg": null
}
{ } Response queued (not synchronous) JSON
HTTP/1.1 200 OK
{
    "result": "PENDING",
    "return": {
        "id": 129,
        "estado": "pago",
        "baja": false,
        "factura": "F2026-0153",
        "fecha_factura": "03\/11\/2026",
        "nif_emisor": "B01000012",
        "fecha": "10\/11\/2026",
        "vencimiento": "03\/12\/2026",
        "result": "PENDING",
        "errores": []
    },
    "msg": null
}
{ } Response with an AEAT error JSON
HTTP/1.1 200 OK
{
    "result": "ERROR",
    "return": {
        "id": 130,
        "estado": "pago",
        "baja": false,
        "factura": "F2026-0153",
        "fecha_factura": "03\/11\/2026",
        "nif_emisor": "B01000012",
        "fecha": "10\/11\/2026",
        "vencimiento": "03\/12\/2026",
        "result": "ERROR",
        "errores": [
            {
                "codigo": "SPFE-ACTION-01",
                "descripcion": "No existe factura sobre la que actuar"
            }
        ]
    },
    "msg": "SPFE-ACTION-01: No existe factura sobre la que actuar"
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods