7 min read
Fakturia Team

Facturae 3.2: mandatory XML fields with a real example

Facturae 3.2 XML file structure: header, parties, invoices and signature, with a table of mandatory fields and a worked €1,000 example.

A Facturae 3.2 file is an XML document made up of four blocks. FileHeader records the version, the modality and the issuer type. Parties identifies the seller and the buyer for tax purposes. Invoices contains each invoice with its header, dates, taxes, totals and lines. The file closes with the XAdES electronic signature. If any of its mandatory fields is missing, the validator rejects the file.

The four blocks of the Facturae XML and their order

The root element is called Facturae and contains, always in this order, FileHeader, Parties, Invoices and the signature (ds:Signature). The XSD schema is strict about the order: a block out of place invalidates the document even if all the data is correct.

  1. FileHeader: describes the file as a whole, not each invoice. It states the schema version, whether it contains a single invoice or a batch, and who issues it.
  2. Parties: identifies the seller (SellerParty) and the buyer (BuyerParty) with their NIF (Spanish tax ID), their name or company name and their address.
  3. Invoices: groups one or several invoices (Invoice). Each one carries its own header data, taxes, totals and detail lines.
  4. XAdES signature: an advanced electronic signature over the whole document. It proves who issued it and that it has not been altered.

The tags are in English even though the format is Spanish. Amounts use a full stop as the decimal separator and carry no thousands separator.

Required data in the FileHeader and Parties of a Facturae XML

The file header and the parties are the first thing any validator checks. The table summarises the essential elements and the most common mistake in each one.

ElementWhat it containsTypical error
SchemaVersionSchema version usedDoes not match the XML namespace
ModalityI (individual) or L (batch)Marking I with several invoices inside
InvoiceIssuerTypeEM issuer, RE recipient or TE third partyUsing TE without filling in the ThirdParty block
BatchBatch identifier, number of invoices and totalsBatch totals different from the sum of the invoices
TaxIdentificationPerson type (F or J), residence and NIFNIF with spaces or hyphens
LegalEntity or IndividualCompany name, or first name and surnamesUsing LegalEntity for a sole trader
AddressInSpainAddress, postcode, town, province and countryIncomplete postcode or empty province

The BatchIdentifier is built by concatenating the issuer's NIF with the number and series of the first invoice. If the recipient is a public administration, the buyer also carries the AdministrativeCentres block with the DIR3 codes of the accounting office, the managing body and the processing unit.

Sub-blocks of each invoice inside Invoices, step by step

Each Invoice is built from the following sub-blocks. All of them are essential except TaxesWithheld, which depends on the transaction, and PaymentDetails.

  1. InvoiceHeader: includes the number (InvoiceNumber), the series if there is one, the document type (FC full, FA simplified, AF self-billed) and the class (OO original, OR corrective). A corrective invoice requires the Corrective block with the corrected invoice and the reason.
  2. InvoiceIssueData: issue date, invoice currency, tax currency and language.
  3. TaxesOutputs: output taxes charged, with tax type, rate, base and amount. In Spain VAT can be the standard 21%, the reduced 10% or the super-reduced 4%.
  4. TaxesWithheld: withholdings, such as the IRPF (Spanish personal income tax) withheld by a company that pays a professional.
  5. InvoiceTotals: gross amount, base before taxes, total taxes, total withholdings, invoice total and amount payable.
  6. Items: detail lines with description, quantity, unit price before taxes, gross amount and taxes for each line.
  7. PaymentDetails: due date, amount, payment method and account (IBAN). It is not always mandatory, but it makes reconciling the payment easier.

The FA type (simplified) is only valid within the limits of article 4 of Real Decreto 1619/2012: up to €400 VAT included, or up to €3,000 in certain retail sectors.

Example of a €1,000 invoice with VAT and IRPF in the XML

A professional invoices €1,000 in fees to a company, with 21% VAT and a 15% IRPF withholding. The table shows how the amounts are spread across the fields of the file.

Invoice itemCalculationAmountXML field
Taxable baseservice fees€1,000.00TotalGrossAmountBeforeTaxes
VAT (21%)€1,000.00 × 21%€210.00TotalTaxOutputs
IRPF withholding (15%)€1,000.00 × 15%−€150.00TotalTaxesWithheld
Invoice total (base + VAT)€1,000.00 + €210.00€1,210.00No field of its own: base plus taxes
Amount to collecttotal − withholding€1,060.00InvoiceTotal and TotalExecutableAmount

Two details prevent rejections. First: TotalTaxesWithheld is written as a positive number (150.00), because the schema itself subtracts it. Second: InvoiceTotal is the base plus VAT minus the withholding, not the total including VAT.

If the client is a private individual, the invoice carries no withholding. In that case the TaxesWithheld block disappears and TotalTaxesWithheld stays at 0.00. To check the figures before generating the file, you can use the invoice calculator with VAT and withholding.

XAdES signature, validation and use of the format in B2B e-invoicing

The XAdES signature sits inside the XML itself and is generated with an electronic certificate belonging to the issuer or to whoever signs on their behalf. Any later change, even a single space, breaks the signature. That is why you should validate the signed file, not the draft.

Between businesses, Ley 18/2022 (Ley Crea y Crece), Real Decreto 238/2026 and Orden HAC/1028/2026 set two deadlines:

  • 6 October 2027, for those whose turnover exceeded 8 million euros in the previous year.
  • 6 October 2028, for all other businesses and professionals, freelancers included.

Facturae is one of the formats accepted between platforms, as an EN 16931 model, alongside UBL, CII and EDIFACT. The public solution of the Spanish Tax Agency (AEAT) works in UBL. Anyone issuing through a private platform must send it a true copy in UBL at the same time. You will find the rest of the obligations in the electronic invoicing guide for freelancers.

This obligation is not VeriFactu. Electronic invoicing regulates the format and the exchange between businesses. VeriFactu regulates the software that generates the invoicing records and sends them to the AEAT.

Frequently asked questions

What is the difference between Facturae and UBL?

Facturae and UBL are two XML e-invoicing formats accepted between platforms in Spain. Facturae is the Spanish format, with its own tags and an XAdES signature. UBL is an international standard and is the format used by the AEAT public solution, which requires a true copy in UBL.

Does an invoice in Facturae format have to be signed?

An invoice in Facturae format includes the XAdES electronic signature as the last block of the XML. That signature proves the issuer's identity and guarantees the content has not been modified. Any change made after signing invalidates the file, so validation must be carried out on the already signed XML.

How is IRPF withholding shown in a Facturae XML?

IRPF withholding in a Facturae XML is declared in the TaxesWithheld block, with its rate, base and amount. The usual rates are 15%, or 7% for new freelancers. The total withheld appears as a positive figure in TotalTaxesWithheld and is subtracted to obtain InvoiceTotal.

Is Facturae 3.2 valid for mandatory B2B electronic invoicing?

Facturae 3.2 is valid as an exchange format between platforms in B2B electronic invoicing, because it is accepted as an EN 16931 model. Anyone issuing through a private platform must also send a true copy in UBL to the AEAT public solution. For most freelancers, the deadline is 6 October 2028.

If you want to know how these obligations affect you and from what date, take Fakturia's free VeriFactu risk diagnosis: in 2 minutes you will have a clear picture of your situation.

Share X LinkedIn
Newsletter

Stay in the loop

Get the latest fiscal updates for freelancers and companies delivered to your inbox.

No spam. Only what matters.
← Back to newsMore on E-invoicing →