# Peppol Documents

My Azur API allows you to send and receive digital documents through the Peppol Network.

Peppol (**P**an-**E**uropean **P**ublic **P**rocurement **O**n**L**ine) is an exchange network where governments and companies can exchange documents in [UBL format](https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ubl).

<figure><img src="/files/A3tlZcSpgN9JoBbXOFJB" alt=""><figcaption><p>Peppol Network <a href="https://peppol.eu/what-is-peppol/peppol-transport-infrastructure/">https://peppol.eu/what-is-peppol/peppol-transport-infrastructure/</a></p></figcaption></figure>

## Environments

* **Sandbox:**  is an environment that let you try My Azur API before going in production, documents are exchanged through the Peppol test Network. Base URL is [https://api-sandbox.myazur.app](https://api.sitasoftware.lu)
* **Production**: documents are exchanged through the official Peppol Network in this environment. Base URL is [https://api.myazur.app](https://api.sitasoftware.lu)

## Preflight

The first thing you need is a My Azur Account, you can create a free one in the sandbox environment here:&#x20;

[https://sandbox.myazur.app/signup](https://myazur.app/signup)

Contact Sita Software and provide the email addresses that you used to create your My Azur account and the information about your company.  You will receive the **firebase\_api\_key** and your **Company ID**.&#x20;

## Postman&#x20;

A convenient approach to try My Azur API is to use [Postman](https://www.postman.com/). Download it, install it and create a free account.&#x20;

You can now Fork the Postman My Azur API collection by clicking the following button:&#x20;

[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/130150-431d6a31-4788-4d02-bc89-8878b1361570?action=collection%2Ffork\&collection-url=entityId%3D130150-431d6a31-4788-4d02-bc89-8878b1361570%26entityType%3Dcollection%26workspaceId%3Ddc078a0f-87b4-4ff2-a458-9745e3e6c017#?env%5BSandbox%20Env%5D=W3sia2V5IjoiYXBpX2Jhc2VfdXJsIiwidmFsdWUiOiJodHRwczovL2FwaS1zYW5kYm94LnNpdGFzb2Z0d2FyZS5sdSIsImVuYWJsZWQiOnRydWUsInR5cGUiOiJkZWZhdWx0Iiwic2Vzc2lvblZhbHVlIjoiaHR0cHM6Ly9hcGktc2FuZGJveC5zaXRhc29mdHdhcmUubHUiLCJzZXNza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lZCI6dHJ1ZSwidHlwZSI6ImFueSIsInNlc3Npb25WYWx1ZSI6IiIsInNlc3Npb25JbmRleCI6Nn1d)

In the next section we will setup the Postman environments.&#x20;

On the top right from the combo box select the Sandbox environment:&#x20;

<figure><img src="/files/0JVlplaFjGGFD6uPZC2u" alt=""><figcaption></figcaption></figure>

Click the Environments section on the left sidebar. You need to set in the **Current Value Column** the variables value for:

* firebase\_api\_key: provided by Sita Software
* test\_user\_email: your email address linked to your My Azur Account (sandbox or prod)
* test\_user\_password: your password

{% hint style="danger" %}
The current environment is displayed on the top right, always check your current environment before sending an API request. Make sure you select the "Sandbox Env" to complete this tutorial.
{% endhint %}

<figure><img src="/files/t2Ss9XjUnYgZI9rjs5Tr" alt=""><figcaption></figcaption></figure>

## Authentication

You can now fetch a Firebase access token, go back to the Collections section (left sidebar), expand the My Azur API collection and select the api request "Get Token".&#x20;

<figure><img src="/files/rc2w1YlsPamel98py3se" alt=""><figcaption><p>Fetch a new Firebase token</p></figcaption></figure>

Click "Send" to retrieve a new token. The new token will be set automatically as environment variable.&#x20;

{% hint style="info" %}
Firebase access token expires after 1 hour. Repeat the previous step to get a fresh one if the API returns a 401 status code.&#x20;
{% endhint %}

Now you can proceed and send any API request that requires authentication.

My Azur API uses Firebase Authentication, you can learn more about how to integrate Firebase Authentication in your app here: <https://firebase.google.com/docs/auth>

SDKs and documentation is provided for several programming languages and platforms, that simplify the integration with your application, here some resources:

* [Get Started with Firebase Authentication on Websites](https://firebase.google.com/docs/auth/web/start)
* [Get Started with Firebase Authentication in C++](https://firebase.google.com/docs/auth/cpp/start)
* [Get Started with Firebase Authentication on Apple Platforms](https://firebase.google.com/docs/auth/ios/start)&#x20;
* [Get Started with Firebase Authentication on Android](https://firebase.google.com/docs/auth/android/start)

## Folders and Peppol Documents

Peppol documents are organized in folders. You can handle multi-tenancy by creating one folder for each of your customers. You will create a separate My Azur account for each for your customers and grant permissions to read and write documents from/to a specific folder. As a company administrator you'll have full control over all your customers folders and all the documents sent and received.&#x20;

In the next sections we'll go through the details on how to build a **complete multi-tenancy system** that let you manage your customer's Peppol documents through My Azur REST API.&#x20;

In detail we will see:&#x20;

* How to create a folder for a tenant with a Peppol Identifier&#x20;
* How to create a My Azur account for a tenant and grant permissions to the folder.&#x20;
* How to send a Peppol document&#x20;
* How to fetch the received Peppol documents

{% hint style="info" %}
If you want to manage your tenants Peppol documents server-side than you don't need to create a separated account for each tenant. You company account can access all your tenants folders.&#x20;
{% endhint %}

## Create a folder for a tenant

A folder is a container of Peppol documents.  Each of your tenants will have a separated folder. To create a new folder make sure you fetched a valid firebase token.  Send a POST request  to /folders and provides your company\_id (Please contact Sita Software if you haven't received your company\_id)

Peppol documents are exchanged between legal entities. You need to provide the verified information about your tenants in the legal entity section: &#x20;

```powershell
curl --location 'https://api-sandbox.myazur.app/folders' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Firebase Access Token>' \
--data '{
    "name" : "Tenant 1",
    "company_id" : <Your company id>,
    "legal_entity" : {
        "party_name": "My Tenant 1",
        "line1": "220 Rue de la liberte",
        "city": "Test City",
        "zip": "Zippy",
        "country": "LU"
    }
}'
```

{% hint style="danger" %}
It's critically important that you verify your customer before creating a folder on My Azur API (Prod Environment). You are legally responsable for completing the KYC (Know Your Customer) process.
{% endhint %}

On Postman:

<figure><img src="/files/soP4YTtSJoK08nGHSxKk" alt=""><figcaption></figcaption></figure>

## Add the Peppol Identifier

We created our folder and the Peppol legal entity, you can now add the Peppol Identifier,  for instance in Luxembourg the Peppol identifier is the TVA number, use "LU:VAT" as scheme.&#x20;

```powershell
curl --location 'https://api-sandbox.myazur.app/folders/<folder_id>/peppol_identifiers' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <firebase token>' \
--data '{
	"superscheme": "iso6523-actorid-upis",
	"scheme": "LU:VAT",
	"identifier": "LU01234567"
```

On Postman:

<figure><img src="/files/6rMWi53tGocJ1hMugWJg" alt=""><figcaption><p>How to add a peppol identifier to a legal entity</p></figcaption></figure>

You'll get a 204 Status code if the operation is successful.&#x20;

## Create a My Azur account for a tenant

Each of your tentants will have a separated My Azur Account, we will grant the permissions to the new account to read/write documents from/to the folder that we created in the previous section.&#x20;

To create a tenant account you can let the tenants create their own account through the website: <https://myazur.app/signup> or you can create a their accounts  programmatically through  My Azur API by sending an HTTP POST request  to /users :&#x20;

```powershell
curl --location 'https://api-sandbox.myazur.app/users' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "admin@tenant1.com",
    "password": "<tenant password>",
    "firstname" : "John",
    "surname" : "Doe"
}
```

On Postman:

<figure><img src="/files/wtMF7EpiNjfc7D53au2B" alt=""><figcaption><p>How to create a My Azur account</p></figcaption></figure>

## Grant folder permissions to a tenant

We created a folder and an account for our tenant. We are gonna grant the folder permissions to the tenant account in this section.  We'll give a folder user role to the tenant account.&#x20;

Send an HTTP POST request to /folders/\<folder\_id>/user\_roles as the following:

```powershell
curl --location 'https://api-sandbox.myazur.app/folders/<folder_id>/user_roles' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <firebase_token>' \
--data-raw '{
    "email" : "john@doe.com",
    "role" : "folder_admin" 
}  
```

On Postman:

<figure><img src="/files/cdMv1QZ1E9oGvR45MSo8" alt=""><figcaption><p>How to add a folder admin</p></figcaption></figure>

## Send a Peppol document

We are ready to send a Peppol document in UBL format via My Azur API.&#x20;

Expand the Documents folder on the left side panel, and select the endpoint "Create a document in UBL format". On the center panel select the Params tab and set your folder id, make sure you use the correct folder id of your tenant for the environment you are working on (sandbox or production).&#x20;

<figure><img src="/files/xCDPNplsA5jxMOQER8RD" alt=""><figcaption><p>Send a Peppol Document in UBL format</p></figcaption></figure>

Switch to the Body tab, the Peppol document in UBL format must be encoded in base64 format. The routing section will determine who will receive the document. If the customer is a Luxembourg company the scheme must be "LU:VAT", the id is the TVA number.&#x20;

<figure><img src="/files/cFTltUHIum4LQyzRfVC2" alt=""><figcaption><p>Send a Peppol Document in UBL format in Luxembourg</p></figcaption></figure>

{% hint style="info" %}
You can send Peppol documents using a Firebase token generated from your account or from the customer account to which you have assigned the folder admin role in the previous section. See the Authentication section above for more details.
{% endhint %}

Click send, if you receive a 200 response status code it means you’ve successfully submitted an invoice for sending via the Peppol network.&#x20;

Your document is initially in the status "Submitted", you need to monitor the document status using the API. You can find the possible statues here:&#x20;

{% content-ref url="/pages/4MeitKTJwqSN5DfnVUoa" %}
[Document](/models/document.md)
{% endcontent-ref %}

{% hint style="info" %}
In case of a 4XX status code you can inspect the body response to learn more about the cause of the issue.
{% endhint %}

You can consider the document as successfully delivered when your document get the status = 5 (Succeded), until then you should display to your user an "in progress" status.&#x20;

To get the current status of a document use a strategy recommended in the section Incremental Sync [Incremental Sync](/peppol/incremental-sync.md)

**What if my Customer is not on the Peppol network?**

Then we can send an email with an electronic invoice attachment that is appropriate for the country your Customer is in. For instance, in de Germany we would send a ZUFGFeRD attachment, in France Facture-X and in Italy a FatturaPA. For India, the GSTN-signed JSON with a PDF that includes the QR code will be attached. Your receiver will know how to process these!

To test the email scenario, simply include a valid email address in the examples above and leave the "eIdentifiers" array empty, like this:

```
{
  "routing":  {
    "emails": [
      "test@example.com"
    ],
    "eIdentifiers": []
  }
}
```

## Receive a Peppol Document

You can get the list of the Peppol documents received by sending an HTTP GET request to /folders/:folder\_id/documents?incoming=true

<figure><img src="/files/Gle1ftpQCazcMQMW927a" alt=""><figcaption><p>Fetch the list of Peppol received documents</p></figcaption></figure>

You can then download each documents by sending a GET request to /folders/:folder\_id/documents/:document\_id and specify as request **Accept** header application/xml

```powershell
curl --location 'https://api-sandbox.myazur.app/folders/<folder_id>/documents/<document_id>' \
--header 'Accept: application/xml' \
--header 'Authorization: Bearer <Bearer Token>
```

<figure><img src="/files/QxhVMno9wl7vZLuv8YEV" alt=""><figcaption><p>Download a Peppol Document in UBL format</p></figcaption></figure>

## Conclusion

Congratulations 🎉 At this point, you have acquired the necessary knowledge to interact with the Peppol network through My Azur API.&#x20;

We have seen how to create an account for each of your customers (tenants), how to create a folder for each of them, and how each customer will send and receive Peppol documents.&#x20;

In the upcoming chapters, we will explore how to implement an efficient Peppol document synchronization system based on timestamps. This will allow you to create a high-performance Peppol client that maximizes the capabilities of My Azur API.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.myazur.app/peppol/peppol-documents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
