Via JSON payload

When your Peppol connection is activated, you unlock the ability to seamlessly transmit documents through this network. Let's dive into the process of crafting an invoice using a JSON payload.

Create an issued invoice

In the example below, you'll see how to generate an issued invoice with the delivery method set to peppol.

To send an invoice through Peppol, ensure that the transport_type_code is set to peppol and provide the pin_scheme and pin_value.

curl --location 'https://app.b2brouter.net/projects/{project-id}/invoices.json' \
--header 'X-B2B-API-Key: xxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
 "send_after_import": false,
  "invoice": {
    "number": "1",
    "date": "2024-01-21",
    "due_date": "2024-03-01",
    "terms": "custom",
    "buyer_reference": "071110000000-001-50",
    "payment_method": 58,
    "iban": "ES9815013231061668117743",
    "client": {
        "name": "Stadtverwaltung Koblenz",
        "taxcode": "148721830",
        "address": "Willi-Hörter-Platz 2",
        "postalcode": "56068",
        "city": "Koblenz",
        "province": "Rheinland-Pfalz",
        "country": "de",
        "pin_value": "071110000000-001-50",
        "pin_scheme": "0204",
        "transport_type_code": "peppol"
    },
    "invoice_lines_attributes": [
      {
        "unit": 1,
        "quantity": 1,
        "price": 1,
        "description": "Description line",
        "taxes_attributes": [
          {
            "category": "S",
            "name": "VAT",
            "percent": 19
          }
        ]
      }
    ]
}
}'

Typically, these attributes are the minimum requirements for Peppol to send the document. However, some recipients may require additional fields such as buyer_reference, as is the case with certain city halls in Germany.

Upon generating the invoice, B2Brouter will automatically assign the most suitable document type for the recipient, if the recipient has the capacity to receive invoices.

Send the invoice

The next step is to send the invoice. Before sending, as a Peppol Certified Service Provider, we meticulously verify the presence of all required data and the document's validity using official schematrons before transmission.

If the generated document is valid, it's transmitted via our access point.

Link to API Reference.

# Send invoice 
curl --location --request POST 'http:/app.b2brouter.net/invoices/send_invoice/{invoice-id}.json' 
--header 'X-B2B-API-KEY: xxxxxxxxxxx' 
--header 'Content-Type: application/json' 

Trace the invoice

Finally, you can check the events related to the invoice:

curl 
--location 'https://app.b2brouter.net/projects/{project-id}/events.json?invoice_id={invoice-id}'
--header 'X-B2B-API-Key: xxxx' 
--header 'Content-Type: application/json'