> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://support.pdfgeneratorapi.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Generating Compliant E-Invoices (UBL, CII, XRechnung, Factur-X)

Electronic invoicing across Europe is becoming a regulatory requirement, and generating fully compliant e-invoices can be complex due to country-specific formats and standards. Our [E-Invoice API](https://pdfgeneratorapi.com/automate-einvoices-xrechnung-factur-x) simplifies this process by transforming simple JSON data into structured, **EN 16931**-compliant invoices in multiple formats including **UBL**, **CII**, **XRechnung**, and **Factur-X** / **ZUGFeRD**.

This tutorial walks you through the available E-Invoice endpoints, so you can generate compliant invoices for **B2G** or **B2B** platforms with minimal effort.

### How it works

1. Retrieve the JSON schema to understand the required structure.
2. Prepare invoice data in Peppol BIS Billing 3.0 format.
3. Send the data to the appropriate endpoint to generate the final invoice.
---

### 1. Get Schema

Before generating an e-invoice, you can retrieve the JSON schema defining the required structure. This ensures that your JSON payload aligns with EN 16931 and [Peppol BIS Billing 3.0 standards](https://docs.peppol.eu/poacc/billing/3.0/).

###### Endpoint Details

* **HTTP Method:** `GET`
* **Request URL:** `https://us1.pdfgeneratorapi.com/api/v4/einvoice/schema`
* **Documentation:** [Official API Docs](https://docs.pdfgeneratorapi.com/v4#tag/eInvoices/operation/getEInvoiceSchema)

###### cURL Example

```
curl --request GET \
  --url https://us1.pdfgeneratorapi.com/api/v4/einvoice/schema \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
```

The response returns the JSON schema for your e-invoice payload.
---

### 2. Create eInvoice

Once you have retrieved the JSON schema using the **Get Schema** endpoint, you can use it to construct a valid invoice payload. This ensures your request meets the **EN 16931** and **Peppol BIS Billing 3.0** requirements before sending it for conversion.

The Create eInvoice endpoint takes this structured JSON and transforms it into a fully compliant XML e-invoice.

###### Endpoint Details

* **HTTP Method:** `POST`
* **Request URL:** `https://us1.pdfgeneratorapi.com/api/v4/einvoice`
* **Documentation:** [Official API Docs](https://docs.pdfgeneratorapi.com/v4#tag/eInvoices/operation/createEInvoice)

|| Note: Before sending the request, ensure your `data` object follows the schema returned by the Get Schema endpoint to avoid validation errors.

###### Request Body

```
{
  "data": {},
  "type": "UBL",
  "output": "base64"
}
```

###### Field Descriptions

* `data` (required) – JSON payload representing a Peppol BIS Billing 3.0 invoice.
* `type` – Defines the output invoice format: `"UBL"` (default) – Universal Business Language format or `"CII"` – Cross-Industry Invoice format.
* `output` – Defines the response format: `"base64"` (default) – returns encoded content in the response or `"file"` – returns the file directly inline.

###### Response Example

```
{
  "response": "JVBERi0xLjcKJeLjz9MKNyAwIG9iago8PCAvVHlwZSA...",
  "meta": {
    "encoding": "base64",
    "content-type": "application/xml"
  }
}
```

The `response` field contains the generated XML invoice, while meta provides information about encoding and content type.

###### cURL Example

For quick testing or integration, you can use the following `cURL` command:

```
curl --request POST \
  --url https://us1.pdfgeneratorapi.com/api/v4/einvoice \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
  --header 'content-type: application/json' \
  --data '{"data":{},"type":"UBL","output":"base64"}'
```
---

### 3. Create XRechnung eInvoice

If you need to generate invoices specifically for the German market, you can use the **XRechnung endpoint**. This format is commonly required for **B2G transactions** and increasingly used in **B2B** scenarios.

While the structure of the request remains the same as in the **Create eInvoice** endpoint, this endpoint ensures that the generated output complies with **XRechnung specifications** in addition to **EN 16931**.

###### Endpoint Details

* **HTTP Method:** `POST`
* **Request URL:** `https://us1.pdfgeneratorapi.com/api/v4/einvoice/xrechnung`
* **Documentation:** [Official API Docs](https://docs.pdfgeneratorapi.com/v4#tag/eInvoices/operation/createXRechnungEInvoice)

|| Note: The request payload follows the same structure as the standard eInvoice endpoint and should align with the schema obtained from the Get Schema endpoint.

###### Request Body

```
{
  "data": {},
  "type": "UBL",
  "output": "base64"
}
```

###### Field Descriptions

* `data` (required) – JSON payload representing a Peppol BIS Billing 3.0 invoice.
* `type` – Defines the output invoice format: `"UBL"` (default) – Universal Business Language format or `"CII"` – Cross-Industry Invoice format.
* `output` – Defines the response format: `"base64"` (default) – returns encoded content in the response or `"file"` – returns the file directly inline.

###### Response Example

```
{
  "response": "JVBERi0xLjcKJeLjz9MKNyAwIG9iago8PCAvVHlwZSA...",
  "meta": {
    "encoding": "base64",
    "content-type": "application/xml"
  }
}
```

Similar to the Create eInvoice endpoint, the `response` field contains the generated XML invoice, while `meta` provides details about encoding and content type.

###### cURL Example

To quickly generate an XRechnung invoice, use the following `cURL` command:

```
curl --request POST \
  --url https://us1.pdfgeneratorapi.com/api/v4/einvoice/xrechnung \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
  --header 'content-type: application/json' \
  --data '{"data":{},"type":"UBL","output":"base64"}'
```
---

### 4. Create Factur-X / ZUGFeRD eInvoice

For use cases requiring both human-readable and machine-readable invoices, the **Factur-X / ZUGFeRD** format combines a **PDF document** with embedded **structured XML**. This endpoint generates a **PDF/A-3** invoice with compliant XML embedded, suitable for workflows that need both a readable invoice and structured data for automation or compliance purposes, using a template and invoice data provided in the request.

To get started quickly, you can use our ready-made [invoice template](https://pdfgeneratorapi.com/templates/free-templates/german-invoice-template-zugferd), so you don’t need to create one from scratch. If you prefer to create your own template, you can learn more about using the editor [here](https://support.pdfgeneratorapi.com/en/article/how-to-use-the-editor-1a194yy/).

###### Endpoint Details

* **HTTP Method:** `POST`
* **Request URL:** `https://us1.pdfgeneratorapi.com/api/v4/einvoice/facturx`
* **Documentation:** [Official API Docs](https://docs.pdfgeneratorapi.com/v4#tag/eInvoices/operation/createFacturXEInvoice)

###### Request Body

```
{
  "template": {
    "id": "REPLACE_TEMPLATE_ID",
    "version_id": 12,
    "data": {}
  },
  "profile": "basic",
  "output": "base64",
  "name": "Invoice 123",
  "metadata": {
    "author": "Organization name",
    "language": "en"
  }
}
```

###### Field Descriptions

* `template` (required) – PDF template defining the invoice layout, including `id`, `version_id`, and `data`, which contains invoice data in Peppol BIS Billing 3.0 format and is used to populate the template and generate the embedded XML.
* `profile` – Factur-X  / ZUGFeRD compliance level. Determines how much structured data is included:

| `"basic"` (default) – standard invoice with essential structured fields |
| `"minimum"` – basic invoice information, minimal automation support |
| `"basicwl"` – basic profile without line-level details |
| `"en16931"` – fully compliant with EN 16931 (recommended for most EU use cases) |
| `"extended"` – adds extra business data beyond EN 16931 |
| `"xrechnung"` – aligns with German XRechnung requirements |

* `output` – Defines the response format: `"base64"` (default) – returns encoded content in the response; `"file"` – returns the file inline; `"url"` or `"viewer"` – stores the document for 30 days and deletes it automatically.
* `name` – Name of the generated document.
* `metadata` – Object containing additional document information, e.g., `author`, `language`.

###### Response Example

```
{
  "response": "JVBERi0xLjcKJeLjz9MKNyAwIG9iago8PCAvVHlwZSA...",
  "meta": {
    "name": "a2bd25b8921f3dc7a440fd7f427f90a4.pdf",
    "display_name": "a2bd25b8921f3dc7a440fd7f427f90a4",
    "encoding": "base64",
    "content-type": "application/pdf",
    "public_id": "a2bd25b8921f3dc7a440fd7f427f90a4"
  }
}
```

The `response` contains the generated PDF invoice, including embedded XML, while `meta` provides document metadata and identification details.

###### cURL Example

To generate a hybrid Factur-X / ZUGFeRD invoice, use the following `cURL` command:

```
curl --request POST \
  --url https://us1.pdfgeneratorapi.com/api/v4/einvoice/facturx \
  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
  --header 'content-type: application/json' \
  --data '{"template":{"id":"REPLACE_TEMPLATE_ID","version_id":12,"data":{}},"profile":"basic","output":"base64","name":"Invoice 123","metadata":{"author":"Organization name","language":"en"}}'
```
---

### Which endpoint should I use?

* Use **Create eInvoice** for standard **EN 16931 XML** invoices (UBL or CII).
* Use **Create XRechnung eInvoice** for invoices required in Germany.
* Use **Create Factur-X / ZUGFeRD eInvoice** for hybrid PDF/XML invoices (commonly used in France and Germany).

---
### Related articles you may find helpful

* [How to create a JSON Web Token (JWT)?](/en/article/how-to-create-a-json-web-token-jwt-anv0ot/)
* [How to integrate PDF Generator API with n8n](/en/article/how-to-integrate-pdf-generator-api-with-n8n-zulhli/)
* [Is PDF Generator API GDPR compliant?](/en/article/is-pdf-generator-api-gdpr-compliant-1b4j83i/)