Who this guide is for
Use this guide if you are a customer or support user setting up token-based authentication for integrations with the Return API or Recover API.
Before you start
A platform user account for the integration.
The username and password for that integration user.
Access to the Return API and/or Recover API features required by the integration.
For Recover API, access to a single project with the
RECOVER_APIfeature.For Return API, access to a single project with the
RETURN_API_V2featureThe correct environment base URLs for the Token gateway, Return API, and Recover API.
Use a dedicated platform user for each integration. Invalidating tokens for a user ends every access token, refresh token, and web session for that user. If multiple integrations share the same user, they can invalidate each other.
How JWT authentication works
The client authenticates with a username and password once to receive two opaque token values:
Access token: used as a Bearer token when calling the Return API or Recover API. It expires after 1 hour.
Refresh token: used to request a new access token and a new refresh token without sending the username and password again. It expires after 30 days.
Authentication flow
Call POST
/jwt/authenticate/v1with the integration user's username and password.Store the returned access token and refresh token securely.
Call the Return API or Recover API with
Authorization: Bearer <access token>.Before the access token expires, call
POST /jwt/refresh/v1with the refresh token.Replace the stored tokens with the new access token and new refresh token from the refresh response.
If tokens may be compromised, or the integration should end its session, call
POST /jwt/invalidate/v1.
Token endpoints
The token endpoints are available through the public Token gateway. Replace {tokenBaseUrl} with the correct base URL for your environment.
Action |
Endpoint | Purpose |
Generate tokens |
POST https://eu-api.rantandrave.com/identity-api/jwt/authenticate/v1 |
Exchange for an access token and refresh token. |
Refresh tokens |
|
Exchange a refresh token for a new access token and a new refresh token. |
Invalidate tokens |
|
Invalidate all tokens and web sessions for the same user. |
Generate tokens
Use this endpoint to exchange the integration user's username and password for an access token and refresh token.
curl -X POST "https://eu-api.rantandrave.com/identity-api/jwt/authenticate/v1" \
-H "Content-Type: application/json" \
-d '{
"username": "your-username",
"password": "your-password"
}'Example response:
{
"token": "AQICAHh...",
"expiresIn": 3600,
"refreshToken": "AQICAHz...",
"refreshExpiresIn": 2592000
}| Field | Description |
|
The access token to send as a Bearer token when calling the Return API or Recover API. |
|
Access token lifetime in seconds. Expected value: |
|
The refresh token to use when requesting new tokens. |
|
Refresh token lifetime in seconds. Expected value: |
Call the Return API or Recover API
Send the access token in the HTTP Authorization header using the Bearer scheme.
Authorization: Bearer <access token>Return API
Use the Return API endpoint provided for your environment. The exact API paths are documented in the Swagger specification.
curl -X GET "https://eu-api.rantandrave.com/return-api/feedback-details" \
-H "Authorization: Bearer <access token>"Recover API
JWT-authenticated Recover API calls use the new Recover API surface, expected under the /recover-api context path. This is separate from the existing /recover Basic Auth surface.
curl -X GET "https://eu-api.rantandrave.com/recover-api/api/rest/task/v1" \
-H "Authorization: Bearer <access token>"Refresh tokens
Use this endpoint when the cached access token is close to expiring. Do not refresh on every API request. A practical approach is to refresh at about 80% of the access token lifetime.
curl -X POST "https://eu-api.rantandrave.com/identity-api/jwt/refresh/v1" \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "AQICAHz..."
}'Example response:
{
"token": "AQICAHh2...",
"expiresIn": 3600,
"refreshToken": "AQICAHy...",
"refreshExpiresIn": 2592000
}Store the new access token and new refresh token from the response. Previously issued refresh tokens remain valid until they expire or the user is invalidated.
Invalidate tokens
Use this endpoint to end the integration user's current token-based session, for example after a suspected credential leak.
curl -X POST "https://eu-api.rantandrave.com/identity-api/jwt/invalidate/v1" \
-H "Content-Type: application/json" \
-d '{
"token": "AQICAHz..."
}'A successful request returns 204 No Content with no response body.
Invalidation applies to the whole user, not only the token sent in the request. It invalidates every access token, refresh token.
HTTP status codes
Generate tokens
| Status | Meaning |
200 |
Access token and refresh token issued. |
400 |
Missing username or password. |
401 |
Wrong password, disabled or locked account, or forced password change pending. |
500 |
Identity, Permissions, or the encryption service is unavailable. |
Refresh tokens
| Status | Meaning |
200 |
New access token and new refresh token issued. |
400 |
Missing refreshToken. |
401 |
Refresh token is invalid, expired, not a refresh token, the account token version has changed, or the account is disabled, locked, or requires a password change. |
500 |
Identity, Permissions, or the encryption service is unavailable. |
Invalidate tokens
| Status | Meaning |
| 204 | Tokens and sessions for the user are invalidated. |
| 400 | Missing token. |
| 401 | Token is invalid, expired, not an access or refresh token, or the account token version has already changed. |
| 500 | Identity or the database is unavailable. |
Security and operational guidance
Store access tokens and refresh tokens securely. Treat both as secrets.
Do not log tokens, include them in URLs, or expose them in error messages.
Use a dedicated platform user per integration.
Keep the integration user's permissions as narrow as possible.
Refresh the access token before expiry rather than waiting for a failed API request.
If a token may be compromised, invalidate it and generate a new token set using the integration user's credentials.
Basic Auth compatibility
Basic Auth remains supported for existing integrations. JWT authentication is an additional option for customers who want token-based authentication.
For Recover API, JWT-authenticated calls use the new /recover-api surface. The existing /recover Basic Auth surface remains separate.
Troubleshooting
| Problem | Possible cause | What to check |
401 when generating tokens |
Incorrect credentials, locked or disabled user, or forced password change pending. | Confirm the integration user's username, password, and account state. |
401 when calling an API |
Access token expired, invalidated, or not sent as a Bearer token. | Refresh the token and confirm the header is exactly Authorization: Bearer <access token>. |
401 when refreshing |
Refresh token expired, invalidated, or not a refresh token. | Generate a new token set using username and password. |
| Recover API request is rejected | User does not have exactly one eligible Recover project or does not have the required RECOVER_API feature. |
Check the integration user's Recover project access and permissions. |
| Second invalidate call fails | The first invalidate call already changed the user's token version. | Treat this as expected behaviour. Do not retry invalidation with the same token. |