Authentication (OAuth 2.0)

Oscar API documentation is publicly readable, but executing API calls requires integration-specific credentials. The setup uses OAuth 2.0 client_credentials together with an API key.

What this means in practice

  • Business view: the credentials give access to all published v2 APIs.
  • Integrator view: each integration has its own credential pair.
  • Security view: requests require both an access token and an x-api-key.

What you need before implementation

  • Client ID
  • Client Secret
  • x-api-key
  • Environment-specific endpoints (Sandbox / Production)

OAuth 2.0 in short

  1. Your integration requests a token from the OAuth service using Client ID + Client Secret.
  2. The OAuth service returns an access token.
  3. Your integration calls Oscar API with Authorization: Bearer <token>.
  4. The request also includes x-api-key.

Technical implementation

1) Request an access token

First build BASE64(client_id:client_secret):

BASIC_TOKEN="<BASE64_ENCODED_CLIENT_ID_COLON_CLIENT_SECRET>"

Then call the token endpoint using the Authorization: Basic header:

curl -X POST "${OAUTH_TOKEN_ENDPOINT}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: Basic ${BASIC_TOKEN}" \
  -d "grant_type=client_credentials"

Example response:

{"access_token":"*********","expires_in":3600,"token_type":"Bearer"}

Use the access_token value from the response as the Authorization: Bearer token in your API call.

Token lifetime and fetch limit

  • Token validity is 3600 seconds (1 hour).
  • With the same clientId, a token can be fetched at most 4 times per hour.
  • Implement token caching so the token is reused for its full validity window.
  • Fetch a new token only after the current token has expired (or is about to expire).

2) Call an API endpoint with token + API key

Example: get changed sales orders from the test environment.

curl -X POST "https://testapi.oscar.fi/sales/sales-orders/changes/query" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -H "x-api-key: <YOUR_X_API_KEY>" \
  -d '{"changedFrom":"2026-11-01T00:00:00Z","pageSize":1}'

The whole flow from token to first search: Quickstart.

Postman

Download the Oscar API v2 collection and import it into Postman: Download the Oscar API v2 collection

  1. Fill the collection variables oauthTokenEndpoint, clientId, clientSecret and apiKey with the provided values.
  2. Open the collection's Authorization tab and select Get New Access Token.
  3. Use the fetched token and send the requests.

The calls in the collection are described on the Quickstart page.

Common errors and checks

  • 401 Unauthorized: token missing, expired, or malformed.
  • 403 Forbidden: the credentials have no access to the resource, or the API key does not match.
  • 429 Too Many Requests: too many token requests with the same clientId (maximum 4 tokens per hour).
  • Wrong environment: Sandbox credentials used against Production (or vice versa).