SDKs and sample code

Available SDKs, client libraries and the interactive API documentation for the eConnect PSB API.

eConnect offers SDKs and client libraries that let you integrate with the PSB API faster. In addition, you can use the OpenAPI specification (swagger.json) to generate a client yourself in virtually any programming language.

Available SDKs

Two officially supported SDKs are available on GitHub, under the organisation theinvoicingcompany:

SDKLanguageRepositoryeconnect-psb-dotnet.NET (C#)github.com/theinvoicingcompany/econnect-psb-dotneteconnect-psb-phpPHPgithub.com/theinvoicingcompany/econnect-psb-php

Both SDKs wrap the PSB REST API and provide typed methods for the most commonly used operations: authentication, sending and receiving invoices, managing hooks and querying party data.

.NET SDK

The .NET SDK is available as a NuGet package. After installation you can authenticate and make your first API call in just a few lines of code.

// Authenticatie en eerste aanroep met de .NET SDK
var client = new PsbClient(new PsbClientOptions
{
    ClientId = "jouw-client-id",
    ClientSecret = "jouw-client-secret",
    BaseUrl = "https://accp-psb.econnect.eu",
    IdentityUrl = "https://accp-identity.econnect.eu"
});

var me = await client.GetMeAsync();
Console.WriteLine($"Account: {me.Name}");

Tip: use the acceptance URLs (accp-psb and accp-identity) during development. Switch to the production URLs when you go live.

PHP SDK

The PHP SDK is installed via Composer. The SDK handles OAuth token management automatically, so you can focus on the business logic.

// Authenticatie en eerste aanroep met de PHP SDK
$client = new \EConnect\Psb\PsbClient([
    'client_id' => 'jouw-client-id',
    'client_secret' => 'jouw-client-secret',
    'base_url' => 'https://accp-psb.econnect.eu',
    'identity_url' => 'https://accp-identity.econnect.eu',
]);

$me = $client->getMe();
echo "Account: " . $me->getName();
Generating your own client with OpenAPI

Working in a language other than .NET or PHP? The PSB API is fully documented as an OpenAPI 3.0 specification. You can download the swagger.json from psb.econnect.eu and use it to generate a client with OpenAPI Generator.

OpenAPI Generator supports more than 50 languages and frameworks, including Java, Python, TypeScript, Go and Ruby. An example using the command-line tool:

openapi-generator-cli generate \
  -i https://psb.econnect.eu/swagger/v1/swagger.json \
  -g java \
  -o ./psb-client-java

The result is a complete client library with typed models for all request and response objects. You only need to set up authentication (see the authentication article) and you can get started right away.

Note: generated clients do not include token management by default. Implement the logic to request and renew tokens yourself, or use an OAuth2 library for your platform.

Interactive API documentation (Swagger UI)

The most direct way to explore the API is via the Swagger UI at psb.econnect.eu. There you can:

  • View all endpoints, grouped by functional area (SalesInvoice, PurchaseInvoice, Hook, Peppol, etc.)
  • Inspect request and response schemas with all fields and their data types
  • Execute API calls with your own Bearer token, directly from the browser
  • Download the swagger.json for code generation

The Swagger UI is also a handy reference during development. If you are unsure about the structure of a request or the fields in a response, you will always find the current specification there.

Getting started directly with the REST API

Prefer not to use an SDK? The PSB API is a standard REST API that you can call with any HTTP client. Below is an example with curl that shows how to request a token and then retrieve your account details:

# Token aanvragen
TOKEN=$(curl -s -X POST https://accp-identity.econnect.eu/connect/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=jouw-client-id" \
  -d "client_secret=jouw-client-secret" \
  -d "scope=ap" | jq -r '.access_token')

# Accountgegevens ophalen
curl -s \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  https://accp-psb.econnect.eu/api/v1/me | jq .

In production applications it is advisable to cache the token and only renew it shortly before it expires (after approximately 3500 seconds). Do not request a new token for every request.

View the interactive API documentation