Token generation is limited to 10 requests per hour per credential pair (publicKey + secretKey). If you exceed this limit, the API returns 429 Too Many Requests with the error code auth_rate_limit_exceeded.
Do not generate a new token on every API call. Cache the token and reuse it for its full 1-hour lifetime. Excessive token generation will trigger the rate limit and block your integration.
Implement token caching to avoid unnecessary requests and stay well within the rate limit:
Copy
1. Check if savedToken exists2. If yes check if (expiresAt - 5 minutes) > now3. If still valid reuse savedToken no API call needed4. If expired or not found call POST /v1/auth/token5. Save new token + calculated expiresAt use it
Treat the token as expired 25 minutes before its actual expiry (expiresIn - 300 seconds). This protects against clock skew between your server and Safefy’s servers.