Skip to main content
The JTL platform uses different authentication mechanisms across its APIs. This page explains how each one works, when to use it, and how tokens are managed.

Authentication at a Glance

Two Types of Tokens (Cloud)

Cloud Apps use two tokens, each answering a different question. The app token identifies the merchant. The access token authorizes your app. An app with a backend uses both: it verifies the app token to learn which tenant a request belongs to, then calls the API with its access token. An app without a backend calls the API with the app token directly.
See App Token Authentication for verification and tenant mapping, and Service Account Authentication for the client credentials implementation.

Cloud Authentication (OAuth 2.0)

The Cloud API uses the OAuth 2.0 Client Credentials Flow. Your app’s backend authenticates with a client ID and secret, receives a short-lived JWT, and uses that JWT as a Bearer token for all API requests.

Prerequisites

Your app must be registered in the Partner Portal. Registration creates an OAuth client with a Client ID and Client Secret.
Your Client Secret is displayed only once immediately after registration. Store it securely.

How the Flow Works

  1. Your backend sends its client credentials to the JTL Identity Provider
  2. The Identity Provider returns a short-lived JWT access token
  3. Your backend includes that token (along with the tenant ID) in every API request

Token Endpoint

Request:Example request:
cURL
Response:
For a full implementation including caching and retry, see Service Account Authentication.

Making Authenticated API Requests

Once you have an access token, include it in every API request along with the tenant ID.Base URL:
Required headers:Example request:
The tenant ID comes from the urn:jtl:tenant_id claim of a verified app token. See App Token Authentication.

Token Lifecycle

Access tokens last approximately 1 hour. Your app needs to handle expiry:
  • Cache the token and reuse it until it is close to expiry
  • Request a new one before the current token expires, rather than waiting for a failure
  • Handle 401 Unauthorized by requesting a new token once and retrying

Security Schemes

Cloud endpoints are secured using one of two schemes:

JTL Cloud vs. OnPremise Comparison


Best Practices

These practices apply regardless of which auth mechanism you’re using: Credential storage
  • Never hardcode credentials in source code. Use environment variables or a secrets manager.
  • Never commit .env files to version control.
  • Rotate credentials if you suspect they’ve been compromised.
Token management
  • Cache tokens and reuse them. Don’t request a new token for every API call.
  • Refresh proactively before expiry, not after receiving a 401 error.
  • On a 401 response, refresh the token and retry the request once.
Security
  • Always use HTTPS for Cloud API calls.
  • Verify app tokens server-side. Never trust a token received from the client without checking its signature and audience.
  • Request the minimum required scopes. Don’t request broader access than your app needs.

What’s Next?

API Keys & Tokens

Deeper dive into JWT structure, app tokens, and token management patterns.

App Token Authentication

Verify the app token in your backend and read the tenant from its claims.

Error Handling

How to handle auth errors, expired tokens, and common failure modes.