## 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](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.

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](https://ticketbaiws.eus/en/spfe-recibidas-get/), 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](https://ticketbaiws.eus/en/spfe-estados-get/), 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. Ejemplo: `pago`
- `baja` (boolean, optional): true to cancel a previously reported status. Ejemplo: `false`
- `serie` (string, required for cobro and impago): Series of the invoice issued with Ticketbai WS. Ejemplo: `A`
- `numero` (string, required for cobro and impago): Number of the invoice issued with Ticketbai WS. Ejemplo: `2026000245`
- `factura` (string, required for pago and rechazo): Series and number of the received invoice, exactly as reported by the issuer. Ejemplo: `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. Ejemplo: `03/11/2026`
- `nif_emisor` (string, required for pago and rechazo): NIF (Spanish tax ID) of the issuer of the received invoice. Ejemplo: `B01000012`
- `nombre_emisor` (string, required for pago and rechazo): Name or company name of the issuer of the received invoice. Ejemplo: `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. Ejemplo: `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. Ejemplo: `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. Ejemplo: `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) Ejemplo: `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. Ejemplo: `04/11/2026`
- `financiacion` (boolean, optional (cobro)): The collection was made through a financing instrument arranged by the issuer. Ejemplo: `false`
- `rectificada` (boolean, optional (pago)): The paid invoice has been corrected (the payment does not need to match the original amount) Ejemplo: `false`
- `rectificativa_negativa` (boolean, optional (pago)): Negative corrective invoice, with no associated payment. Ejemplo: `false`
- `sincrono` (boolean, optional): true to send the status to the AEAT immediately and return its response. By default it is queued. Ejemplo: `true`

**RESPONSE (return)**

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

**POST** `https://{entorno}.ticketbaiws.eus/spfe-estados/`

```bash
$ 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
}'
```

Respuesta:

```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"
}
```

Fuente: https://ticketbaiws.eus/en/spfe-estados-post/
