OpenAPI codegen

Generate a PSB API client in any language with OpenAPI Generator or NSwag. Download swagger.json and set up OAuth2 token management.

The PSB API is fully described as an OpenAPI 3.0 specification. If you work in a language without an official SDK (Python, Java, TypeScript, Go, Ruby, and so on), generate a typed client from swagger.json.

Get the specification

The current specification is available via:

  • Swagger UI: psb.econnect.eu — download swagger.json via the button at the top
  • Direct URL: https://psb.econnect.eu/swagger/v1/swagger.json

In some environments a subscription key is required as a query parameter:

https://psb.econnect.eu/v1/swagger.json?subscriptionKey={your-subscription-key}

The PSB documentation on psb.econnect.eu describes this pattern in the SDK examples.

Generate a client with OpenAPI Generator

Install OpenAPI Generator CLI and choose a generator (-g) for your language:

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

Other common generators:

Generator (-g)Language / frameworkpythonPythontypescript-axiosTypeScript (the Axios client)goGorubyRubyphpPHP (alternative to everbinding/econnect-psb-php)csharpC# (alternative to EConnect.Psb)

OpenAPI Generator supports more than 50 languages. See the generator list for options per language.

PHP example from the SDK documentation

The PHP SDK repository shows codegen with a custom package name:

openapi-generator-cli generate \
  -g php \
  -i "https://psb.econnect.eu/v1/swagger.json?subscriptionKey={your-subscription}" \
  -o ./psb-client-php \
  --additional-properties=invokerPackage=EConnect\\Psb
NSwag (.NET)

For .NET projects, NSwag is an alternative alongside the official EConnect.Psb package:

nswag openapi2csclient /input:https://psb.econnect.eu/swagger/v1/swagger.json /output:PsbClient.cs

EConnect.Psb additionally provides DI registration, token management and webhook validation that a pure codegen client does not have.

Authentication in generated clients

Generated clients do not include OAuth2 token management by default. You implement yourself:

  1. Obtain a token via POST /connect/token on the Identity Server
  2. Send the Bearer token in the Authorization header
  3. Refresh the token before expiry (tokens are valid for about one hour)
EnvironmentIdentity ServerAcceptancehttps://accp-identity.econnect.eu/connect/tokenProductionhttps://identity.econnect.eu/connect/token

See Authentication for the Client Credentials and Resource Owner flows.

Example with curl (basis for your own token logic):

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=your-client-id" \
  -d "client_secret=your-client-secret" \
  -d "scope=ap" | jq -r '.access_token')

In production, cache the token and refresh it only shortly before expiry — not on every API request.

Swagger UI as a reference

During development the Swagger UI is useful to:

  • Explore endpoints by functional area (SalesInvoice, Hook, Peppol, and so on)
  • Inspect request and response schemas
  • Run test calls with your Bearer token
Frequently asked questions
Should I use codegen or the official SDK?

For PHP and .NET, official SDKs are available with token management and examples. Codegen is the standard route for other languages, or when you want full control over the generated code.

How do I keep the client up to date when the API changes?

Regenerate the client when eConnect rolls out a new API version. Compare swagger.json periodically with your current version. Breaking changes are usually communicated via release notes and the PSB documentation.