Rate Limiting
Understand and handle API rate limits in the stemp API.
Rate Limiting
The stemp API enforces rate limits to ensure fair usage and platform stability. This page explains how rate limiting works and how to handle it in your integration.
How It Works
Rate limits are applied per IP address. All requests from the same IP address share one limit, regardless of the token they use. When you exceed the limit, the API returns a 429 Too Many Requests response.
There are three tiers:
| Tier | Requests per minute | Applies to |
|---|---|---|
| Strict | 10 | Login, registration, password reset, and the token endpoints, including token refresh for apps (/oauth2/token, /v1/apps/oauth2/token, /v1/apps/oauth2/refresh) |
| Moderate | 60 | OAuth authorization and consent, session refresh (/v1/auth/refresh), invitations, page registrations, and the app and OAuth client endpoints of the Developer Portal (/v1/_dev/apps/, /v1/_dev/oauth-clients/) |
| General | 600 | All other endpoints |
These limits may change. The X-RateLimit-Limit header always shows the limit for the current request.
Response Headers
Rate-limited responses include:
| Header | Description |
|---|---|
X-RateLimit-Limit | Requests allowed per minute in this tier |
X-RateLimit-Remaining | Requests remaining |
Retry-After | Seconds to wait before retrying (only on 429) |
The limit refills continuously rather than resetting at a fixed time.
Example 429 Response
HTTP/1.1 429 Too Many Requests
Retry-After: 7
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 0
Content-Type: application/json
{
"error": "too_many_requests",
"message": "Rate limit exceeded. Try again in 7s."
}Handling Rate Limits
Exponential Backoff
The recommended approach is exponential backoff with jitter:
async function withRateLimit<T>(
fn: () => Promise<Response>,
maxRetries = 5
): Promise<T> {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fn()
if (response.ok) {
return response.json()
}
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') || '5')
const jitter = Math.random() * 1000
await new Promise(r => setTimeout(r, retryAfter * 1000 + jitter))
continue
}
throw new Error(`API error: ${response.status}`)
}
throw new Error('Max retries exceeded')
}Proactive Rate Limit Monitoring
Check the remaining quota before making requests:
function checkRateLimit(response: Response) {
const remaining = parseInt(response.headers.get('X-RateLimit-Remaining') || '0')
const limit = parseInt(response.headers.get('X-RateLimit-Limit') || '0')
if (remaining < 10) {
console.warn(`Rate limit low: ${remaining} of ${limit} per minute left. Slow down.`)
}
}Best Practices
- Respect
Retry-After— Always wait the specified duration before retrying. - Use exponential backoff — Don't hammer the API with immediate retries.
- Add jitter — Randomize retry delays to avoid thundering herd effects.
- Cache responses — Cache read-heavy data like user profiles and pass states.
- Batch where possible — Combine multiple operations where the API supports it.
- Monitor your usage — Track
X-RateLimit-Remainingto detect issues before hitting limits. - Use webhooks — Instead of polling for changes, subscribe to webhook events to receive real-time notifications.
Common Scenarios
| Scenario | Recommendation |
|---|---|
| Importing many users | Stay below 10 requests/second (600 per minute is the general limit) and monitor remaining quota |
| Real-time POS scanning | Rate limits are generous for normal usage; no special handling needed |
| Polling for updates | Switch to webhooks — they're more efficient and real-time |
| Batch stamp operations | Space requests over time rather than sending them all at once |