OAuth2 Authentication
This API uses OAuth 2.0 with the Client Credentials flow (machine-to-machine). You first request an access token from the token endpoint and then send it as a Bearer token with every API request.
Currently we are using long-lived tokens, but we plan to migrate to short-lived tokens in the future.
Prerequisites
You will receive credentials from your TK-World Partner Manager:
client_idclient_secret- optionally: scopes (see below)
OAuth2 Flow: Client Credentials
Token Endpoint
According to the OpenAPI specification:
- Token URL (Production):
https://partner.tkw.services/oauth/token - Token URL (Development):
https://partner.tkw-dev.de/oauth/token
Scopes
The specification defines (among others) the following scope:
manage-order– Administrative access
Note: Many endpoints require OAuth2 but no specific scope (
[]). Some order-related endpoints additionally requiremanage-order.
The scope is meant to be used to be able to have separate tokens for different purposes. So you don't need to use the same token for aquisition of orders and for order administration.
Request an Access Token
Client authentication via HTTP Basic
curl -X POST "https://partner.tkw.services/oauth/token" -H "Content-Type: application/x-www-form-urlencoded" -u "<client_id>:<client_secret>" --data-urlencode "grant_type=client_credentials" --data-urlencode "scope=manage-order"
If you do not need a scope, omit the scope parameter:
curl -X POST "https://partner.tkw.services/oauth/token" -H "Content-Type: application/x-www-form-urlencoded" -u "<client_id>:<client_secret>" --data-urlencode "grant_type=client_credentials"
Token Response
The response contains the access token
{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600
}
Key fields:
access_token→ used for API callstoken_type→Bearerexpires_in→ lifetime in seconds
Use the Access Token in API Requests
Authorization header
All API endpoints expect OAuth2 via:
Authorization: Bearer <access_token>
Example (Production base URL)
Servers according to the spec:
- Production:
https://partner.tkw.services/api/v1 - Development:
https://partner.tkw-dev.de/api/v1
Example request:
curl -X GET "https://partner.tkw.services/api/v1/projects" -H "Authorization: Bearer <access_token>"
Endpoints & Required Scopes (per spec)
OAuth2 + manage-order scope required
For order administration per spec:
GET /o/{tkwId}/status→ scope:manage-orderGET /o/{tkwId}/providerStatus→ scope:manage-orderGET /o/list→ scope:manage-order
Common Errors & Troubleshooting
- 401 Unauthorized: token missing, invalid, or expired
- 403 Forbidden: token is valid but scopes/permissions are missing (e.g.,
manage-ordernot included) - invalid_client (token endpoint): wrong
client_id/client_secretor client not allowed - invalid_scope: requested scope is not permitted
Best Practices
- Cache tokens until
expires_inis reached (don’t fetch a new token for every request). - If you get 403, verify the required scope is included.
- Never commit secrets to a repository (use environment variables / secret storage).