Getting startedYour first SAPI+ call

Your first SAPI+ call

Get a token and load the list of received eInvoices in the sandbox.

Prepare an activated test company, client_id, client_secret and its Peppol Participant ID. If you don't have client credentials yet, generate them in the web application. The examples use cURL.

1. Prepare the variables

Run commands in one terminal. Replace the Participant ID with the data of your sandbox company.

SAPI_BASE_URL='https://einvoice-v1-ynyiur6quq-ey.a.run.app/v1'
SAPI_PARTICIPANT_ID='0245:YOUR_TAX_ID'

2. Get an access token

In the request body, replace YOUR_CLIENT_ID and YOUR_CLIENT_SECRET with the assigned credentials. Keep the JSON valid, including escaping any quotes or backslashes in the values.

curl --request POST --fail-with-body --silent --show-error \
  "$SAPI_BASE_URL/sapi/auth/token" \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "grant_type": "client_credentials",
    "scope": "document:send document:receive"
  }'

From the successful JSON response, copy the value access_token and set it for further calls:

SAPI_ACCESS_TOKEN='ACCESS_TOKEN_FROM_RESPONSE'

Continue only after a successful response with a non-empty access_token. For 400, 401, 403 or 423, correct the input or access according to the instructions Authentication. Run the examples in a private test environment; Do not share credentials or answer with tokens and do not write in logs.

3. Load received documents

curl --fail-with-body --silent --show-error --get \
  "$SAPI_BASE_URL/sapi/document/receive" \
  --header "Authorization: Bearer $SAPI_ACCESS_TOKEN" \
  --header "X-Peppol-Participant-Id: $SAPI_PARTICIPANT_ID" \
  --header 'Accept: application/json' \
  --data-urlencode 'limit=20'

The header X-Peppol-Participant-Id specifies the company whose documents you are reading. Use the identifier of the company to which your credentials are authorized. The value should not automatically be the Participant ID of the counterparty from the last sent invoice.

The example does not use the status filter. If you only want unconfirmed documents, add --data-urlencode 'status=RECEIVED'. Do not automatically consider the default selection without this filter to only select unconfirmed documents.

4. Process the response

documents contains document metadata. If the list is empty, the company may not have received eInvoices available.

If you receive nextPageToken, pass it without modification in the query parameter pageToken of the next request. For each document, download the detail and XML, save or process it, and only then call acknowledge according to the instructions Receiving eInvoices.