Skip to main content

Invoicing Spanish Public Authorities with Facturae 3.2.2

Spanish law (Ley 25/2013) requires structured electronic invoices in Facturae format for any transaction with a public sector entity. Frihet generates the signed XML and manages the DIR3 administrative codes required for acceptance at FACe and other B2G portals.

What is Facturae and when does it apply

Facturae 3.2.2 is the XML format defined by the Ministry of Finance for electronic invoicing between businesses and the Spanish public administration (B2G). It has been mandatory since 2015 for invoices above €5,000 addressed to any public sector entity. Since 2017, no minimum threshold applies for the Central State Administration.

The standard uses XAdES-EPES enveloped digital signatures with the issuer's electronic certificate (FNMT, ACCV, CATCert, or another recognized CA). Without a valid signature, FACe automatically rejects the invoice.

DIR3 codes — the three mandatory administrative identifiers

Each B2G invoice requires three codes from the DIR3 database (Directorio Común de Unidades Orgánicas y Oficinas):

FieldDescriptionExample
Accounting office (Oficina contable)Department that records the invoiceL01280796
Managing body (Órgano gestor)Entity that contracted the serviceL01280796
Processing unit (Unidad tramitadora)Unit managing the fileL01280796

Look up the DIR3 codes for the receiving body in the official directory before issuing the invoice. Codes differ for each ministry, regional government, municipality, or public entity.

Marking a client as B2G in Frihet

To enable Facturae for a client:

  1. Go to Clients and open the client record.
  2. In the Tax data section, enable Public authority (B2G).
  3. Enter the three DIR3 codes: accounting office, managing body, and processing unit.
  4. For European entities (Germany, etc.), also enter the Leitweg-ID in the corresponding field.
  5. Save the client.

From this point, all invoices to that client will include the DIR3 fields in the generated Facturae XML.

Exporting the signed Facturae XML

Once the invoice to a B2G client is created:

  1. Open the invoice in Sent or Issued status.
  2. Click More optionsExport e-invoice.
  3. In the export dialog (EInvoiceExportDialog), select Facturae 3.2.2 (Spain B2G).
  4. If your digital certificate is configured, Frihet signs the XML automatically with XAdES-EPES.
  5. If you have not uploaded a certificate yet, the system redirects you to Settings → Integrations → Digital certificate.
  6. Download the resulting .xsig file.

The generated XML includes:

  • Schema compliant with facturae.gob.es version 3.2.2
  • XAdES-EPES signature with timestamp
  • DIR3 codes from the B2G client
  • Issuer NIF, IBAN, and company details from your profile

Submitting to FACe

FACe (Punto General de Entrada de Facturas Electrónicas) is the central portal for submitting B2G invoices to the Central State Administration and affiliated bodies.

Direct submission from Frihet

Frihet can submit the signed invoice to FACe via its Cloud Functions submitFace and getFaceStatus:

  1. On the exported invoice, click Send to FACe.
  2. Frihet sends the signed XML to the FACe SOAP service.
  3. The entry registration number (RCF) assigned by FACe is displayed.
  4. Invoice status updates in real time: Registered → Processing → Paid.

Manual submission at face.gob.es

If you prefer to manage submission outside Frihet:

  1. Access face.gob.es with your electronic certificate.
  2. Select Submit invoice and upload the .xsig file downloaded from Frihet.
  3. FACe validates the signature, DIR3 codes, and issuer NIF.
  4. Save the tracking code to check status later.
Regional portals

Some Autonomous Communities have their own portals in addition to FACe. Catalonia uses e.FACT, the Canary Islands use FACCan, etc. The Facturae 3.2.2 XML is compatible with all of them, although the DIR3 codes may differ.

Status tracking

After submission, the invoice passes through these statuses in FACe:

StatusDescription
RegisteredInvoice received and formally validated
ProcessingManaging body has received the invoice
AcknowledgedConformity with service delivered confirmed
ApprovedAuthorized for payment
PaidPayment completed
RejectedFormal error or discrepancy. Correction required.

Frihet queries status via getFaceStatus and reflects it in the invoice timeline.

Digital certificate

For XAdES-EPES signing you need a recognized digital certificate:

  • FNMT (Fábrica Nacional de Moneda y Timbre) — most common for individuals and companies
  • ACCV (Valencian Agency for Technology and Electronic Certification)
  • CATCert (Catalan Certification Agency)
  • Camerfirma, ANF AC, Firmaprofesional, and other accredited CAs

Frihet stores the certificate encrypted with AES-256-GCM in Firestore. It is never exposed in plaintext outside the signing process.

To upload the certificate:

  1. Go to Settings → Integrations → Digital certificate.
  2. Upload the .p12 or .pfx file with the corresponding password.
  3. Frihet validates the certificate and displays the expiry date.
Certificate renewal

Certificates for legal entities expire after 2 years. Frihet shows a warning 30 days before expiry. A signature with an expired certificate is rejected by FACe.

Credit notes and corrections B2G

Corrective invoices in B2G follow the same process as regular invoices. Frihet includes TipoDocumento = FC (corrective) and the reference to the original invoice in the XML. Submit the corrective invoice at FACe using the same process as a standard invoice.

Frequently asked questions

What if FACe rejects the invoice? FACe returns an error code with the rejection reason (invalid signature, incorrect DIR3 codes, NIF not registered as supplier, etc.). Correct the indicated error, regenerate the signed XML in Frihet, and resubmit.

Can I invoice a municipality that is not on FACe? Some municipalities have their own portal. Frihet generates valid Facturae XML for any B2G portal. Submission to portals other than FACe is done by downloading the XML and uploading it manually.

Is the Leitweg-ID required for B2G clients in Spain? No. The Leitweg-ID is the equivalent identifier for Germany (German B2G). Spain uses DIR3 codes. If your client is a German public entity, enter the Leitweg-ID in the corresponding client field.

Official references