API documentation
OAuth lets your software call the QLS API without storing a user's password. The QLS auth service issues access tokens, and you send a token with every API request. This guide shows how to create an API client and get a token in two ways.
Which flow do I need?
| Your situation | Use |
|---|---|
| You connect your own organisation's systems to QLS. Your server calls the API and no user is present. | Option A: client credentials |
| You build an application where a QLS user signs in and approves access, and your app acts on behalf of that user. | Option B: authorization code |
On this page
- Before you start
- Step 1: create an API client
- Option A: client credentials (server-to-server)
- Option B: authorization code (act on behalf of a user)
- Keep your credentials safe
- Troubleshooting / FAQ
- Next steps
Before you start
- An account on the QLS auth service. You sign in at
https://auth.qls.nl. - Two-factor authentication (2FA). You need 2FA on your account to reach the API client screens.
- The right API. QLS has two APIs. Check carefully which one you need.
| API | Host | Documentation |
|---|---|---|
| New API | api.qls.nl |
my.qls.nl/docs/api |
| Old API | api.pakketdienstqls.nl |
api.pakketdienstqls.nl/redoc |
Many customers still use the old API. The access tokens you get with this guide work for both APIs. Only the endpoints differ: take them from the documentation of the API you use.
Step 1: create an API client
An API client is the identity of your application. It has a client ID and a client secret. Any user who is signed in to the auth service (with 2FA) can create one.
Create the client with an account that has access to the organisation whose data you want to reach. Your token gets the same access as that account.
- Sign in at
https://auth.qls.nl. - Open Settings in the profile menu and choose API Access. You see your own clients.
- Select Create.
- Enter a Name. Enter a Redirect URL only if you use Option B. The form accepts one redirect URL.
- Select Save, then open the client to see its Client ID and Client Secret.

The API Access screen under Settings lists your own clients. Select Create to add one.

The Create Client form. Fill in a name and, for Option B, your redirect URL. There is no grant type or scope to choose.

The client detail page shows the Client ID and the Client Secret. Use the show and copy buttons next to them. The secret is masked here.
Treat the client secret like a password
The secret stays visible in the app, so anyone who can open your signed-in session can read it. Store it in a secret manager or an environment variable.
In the examples below, replace <client_id> and <client_secret> with your own values.
Option A: client credentials (server-to-server)
Use this when your own server calls the QLS API for your own organisation, with no user present. Most integrations start here.
Overview
- Your server sends the client ID and client secret to the token URL.
- The auth service returns an access token.
- Your server calls the API and sends the token in the
Authorizationheader. - The API returns the data. Keep using the same token until it is about to expire, then request a new one.
Request a token
| Method | POST |
|---|---|
| URL | https://api.qls.nl/2026-1/auth/token |
| Headers | Content-Type: application/json |
| Body | JSON, with the fields below |
| Field | Value | Source |
|---|---|---|
grant_type |
Always client_credentials. |
Fixed value |
client_id |
The client ID from the API Access screen. | From QLS |
client_secret |
The client secret from the API Access screen. | From QLS |
Raw request
POST /2026-1/auth/tokenHost: api.qls.nlContent-Type: application/json{"grant_type": "client_credentials","client_id": "<client_id>","client_secret": "<client_secret>"}
The same request using curl
curl -X POST "https://api.qls.nl/2026-1/auth/token" \-H "Content-Type: application/json" \-d '{"grant_type": "client_credentials","client_id": "<client_id>","client_secret": "<client_secret>"}'
Response body
{"data": {"token_type": "Bearer","access_token": "<access_token>","expires_in": 1800}}
| Field | Meaning |
|---|---|
access_token |
The token you send to the API. |
token_type |
Always Bearer. |
expires_in |
Lifetime of the token in seconds. |
Reuse the token
An access token from this flow is valid for 30 minutes (expires_in: 1800 seconds). Do not request a new token for every API call: cache the access token and reuse it until shortly before it expires. Read expires_in from each response rather than hard-coding the lifetime. This response contains no refresh token. When the token expires, request a new one with the same call.
Call the API
| Method | As described in the API documentation, for example GET |
|---|---|
| Header |
|
Raw request
GET /2026-1/organizations/<organization_slug>/ordersHost: api.qls.nlAuthorization: Bearer <access_token>
The organisation you work in is part of the URL path. Take the exact endpoints and paths from the documentation of the API you use: the new API documentation or the old API documentation.
The token acts as the user who created the client. The API grants the same organisation access as that user's account. If that user loses access to an organisation, the token loses it too. Create the client with an account that has the access your integration needs.
Option B: authorization code (act on behalf of a user)
Use this when an individual QLS user signs in and approves access for your application. Your app then acts for that user.
Set the Redirect URL on the client first (Step 1). The redirect URI in every request must match that URL exactly, including scheme, host, path and trailing slash.
Overview
- Your app sends the user's browser to the authorize URL.
- The user signs in and selects Approve on the consent screen.
- The auth service redirects the browser to your redirect URL with a
code. - Your server exchanges the code at the token URL.
- The auth service returns an access token and a refresh token.
- Your server calls the API with the access token.
- Before the access token expires, your server uses the refresh token to get a new one.
1. Send the user to the authorize URL
| Method | GET, opened in the user's browser |
|---|---|
| URL | https://auth.qls.nl/oauth/authorize |
| Parameter | Value | Source |
|---|---|---|
client_id |
The client ID from the API Access screen. | From QLS |
redirect_uri |
The redirect URL of your client, URL-encoded. It must match exactly. | You choose when you create the client |
response_type |
Always code. |
Fixed value |
scope |
*. Clients created on the API Access screen use this default scope. |
Fixed value |
state |
A random value you generate for each request. It comes back unchanged on your redirect. Check it before you continue. | You choose per request |
Raw request
GET /oauth/authorize?client_id=<client_id>&redirect_uri=<redirect_uri>&response_type=code&scope=*&state=<random_state>Host: auth.qls.nl
The user signs in (with 2FA if needed) and sees the consent screen.
2. The user approves access
The consent screen is titled "Access for" followed by your client name. It states that your application is requesting permission to access the user's account. The user selects Approve or Deny. QLS may skip the screen on later requests when the user already approved your client.

The consent screen. Approve sends the user to your redirect URL with an authorization code. Deny sends the user back without one.
3. Receive the code
The auth service redirects the browser to your redirect URL with the code and your state as query parameters.
https://partner.example.com/oauth/callback?code=<authorization_code>&state=<random_state>
Compare state with the value you sent. If it differs, stop and discard the response.
Exchange the code right away
The authorization code is valid for 10 minutes. Exchange it as soon as you receive it.
4. Exchange the code for tokens
| Method | POST, from your server |
|---|---|
| URL | https://auth.qls.nl/oauth/token |
| Headers | Content-Type: application/x-www-form-urlencoded |
| Body | Form fields, as in standard OAuth 2.0 |
| Field | Value | Source |
|---|---|---|
grant_type |
Always authorization_code. |
Fixed value |
client_id |
The client ID from the API Access screen. | From QLS |
client_secret |
The client secret from the API Access screen. | From QLS |
redirect_uri |
The same redirect URI you used in the authorize request. | You choose |
code |
The code from your redirect. | From QLS (per request) |
Raw request
POST /oauth/tokenHost: auth.qls.nlContent-Type: application/x-www-form-urlencodedgrant_type=authorization_code&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&code=<authorization_code>
The same request using curl
curl -X POST "https://auth.qls.nl/oauth/token" \-d "grant_type=authorization_code" \-d "client_id=<client_id>" \-d "client_secret=<client_secret>" \-d "redirect_uri=<redirect_uri>" \-d "code=<authorization_code>"
Response body (standard OAuth 2.0-shape)
{"token_type": "Bearer","expires_in": 900,"access_token": "<access_token>","refresh_token": "<refresh_token>"}
Call the API with Authorization: Bearer <access_token>, as in Option A.
5. Refresh the token
Token lifetimes
In this flow an access token is valid for 15 minutes (expires_in: 900 seconds) and a refresh token for 120 minutes. The authorization code itself is valid for 10 minutes. Read expires_in in the response rather than hard-coding these numbers. Cache the access token and reuse it. Refresh shortly before it expires, not on every API call. If the refresh token has expired too, the user must approve access again.
| Method | POST, from your server |
|---|---|
| URL | https://auth.qls.nl/oauth/token |
| Headers | Content-Type: application/x-www-form-urlencoded |
| Field | Value | Source |
|---|---|---|
grant_type |
Always refresh_token. |
Fixed value |
refresh_token |
The refresh token from the previous token response. | From QLS |
client_id |
The client ID from the API Access screen. | From QLS |
client_secret |
The client secret from the API Access screen. | From QLS |
Raw request
POST /oauth/tokenHost: auth.qls.nlContent-Type: application/x-www-form-urlencodedgrant_type=refresh_token&refresh_token=<refresh_token>&client_id=<client_id>&client_secret=<client_secret>
The response has the same shape as in step 4. When the refresh token has expired as well, send the user through the authorize URL again.
Clients created on the API Access screen are confidential clients that use a client secret. Keep the code exchange and the refresh on your server.
Keep your credentials safe
Never expose secrets or tokens
Never put the client secret, an access token or a refresh token in a URL, in front-end or mobile app code, in a repository, or in a support ticket. Send them only in a request header or body, over HTTPS. Keep them in a secret manager or an environment variable.
Validate state
In Option B, generate a new random state for each authorize request and compare it with the value that comes back on your redirect.
One client per application
Create a separate API client for each application or environment, with a clear name. Then each one has its own client ID and secret.
Troubleshooting / FAQ
| Situation | What to do |
|---|---|
The token request fails with invalid_client, or with a 401 and an empty body |
Check the client ID and secret. Copy them again from the client detail page and remove spaces. Make sure you call the right host and use the right request format for the flow. |
| The authorize step reports a redirect mismatch | Make the redirect_uri identical to the Redirect URL on your client, character for character. A client has one redirect URL. Update the client if your URL changed. |
| The API returns 401 after it worked before | Your access token has expired. For Option A, request a new token. For Option B, use the refresh token, or start the authorization again if that has expired too. |
| The API returns 404 for an organisation | The user who created the client (Option A) or the user who approved access (Option B) has no access to that organisation, or the organisation name in the URL is wrong. |
| The token request gets a 422 or 400 response | Check that every field is present and that grant_type is correct for the endpoint. |
| You are not sure which API you need | Compare the two documentation sites in Before you start. The same token works for the new API at api.qls.nl and the old API at api.pakketdienstqls.nl; the endpoints are in each API's own documentation. |
| You need error responses or rate limits | See the API documentation. |
Next steps
- Read the API documentation. The new API is documented at my.qls.nl/docs/api. The old API is documented at api.pakketdienstqls.nl/redoc.
- Test your first call. Request a token, then call an endpoint from the documentation with the Bearer header. A successful response confirms that your client works.
- Contact QLS support if you get stuck. Mention which API you use, the name of your API client and the time of the failed request. Never send your client secret or an access token.