Verifactu XML structure: the invoicing record
The Verifactu invoicing record is an XML that follows the AEAT schemas SuministroLR.xsd and SuministroInformacion.xsd: a RegFactuSistemaFacturacion with a Cabecera (the taxpayer obliged to issue) and one or more RegistroFactura, each with a RegistroAlta or a RegistroAnulacion chained to the previous one by its hash. With the Verifactu API you don't build it: you send JSON and Verifacti generates the XML, which you can download.
The content and format of the record are set by RD 1007/2023 and Order HAC/1177/2024, in force; the schemas are on the AEAT developer portal.
Before you start
- To download a real XML, a free account: it includes a test environment and a test NIF.
- The AEAT XSD schemas, on its developer portal.
What the rules require
Each invoice generates an invoicing record with the content and format set by Order HAC/1177/2024. In the VERI*FACTU mode, that record is sent to the AEAT. Don't confuse the invoicing record with the invoice: the record is the XML that goes with each invoice, and one invoice can have several (registration, correction, cancellation). The summary of the rules, in Verifactu regulations.
General structure of a submission
A submission has one root, RegFactuSistemaFacturacion, with a Cabecera that identifies the taxpayer and one or more RegistroFactura. The elements use two namespaces: sum (SuministroLR.xsd) and sum1 (SuministroInformacion.xsd). It all travels inside a SOAP envelope.
RegFactuSistemaFacturacion
├── Cabecera
│ ├── ObligadoEmision NombreRazon and NIF
│ ├── Representante (optional)
│ ├── RemisionVoluntaria (optional) FechaFinVeriFactu, Incidencia
│ └── RemisionRequerimiento (optional)
└── RegistroFactura (one or more, up to 1,000)
└── RegistroAlta or RegistroAnulacionRegistration record (RegistroAlta)
Example: an F1 invoice
The XML Verifacti generates for the invoice in the PHP tutorial (the NIF's first record). It validates against the AEAT XSD. The SistemaInformatico data and the generation date and time are placeholders.
<sum:RegFactuSistemaFacturacion xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd">
<sum:Cabecera>
<sum1:ObligadoEmision>
<sum1:NombreRazon>EMPRESA DE PRUEBA SL</sum1:NombreRazon>
<sum1:NIF>B12345674</sum1:NIF>
</sum1:ObligadoEmision>
</sum:Cabecera>
<sum:RegistroFactura>
<sum1:RegistroAlta>
<sum1:IDVersion>1.0</sum1:IDVersion>
<sum1:IDFactura>
<sum1:IDEmisorFactura>B12345674</sum1:IDEmisorFactura>
<sum1:NumSerieFactura>A1</sum1:NumSerieFactura>
<sum1:FechaExpedicionFactura>18-11-2026</sum1:FechaExpedicionFactura>
</sum1:IDFactura>
<sum1:RefExterna>11111111-2222-3333-4444-555555555555</sum1:RefExterna>
<sum1:NombreRazonEmisor>EMPRESA DE PRUEBA SL</sum1:NombreRazonEmisor>
<sum1:Subsanacion>N</sum1:Subsanacion>
<sum1:RechazoPrevio>N</sum1:RechazoPrevio>
<sum1:TipoFactura>F1</sum1:TipoFactura>
<sum1:DescripcionOperacion>Servicios de consultoría</sum1:DescripcionOperacion>
<sum1:Destinatarios>
<sum1:IDDestinatario>
<sum1:NombreRazon>Empresa Cliente SL</sum1:NombreRazon>
<sum1:NIF>A15022510</sum1:NIF>
</sum1:IDDestinatario>
</sum1:Destinatarios>
<sum1:Desglose>
<sum1:DetalleDesglose>
<sum1:ClaveRegimen>01</sum1:ClaveRegimen>
<sum1:CalificacionOperacion>S1</sum1:CalificacionOperacion>
<sum1:TipoImpositivo>21</sum1:TipoImpositivo>
<sum1:BaseImponibleOimporteNoSujeto>200.00</sum1:BaseImponibleOimporteNoSujeto>
<sum1:CuotaRepercutida>42.00</sum1:CuotaRepercutida>
</sum1:DetalleDesglose>
</sum1:Desglose>
<sum1:CuotaTotal>42.00</sum1:CuotaTotal>
<sum1:ImporteTotal>242.00</sum1:ImporteTotal>
<sum1:Encadenamiento>
<sum1:PrimerRegistro>S</sum1:PrimerRegistro>
</sum1:Encadenamiento>
<sum1:SistemaInformatico>
<sum1:NombreRazon>PRODUCTOR DEL SOFTWARE SL</sum1:NombreRazon>
<sum1:NIF>89890001K</sum1:NIF>
<sum1:NombreSistemaInformatico>MiFacturador</sum1:NombreSistemaInformatico>
<sum1:IdSistemaInformatico>MF</sum1:IdSistemaInformatico>
<sum1:Version>2.1.0</sum1:Version>
<sum1:NumeroInstalacion>0001</sum1:NumeroInstalacion>
<sum1:TipoUsoPosibleSoloVerifactu>S</sum1:TipoUsoPosibleSoloVerifactu>
<sum1:TipoUsoPosibleMultiOT>S</sum1:TipoUsoPosibleMultiOT>
<sum1:IndicadorMultiplesOT>S</sum1:IndicadorMultiplesOT>
</sum1:SistemaInformatico>
<sum1:FechaHoraHusoGenRegistro>2026-11-18T09:30:00+00:00</sum1:FechaHoraHusoGenRegistro>
<sum1:TipoHuella>01</sum1:TipoHuella>
<sum1:Huella>5F291F83D926980C021E9BD733B3588E6593D803A822C57E039E6F894DD0DCE1</sum1:Huella>
</sum1:RegistroAlta>
</sum:RegistroFactura>
</sum:RegFactuSistemaFacturacion>| Element | What it holds |
|---|---|
IDVersion | Format version (1.0) |
IDFactura | IDEmisorFactura, NumSerieFactura and FechaExpedicionFactura |
RefExterna | Your own reference (optional) |
NombreRazonEmisor | Name or company name of the issuer |
Subsanacion · RechazoPrevio | If the record corrects an earlier one (optional) |
TipoFactura | F1, F2, F3, R1–R5 |
TipoRectificativa · FacturasRectificadas · FacturasSustituidas · ImporteRectificacion | Only in corrective and replacement invoices |
FechaOperacion | If the transaction date differs from the issue date (optional) |
DescripcionOperacion | Description of the transaction |
FacturaSimplificadaArt7273 · FacturaSinIdentifDestinatarioArt61d | Qualified simplified invoice (arts. 7.2 and 7.3) and invoice without recipient identification (art. 6.1.d) of the Invoicing Regulation (optional) |
Macrodato | Very high-value invoices (optional) |
EmitidaPorTerceroODestinatario · Tercero | Invoices issued by a third party or by the recipient (optional) |
Destinatarios | IDDestinatario: NombreRazon and NIF or IDOtro (not in F2 or R5) |
Cupon | Optional |
Desglose | DetalleDesglose: tax, regime key, classification or exemption, rate, base, tax amount and equivalence surcharge |
CuotaTotal · ImporteTotal | Sum of tax amounts and invoice total |
Encadenamiento | PrimerRegistro or RegistroAnterior |
SistemaInformatico | Identity of the invoicing system |
FechaHoraHusoGenRegistro | Date, time and time zone when the record was generated |
NumRegistroAcuerdoFacturacion · IdAcuerdoSistemaInformatico | Only with invoicing agreements with the AEAT (optional) |
TipoHuella · Huella | 01 (SHA-256) and the record hash |
Cancellation record (RegistroAnulacion)
<sum:RegFactuSistemaFacturacion xmlns:sum="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" xmlns:sum1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd">
<sum:Cabecera>
<sum1:ObligadoEmision>
<sum1:NombreRazon>EMPRESA DE PRUEBA SL</sum1:NombreRazon>
<sum1:NIF>B12345674</sum1:NIF>
</sum1:ObligadoEmision>
</sum:Cabecera>
<sum:RegistroFactura>
<sum1:RegistroAnulacion>
<sum1:IDVersion>1.0</sum1:IDVersion>
<sum1:IDFactura>
<sum1:IDEmisorFacturaAnulada>B12345674</sum1:IDEmisorFacturaAnulada>
<sum1:NumSerieFacturaAnulada>A1</sum1:NumSerieFacturaAnulada>
<sum1:FechaExpedicionFacturaAnulada>18-11-2026</sum1:FechaExpedicionFacturaAnulada>
</sum1:IDFactura>
<sum1:RefExterna>66666666-7777-8888-9999-000000000000</sum1:RefExterna>
<sum1:Encadenamiento>
<sum1:RegistroAnterior>
<sum1:IDEmisorFactura>B12345674</sum1:IDEmisorFactura>
<sum1:NumSerieFactura>A1</sum1:NumSerieFactura>
<sum1:FechaExpedicionFactura>18-11-2026</sum1:FechaExpedicionFactura>
<sum1:Huella>5F291F83D926980C021E9BD733B3588E6593D803A822C57E039E6F894DD0DCE1</sum1:Huella>
</sum1:RegistroAnterior>
</sum1:Encadenamiento>
<sum1:SistemaInformatico>
<sum1:NombreRazon>PRODUCTOR DEL SOFTWARE SL</sum1:NombreRazon>
<sum1:NIF>89890001K</sum1:NIF>
<sum1:NombreSistemaInformatico>MiFacturador</sum1:NombreSistemaInformatico>
<sum1:IdSistemaInformatico>MF</sum1:IdSistemaInformatico>
<sum1:Version>2.1.0</sum1:Version>
<sum1:NumeroInstalacion>0001</sum1:NumeroInstalacion>
<sum1:TipoUsoPosibleSoloVerifactu>S</sum1:TipoUsoPosibleSoloVerifactu>
<sum1:TipoUsoPosibleMultiOT>S</sum1:TipoUsoPosibleMultiOT>
<sum1:IndicadorMultiplesOT>S</sum1:IndicadorMultiplesOT>
</sum1:SistemaInformatico>
<sum1:FechaHoraHusoGenRegistro>2026-11-18T09:31:00+00:00</sum1:FechaHoraHusoGenRegistro>
<sum1:TipoHuella>01</sum1:TipoHuella>
<sum1:Huella>CC9B545E52FBF2AB47B88C7280F2C79070A2A67342F8B6737DFC349FA79EC055</sum1:Huella>
</sum1:RegistroAnulacion>
</sum:RegistroFactura>
</sum:RegFactuSistemaFacturacion>| Element | What it holds |
|---|---|
IDVersion | Format version (1.0) |
IDFactura | IDEmisorFacturaAnulada, NumSerieFacturaAnulada and FechaExpedicionFacturaAnulada |
RefExterna | Your own reference (optional) |
SinRegistroPrevio · RechazoPrevio | If an invoice with no previous record, or after a rejection, is cancelled (optional) |
GeneradoPor · Generador | Who generates the cancellation, if not the issuer (optional) |
Encadenamiento | PrimerRegistro or RegistroAnterior |
SistemaInformatico · FechaHoraHusoGenRegistro · TipoHuella · Huella | As in the registration |
The Encadenamiento block
In a taxpayer's first record, Encadenamiento carries PrimerRegistro with value S. From the second on, it carries RegistroAnterior with the IDEmisorFactura, NumSerieFactura, FechaExpedicionFactura and Huella of the previous record, whether a registration or a cancellation (as in the cancellation example above). How that hash is computed, in hash and chaining.
What the API generates from your JSON
With the Verifactu API you send JSON and Verifacti builds the XML. This is how fields map:
| API JSON field | XML element |
|---|---|
| NIF of the API key | IDEmisorFactura (and ObligadoEmision/NIF in the header) |
serie + numero | NumSerieFactura (joined, at most 60 characters) |
fecha_expedicion | FechaExpedicionFactura |
fecha_operacion | FechaOperacion |
tipo_factura | TipoFactura |
tipo_rectificativa, facturas_rectificadas, facturas_sustituidas, importe_rectificativa | TipoRectificativa, FacturasRectificadas, FacturasSustituidas, ImporteRectificacion |
descripcion | DescripcionOperacion |
nif or id_otro, and nombre | Destinatarios/IDDestinatario |
lineas[] | Desglose/DetalleDesglose (one per line) |
| Sum of the tax amounts of the lines | CuotaTotal |
importe_total | ImporteTotal |
Record uuid | RefExterna |
| Computed by Verifacti | Encadenamiento, FechaHoraHusoGenRegistro, TipoHuella, Huella |
sistema_informatico (optional, integrator identity) | SistemaInformatico |
Special characters
Values are written escaped in the XML (& as &, < as <), but the hash and the QR URL are computed over the unescaped value, which is what the AEAT stores. That is why the API rejects a serie or numero that already contains escaped entities (vf-verifactu-serie_numero_entidad): send the text as is.
How to see the XML that was sent
Download an invoice's XML with POST /verifactu/downloadXML (by serie and numero; it returns the request and response exactly as exchanged with the AEAT, SOAP envelope included) or export a period's with POST /verifactu/export (by ejercicio and periodo; it returns up to 500 URLs valid for 15 minutes and a token for the next ones). Since the AEAT receives records in batches, the XML may include records of other invoices. With the free account's test NIF you can use downloadXML; export only works with your own NIFs. In the test environment, XML files are kept for at most 90 days.
curl -X POST https://api.verifacti.com/verifactu/downloadXML \
-H "Authorization: Bearer $VERIFACTI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"serie": "A", "numero": "1"}'curl -X POST https://api.verifacti.com/verifactu/export \
-H "Authorization: Bearer $VERIFACTI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"ejercicio": "2026", "periodo": "11"}'Validate an XML
If you generate the XML yourself, validate it against the AEAT XSD schemas (for example with xmllint --schema SuministroLR.xsd) or with the Verifactu XML validator. The XSD checks the structure; the business rules are in the AEAT validations and errors document (v1.2.2). For the JSON of each case, see the Verifactu examples.
Common structure errors
| Code | Cause | Fix |
|---|---|---|
vf-verifactu-importe_total_cuadre | importe_total does not match (€10 margin) the sum of base_imponible, cuota_repercutida and cuota_recargo_equivalencia of the lines | Recalculate the total |
vf-verifactu-serie_numero_entidad | serie or numero with already-escaped XML entities | Send the text unescaped |
vf-verifactu-fecha_expedicion_hoy | fecha_expedicion is not today's date (test environment) | Send today's date as DD-MM-YYYY |
vf-verifactu-nif_formato | The recipient's NIF is not validly formatted | Check the NIF; for foreign recipients, use id_otro |
Every other code, in Verifactu errors.
Next step
With the Verifactu API you don't build the XML: you send JSON and Verifacti generates the record, chains it and sends it to the AEAT. Start with the quick start guide or the documentation.
Other Verifactu tutorials
Questions about the Verifactu XML
More questions about the Verifactu APIWhere are the Verifactu XSD files?
SuministroLR.xsd and SuministroInformacion.xsd for the submission, and RespuestaSuministro.xsd for the response.Is an invoicing record the invoice?
Do I have to sign the XML?
Can I see the XML the API generated?
POST /verifactu/downloadXML (one invoice) or POST /verifactu/export (a period).Where can I see the JSON of a corrective invoice?
Send JSON and leave the XML to the API
Try it with the free account and download the XML it generates.