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

| 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. 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 options** → **Export 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 submission service:

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](https://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.

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

## Status tracking

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

| Status | Description |
|--------|-------------|
| **Registered** | Invoice received and formally validated |
| **Processing** | Managing body has received the invoice |
| **Acknowledged** | Conformity with service delivered confirmed |
| **Approved** | Authorized for payment |
| **Paid** | Payment completed |
| **Rejected** | Formal error or discrepancy. Correction required. |

Frihet queries the status automatically 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. 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.

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

- 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)
- [REST API](/desarrolladores/api-rest)
