---
title: "Facturae B2G: invoicing Spanish public authorities (FACe)"
description: "Generate Facturae 3.2.2 invoices with XAdES-EPES signature for Spanish public administrations in Frihet and download them to file at FACe or other B2G portals."
canonical_url: "https://docs.frihet.io/en/cumplimiento/facturae-b2g"
language: "en"
---

# Invoicing Spanish Public Authorities with Facturae 3.2.2

Spanish law (Ley 25/2013) governs electronic invoices addressed to the Spanish public sector. 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). Any supplier to a public administration may issue electronic invoices. Since 15 January 2015, certain entities must use them, including public limited companies (*sociedades anónimas*) and limited liability companies (*sociedades de responsabilidad limitada*) ([Ley 25/2013](https://www.boe.es/buscar/act.php?id=BOE-A-2013-13722), Article 4 and Eighth Final Provision). Each administration may exclude invoices of up to €5,000 from that obligation by regulation: the Central State Administration excludes them from mandatory filing in FACe ([Orden HAP/1074/2014](https://www.boe.es/buscar/act.php?id=BOE-A-2014-6662), First Additional Provision).

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):

| Field | Description | Example |
|-------|-------------|---------|
| **Accounting office** (Oficina contable) | Department that records the invoice | `L01280796` |
| **Managing body** (Órgano gestor) | Entity that contracted the service | `L01280796` |
| **Processing unit** (Unidad tramitadora) | Unit managing the file | `L01280796` |

Look up the DIR3 codes for the receiving body in the [official directory](https://face.gob.es/es/administraciones/directorio-administraciones) 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. Tick **B2G Client (Public Administration)**. It only appears when the client type is **Company / Freelancer**.
3. Enter the three DIR3 codes: accounting office, managing body, and processing unit. The fields appear when the client's address country is Spain or is not set.
4. If the client's address is in Germany, the form shows the **Leitweg-ID** field instead of the DIR3 codes.
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. In the invoice actions menu, choose **Export e-invoice**.
2. Select the **Facturae 3.2.2 (FACe B2G)** format.
3. Tick **Sign XML (XAdES-EPES)**. You need a digital certificate uploaded in **Finance** → **Taxes** → **Compliance**.
4. Download the XML.

The generated XML includes:
- Schema compliant with `facturae.gob.es` version 3.2.2
- XAdES-EPES signature, if you tick the signing option
- 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.

From the app, Frihet does not submit invoices to FACe: download the signed XML and file it at face.gob.es.

1. Access [face.gob.es](https://face.gob.es) with your electronic certificate.
2. Select **Submit invoice** and upload the XML downloaded from Frihet.
3. FACe validates the signature, DIR3 codes, and issuer NIF.
4. Save the **tracking code** to check status later.

:::note 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.
:::

## 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

When you upload it, Frihet stores the certificate and its password encrypted with AES-256-GCM.

To upload the certificate:

1. Go to **Finance** → **Taxes** → **Compliance**.
2. Upload the `.p12` or `.pfx` file with the corresponding password.
3. Frihet validates the certificate and displays the expiry date.

:::caution Certificate renewal
Certificates for legal entities expire after 2 years. Frihet shows a warning as the expiry date approaches. 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 marks the corrective invoice with `InvoiceClass = OR` and includes the original invoice number 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. Download the XML and upload it to that body's portal, as with FACe.

**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

- Facturae: [https://www.facturae.gob.es](https://www.facturae.gob.es)
- FACe portal: [https://face.gob.es](https://face.gob.es)
- DIR3 directory: [https://face.gob.es/es/administraciones/directorio-administraciones](https://face.gob.es/es/administraciones/directorio-administraciones)
- Ley 25/2013: [https://www.boe.es/buscar/act.php?id=BOE-A-2013-12813](https://www.boe.es/buscar/act.php?id=BOE-A-2013-12813)
- Facturae XSD schema: [https://www.facturae.gob.es/formato/Paginas/version-3-2-2.aspx](https://www.facturae.gob.es/formato/Paginas/version-3-2-2.aspx)

## Related

- [Electronic invoicing formats](/facturacion/factura-electronica)
- [VeriFactu](/cumplimiento/verifactu)
- [TicketBAI](/cumplimiento/ticketbai-pais-vasco)
- [REST API](/desarrolladores/api-rest)
