> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invopop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Facturae Guide

> Generate Facturae XML invoices for B2G in Spain.

## Introduction

**Facturae** is Spain's official XML invoice format for **Business-to-Government (B2G)** transactions. The current version is **Facturae 3.2.2**, and invoices are submitted to public administrations through the [FACe](https://face.gob.es/) platform.

Facturae is required when invoicing any Spanish public administration body (central government, regional governments, local councils, etc.). Unlike other Spanish tax reporting systems (VERI\*FACTU, SII), Facturae does not require supplier registration — you simply generate the XML and submit it.

## Prerequisites

To generate Facturae invoices, ensure you have:

* An invoice with:
  * Supplier details (company name, tax ID, full address). Check the [Spanish](https://docs.gobl.org/regimes/es) regime for specifics.
  * Line items with name, price, and applicable taxes.

## Facturae Setup

To generate Facturae invoices, follow these instructions in the [Invopop Console](https://console.invopop.com):

<Steps>
  <Step title="Connect the Spain app">
    1. Navigate to **Configuration** → **Apps**.
    2. Locate **Spain** in the app discovery list.
    3. Click **Connect** to activate.

    No additional configuration is needed.
  </Step>

  <Step title="Configure invoice workflow">
    <Tabs>
      <Tab title="Template">
        <Card iconType="duotone" title="Facturae Generate Invoice" icon="code-branch" href="https://console.invopop.com/redirect/workflows/new?template=es-facturae" cta="Add to my workspace">
          This workflow will generate a Facturae XML document.
        </Card>
      </Tab>

      <Tab title="Code">
        Copy and paste into a new [Empty Invoice workflow](https://console.invopop.com/redirect/workflows/new?template=empty-invoice) code view.

        ```json Example Facturae invoice workflow theme={"system"}
        {
            "name": "Facturae generate invoice",
            "description": "Generate a Facturae XML invoice",
            "schema": "bill/invoice",
            "steps": [
                {
                    "id": "dc2d4780-0be4-11f1-99f1-2d47ed7bc202",
                    "name": "Add sequential code",
                    "provider": "sequence.enumerate",
                    "summary": "Dynamic · Facturae · 000001",
                    "config": {
                        "name": "Facturae",
                        "padding": 6,
                        "start": 1
                    }
                },
                {
                    "id": "e2d8e3f0-0be4-11f1-99f1-2d47ed7bc202",
                    "name": "Sign envelope",
                    "provider": "silo.close"
                },
                {
                    "id": "ef9897c0-0be4-11f1-99f1-2d47ed7bc202",
                    "name": "Generate Facturae XML",
                    "provider": "gov-es.facturae.generate"
                }
            ],
            "rescue": []
        }
        ```
      </Tab>

      <Tab title="Build from scratch">
        First, review our [workflows guide](/guides/features/workflows) to understand the basics.

        In [Console](https://console.invopop.com) create a new workflow and select [Empty Invoice workflow](https://console.invopop.com/redirect/workflows/new?template=empty-invoice) in the template selector, then add the essential steps:

        1. **Add sequential code**: Assigns a sequential code to the invoice.
        2. **Sign envelope**: The envelope must be signed before processing.
        3. **Generate Facturae XML**: Produces the Facturae 3.2.2 XML document.
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Administrative Centers (DIR3 Codes)

<Info>
  When invoicing Spanish **public administrations** via FACe, you must include three administrative centers identified by their **DIR3 codes**. Each public body publishes these codes in the [DIR3 directory](https://administracionelectronica.gob.es/ctt/dir3).
</Info>

The three required roles and their corresponding GOBL fields are:

| Facturae Role                            | Code | GOBL Field                                  |
| ---------------------------------------- | ---- | ------------------------------------------- |
| **Oficina Contable** (Accounting Office) | `01` | `customer.identities[]` with `scope: "tax"` |
| **Órgano Gestor** (Managing Body)        | `02` | `delivery.receiver.identities[0]`           |
| **Unidad Tramitadora** (Processing Unit) | `03` | `ordering.buyer.identities[0]`              |

See the FACe example below for a complete invoice with all three administrative centers.

## Running

Use the following example GOBL documents to generate Facturae invoices.

<AccordionGroup>
  <Accordion title="Facturae B2B Invoice">
    A standard Facturae invoice from a Spanish supplier to a Spanish business customer.

    Notice:

    * the [`es-facturae-v3`](https://docs.gobl.org/addons/es-facturae-v3) addon is required,
    * the `es-facturae-doc-type` and `es-facturae-invoice-class` tax extensions must be set,
    * both supplier and customer must have full address details and valid Spanish tax IDs.

    ```json Facturae B2G Invoice theme={"system"}

    {
    	"$schema": "https://gobl.org/draft-0/bill/invoice",
    	"$regime": "ES",
    	"$addons": [
    		"es-facturae-v3"
    	],
    	"uuid": "01922b1e-e288-7ab9-82f3-0c8c8c7956bc",
    	"type": "standard",
    	"code": "TEST01001F",
    	"issue_date": "2021-12-08",
    	"currency": "EUR",
    	"tax": {
    		"ext": {
    			"es-facturae-doc-type": "FC",
    			"es-facturae-invoice-class": "OO"
    		}
    	},
    	"supplier": {
    		"name": "Hypeprop Sl",
    		"alias": "Hypeprop",
    		"tax_id": {
    			"country": "ES",
    			"code": "B23103039"
    		},
    		"people": [
    			{
    				"name": {
    					"given": "Paloma",
    					"surname": "Araujo"
    				}
    			}
    		],
    		"addresses": [
    			{
    				"num": "74",
    				"street": "Campo Real",
    				"locality": "Torrejón De La Calzada",
    				"region": "Madrid",
    				"code": "28023",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "rxazy27xfc@iname.com"
    			}
    		],
    		"telephones": [
    			{
    				"label": "office",
    				"num": "+34910730028"
    			}
    		]
    	},
    	"customer": {
    		"name": "Moniward Sl",
    		"tax_id": {
    			"country": "ES",
    			"code": "B77436020"
    		},
    		"addresses": [
    			{
    				"num": "35",
    				"street": "Plaza Horno",
    				"locality": "Nombela",
    				"region": "Toledo",
    				"code": "45083",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "bfn25xf3p@lycos.co.uk"
    			}
    		]
    	},
    	"lines": [
    		{
    			"i": 1,
    			"quantity": "20",
    			"item": {
    				"name": "Operations and development - day rate",
    				"price": "200.00"
    			},
    			"sum": "4000.00",
    			"taxes": [
    				{
    					"cat": "VAT",
    					"rate": "standard",
    					"percent": "21.0%"
    				}
    			],
    			"total": "4000.00"
    		},
    		{
    			"i": 2,
    			"quantity": "2",
    			"item": {
    				"name": "Additional Overtime",
    				"price": "101.00"
    			},
    			"sum": "202.00",
    			"taxes": [
    				{
    					"cat": "VAT",
    					"rate": "standard",
    					"percent": "21.0%"
    				}
    			],
    			"total": "202.00"
    		}
    	],
    	"payment": {
    		"terms": {
    			"key": "due-date",
    			"due_dates": [
    				{
    					"date": "2021-12-30",
    					"amount": "5084.42",
    					"percent": "100%"
    				}
    			],
    			"notes": "Some kind of payment term note"
    		},
    		"instructions": {
    			"key": "credit-transfer",
    			"credit_transfer": [
    				{
    					"iban": "ES25 0188 2570 7185 4470 4761",
    					"name": "Bankrandom"
    				}
    			]
    		}
    	},
    	"totals": {
    		"sum": "4202.00",
    		"total": "4202.00",
    		"taxes": {
    			"categories": [
    				{
    					"code": "VAT",
    					"rates": [
    						{
    							"key": "standard",
    							"base": "4202.00",
    							"percent": "21.0%",
    							"amount": "882.42"
    						}
    					],
    					"amount": "882.42"
    				}
    			],
    			"sum": "882.42"
    		},
    		"tax": "882.42",
    		"total_with_tax": "5084.42",
    		"payable": "5084.42"
    	},
    	"notes": [
    		{
    			"key": "general",
    			"text": "Thank you for your custom!"
    		}
    	]
    }
    ```
  </Accordion>

  <Accordion title="Facturae Credit Note">
    A corrective invoice (credit note) referencing a previous Facturae invoice.

    Notice:

    * the `type` is set to `credit-note`,
    * a `preceding` entry references the original invoice with the `es-facturae-correction` code,
    * the `es-facturae-invoice-class` is set to `OR` (rectificativa).

    ```json Facturae Credit Note theme={"system"}
    {
    	"$schema": "https://gobl.org/draft-0/bill/invoice",
    	"$regime": "ES",
    	"$addons": [
    		"es-facturae-v3"
    	],
    	"uuid": "01922b1e-e283-7860-96aa-c57af9ffe67b",
    	"type": "credit-note",
    	"code": "TEST01001R",
    	"issue_date": "2021-12-08",
    	"currency": "EUR",
    	"preceding": [
    		{
    			"type": "standard",
    			"issue_date": "2021-12-08",
    			"code": "TEST01001F",
    			"ext": {
    				"es-facturae-correction": "01"
    			}
    		}
    	],
    	"tax": {
    		"ext": {
    			"es-facturae-doc-type": "FC",
    			"es-facturae-invoice-class": "OR"
    		}
    	},
    	"supplier": {
    		"name": "Hypeprop Sl",
    		"alias": "Hypeprop",
    		"tax_id": {
    			"country": "ES",
    			"code": "B23103039"
    		},
    		"people": [
    			{
    				"name": {
    					"given": "Paloma",
    					"surname": "Araujo"
    				}
    			}
    		],
    		"addresses": [
    			{
    				"num": "74",
    				"street": "Campo Real",
    				"locality": "Torrejón De La Calzada",
    				"region": "Madrid",
    				"code": "28023",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "rxazy27xfc@iname.com"
    			}
    		],
    		"telephones": [
    			{
    				"label": "office",
    				"num": "+34910730028"
    			}
    		]
    	},
    	"customer": {
    		"name": "Moniward Sl",
    		"tax_id": {
    			"country": "ES",
    			"code": "B77436020"
    		},
    		"addresses": [
    			{
    				"num": "35",
    				"street": "Plaza Horno",
    				"locality": "Nombela",
    				"region": "Toledo",
    				"code": "45083",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "bfn25xf3p@lycos.co.uk"
    			}
    		]
    	},
    	"lines": [
    		{
    			"i": 1,
    			"quantity": "20",
    			"item": {
    				"name": "Operations and development - day rate",
    				"price": "200.00"
    			},
    			"sum": "4000.00",
    			"taxes": [
    				{
    					"cat": "VAT",
    					"rate": "standard",
    					"percent": "21.0%"
    				}
    			],
    			"total": "4000.00"
    		},
    		{
    			"i": 2,
    			"quantity": "2",
    			"item": {
    				"name": "Additional Overtime",
    				"price": "101.00"
    			},
    			"sum": "202.00",
    			"taxes": [
    				{
    					"cat": "VAT",
    					"rate": "standard",
    					"percent": "21.0%"
    				}
    			],
    			"total": "202.00"
    		}
    	],
    	"totals": {
    		"sum": "4202.00",
    		"total": "4202.00",
    		"taxes": {
    			"categories": [
    				{
    					"code": "VAT",
    					"rates": [
    						{
    							"key": "standard",
    							"base": "4202.00",
    							"percent": "21.0%",
    							"amount": "882.42"
    						}
    					],
    					"amount": "882.42"
    				}
    			],
    			"sum": "882.42"
    		},
    		"tax": "882.42",
    		"total_with_tax": "5084.42",
    		"payable": "5084.42"
    	},
    	"notes": [
    		{
    			"key": "general",
    			"text": "Thank you for your custom!"
    		}
    	]
    }
    ```
  </Accordion>

  <Accordion title="Facturae FACe Invoice (with Administrative Centers)">
    An invoice addressed to a public administration via the FACe platform, including the three required DIR3 administrative centers.

    Notice:

    * the customer includes an identity with `scope: "tax"` for the **Oficina Contable** (DIR3 code `01`),
    * `delivery.receiver` includes the **Órgano Gestor** identity (DIR3 code `02`),
    * `ordering.buyer` includes the **Unidad Tramitadora** identity (DIR3 code `03`),
    * each public body publishes their DIR3 codes — look them up in the [DIR3 directory](https://administracionelectronica.gob.es/ctt/dir3).

    ```json Facturae FACe Invoice (B2G with Admin Centers) theme={"system"}
    {
    	"$schema": "https://gobl.org/draft-0/bill/invoice",
    	"$regime": "ES",
    	"$addons": [
    		"es-facturae-v3"
    	],
    	"type": "standard",
    	"code": "TEST01002F",
    	"issue_date": "2021-12-08",
    	"currency": "EUR",
    	"tax": {
    		"ext": {
    			"es-facturae-doc-type": "FC",
    			"es-facturae-invoice-class": "OO"
    		}
    	},
    	"supplier": {
    		"name": "Hypeprop Sl",
    		"alias": "Hypeprop",
    		"tax_id": {
    			"country": "ES",
    			"code": "B23103039"
    		},
    		"people": [
    			{
    				"name": {
    					"given": "Paloma",
    					"surname": "Araujo"
    				}
    			}
    		],
    		"addresses": [
    			{
    				"num": "74",
    				"street": "Campo Real",
    				"locality": "Torrejón De La Calzada",
    				"region": "Madrid",
    				"code": "28023",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "rxazy27xfc@iname.com"
    			}
    		],
    		"telephones": [
    			{
    				"label": "office",
    				"num": "+34910730028"
    			}
    		]
    	},
    	"customer": {
    		"name": "Ayuntamiento de Madrid",
    		"tax_id": {
    			"country": "ES",
    			"code": "P2807900B"
    		},
    		"identities": [
    			{
    				"scope": "tax",
    				"code": "L01280796"
    			}
    		],
    		"addresses": [
    			{
    				"num": "4",
    				"street": "Plaza de la Villa",
    				"locality": "Madrid",
    				"region": "Madrid",
    				"code": "28005",
    				"country": "ES"
    			}
    		],
    		"emails": [
    			{
    				"addr": "facturacion@madrid.es"
    			}
    		]
    	},
    	"delivery": {
    		"receiver": {
    			"name": "Concejalía de Hacienda",
    			"identities": [
    				{
    					"code": "LA0007407"
    				}
    			],
    			"addresses": [
    				{
    					"num": "3",
    					"street": "Calle Alcalá",
    					"locality": "Madrid",
    					"region": "Madrid",
    					"code": "28014",
    					"country": "ES"
    				}
    			]
    		}
    	},
    	"ordering": {
    		"buyer": {
    			"name": "Departamento de Compras",
    			"identities": [
    				{
    					"code": "LA0007408"
    				}
    			],
    			"addresses": [
    				{
    					"num": "10",
    					"street": "Gran Vía",
    					"locality": "Madrid",
    					"region": "Madrid",
    					"code": "28013",
    					"country": "ES"
    				}
    			]
    		}
    	},
    	"lines": [
    		{
    			"quantity": "20",
    			"item": {
    				"name": "Services rendered",
    				"price": "200.00"
    			},
    			"taxes": [
    				{
    					"cat": "VAT",
    					"rate": "standard"
    				}
    			]
    		}
    	],
    	"payment": {
    		"terms": {
    			"key": "due-date",
    			"due_dates": [
    				{
    					"date": "2021-12-30",
    					"amount": "4840.00",
    					"percent": "100%"
    				}
    			]
    		},
    		"instructions": {
    			"key": "credit-transfer",
    			"credit_transfer": [
    				{
    					"iban": "ES25 0188 2570 7185 4470 4761",
    					"name": "Bankrandom"
    				}
    			]
    		}
    	}
    }
    ```
  </Accordion>
</AccordionGroup>

<Info>
  In your invoice data, make sure to include the [`es-facturae-v3` addon](https://docs.gobl.org/addons/es-facturae-v3) and set the regime to `ES`.
</Info>

Once you have saved in Invopop, select <kbd>Run workflow</kbd> and select "Facturae Generate Invoice" from the sidebar.

***

<AccordionGroup>
  <Accordion title="🇪🇸 Invopop resources for Spain">
    |            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
    | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Compliance | <Icon icon="https://assets.invopop.com/flags/es.svg" /> [Invoicing compliance in Spain](/compliance/spain)<br /> <Icon icon="timeline" /> [Compliance timeline](/timelines/spain)                                                                                                                                                                                                                                                                                                                   |
    | Apps       | <Icon icon="https://assets.invopop.com/apps/gov-es/icon.svg" /> [Spain](/apps/spain)<br /> <Icon icon="https://assets.invopop.com/apps/verifactu/icon.svg" /> [VERI\*FACTU Spain](/apps/verifactu-spain)<br /><Icon icon="https://assets.invopop.com/apps/ticketbai/icon.svg" /> [TicketBAI Spain](/apps/ticketbai-spain)                                                                                                                                                                           |
    | Guides     | <Icon icon="book" /> [Facturae Guide](/guides/es-facturae)<br /><Icon icon="book" /> [VERI\*FACTU Invoicing Guide](/guides/es-verifactu)<br /><Icon icon="book" /> [VERI\*FACTU Supplier Onboarding](/guides/es-verifactu-supplier)<br /><Icon icon="book" /> [SII Invoicing Guide](/guides/es-sii)<br /><Icon icon="book" /> [SII Supplier Onboarding](/guides/es-sii-supplier)<br /><Icon icon="book" /> [TicketBAI Guide](/guides/es-ticketbai)                                                  |
    | FAQ        | <Icon icon="square-question" /> [Spain FAQ](/faq/spain)                                                                                                                                                                                                                                                                                                                                                                                                                                             |
    | GOBL       | <Icon icon="https://assets.invopop.com/icons/gobl.svg" />  [Spain Tax Regime](https://docs.gobl.org/regimes/es)<br /> <Icon icon="https://assets.invopop.com/icons/gobl.svg" /> [VERI\*FACTU Addon](https://docs.gobl.org/addons/es-verifactu-v1)<br /> <Icon icon="https://assets.invopop.com/icons/gobl.svg" /> [Facturae Addon](https://docs.gobl.org/addons/es-facturae-v3)<br /> <Icon icon="https://assets.invopop.com/icons/gobl.svg" /> [SII Addon](https://docs.gobl.org/addons/es-sii-v1) |
    | GitHub     | <Icon icon="github" /> [gobl.facturae](https://github.com/invopop/gobl.facturae)<br /><Icon icon="github" /> [gobl.verifactu](https://github.com/invopop/gobl.verifactu)<br /> <Icon icon="github" /> [gobl.ticketbai](https://github.com/invopop/gobl.ticketbai)                                                                                                                                                                                                                                   |
  </Accordion>
</AccordionGroup>

<Card title="Spain FAQ" icon="square-question" href="/faq/spain" arrow="true" horizontal>
  Find answers to frequently asked questions about invoicing in Spain →
</Card>

<Card title="Participate in our community" icon="forumbee" href="https://community.invopop.com" arrow="true" horizontal>
  Ask and answer questions about invoicing in Spain →
</Card>
