Skip to content

Authentication

All API access begins with authentication. You exchange your credentials for a time-limited access token, which is then used for every subsequent request.

  • Only requests from pre-approved IP addresses are allowed (production)
  • Send Authorization: Bearer <access_token> on all authenticated API calls
  • Pass X-REQUEST-ID (unique UUID) on every request for cross-system tracing
Environment Base URL
Staging https://api.staging.rewardos.in
Production https://api.rewardos.in

POST /v1/partners/auth/login

Exchange your credentials for an access token. This endpoint does not require authentication.

{
"clientId": "string",
"clientSecret": "string"
}

Status 200 — Login successful:

{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresInSecs": 3600
}
Status Meaning Common Cause
401 Unauthorized Wrong clientId/clientSecret, or staging keys on production
400 Bad Request Missing fields in request body
403 Forbidden Request from a non-whitelisted IP
Terminal window
curl -X POST "https://api.staging.rewardos.in/v1/partners/auth/login" \
-H "Content-Type: application/json" \
-d '{
"clientId": "YOUR_STAGING_CLIENT_ID",
"clientSecret": "YOUR_STAGING_CLIENT_SECRET"
}'

The access token expires after expiresInSecs (typically 3600s / 1 hour).

Do not call Login before every request. Store the token and reuse it within the validity window.

let cachedToken = null;
let tokenExpiry = null;
async function getToken() {
const now = Date.now();
if (cachedToken && tokenExpiry && now < tokenExpiry - 300000) {
return cachedToken;
}
const response = await fetch(`${process.env.REWARDOS_BASE_URL}/v1/partners/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
clientId: process.env.REWARDOS_CLIENT_ID,
clientSecret: process.env.REWARDOS_CLIENT_SECRET,
}),
});
const data = await response.json();
cachedToken = data.token;
tokenExpiry = now + data.expiresInSecs * 1000;
return cachedToken;
}

Refresh at ~80% of expiry (e.g. after 48 minutes for a 60-minute token).

If you receive a 401 during a request, re-authenticate and retry the failed request automatically.

Every API call after authentication must include:

Header Value Description
Authorization Bearer <access_token> JWT from Login
X-REQUEST-ID Unique UUID per request Required for support and tracing
Content-Type application/json Required for POST bodies
Terminal window
curl -X GET \
https://api.staging.rewardos.in/v1/partners/products \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'X-REQUEST-ID: a-unique-uuid-here'
  • Store clientId and clientSecret securely
  • Implement token acquisition via /v1/partners/auth/login
  • Implement refresh based on expiresInSecs
  • Include Authorization: Bearer {token} on all API calls
  • Generate and log unique X-REQUEST-ID for every request
  • Keep base URLs configurable per environment
  • Handle 401 by re-authenticating automatically
  1. Explore the brand catalog
  2. Place your first order