client_id and client_secret per environment. You receive one| Environment | Token endpoint |
|---|---|
| Sandbox (test) | https://api-test.freightlens.io/oauth/token |
| Production | https://api.freightlens.io/oauth/token |
POST to the token endpoint with grant_type=client_credentials.{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "track-and-trace.read"
}access_token — the bearer token to send on every API request.expires_in — the token's lifetime in seconds. Cache the token and reuse it untilscope — the granted scope. Track & trace read access is track-and-trace.read.Authorization header as a Bearer token.expires_in elapses401 Unauthorized, request a new token once andapi-test.freightlens.io; production credentials only against api.freightlens.io.| Status | Meaning | What to do |
|---|---|---|
400 | Malformed token request (missing/invalid parameters). | Check grant_type, client_id, client_secret, and content type. |
401 | Invalid credentials, or an expired/invalid access token. | Verify the credentials; request a fresh token and retry once. |
403 | Authenticated, but the token lacks the required scope. | Confirm the client is granted track-and-trace.read. |
{
"code": "UNAUTHORIZED",
"message": "The access token is expired or invalid."
}