Why tokens expire
Theid_token returned by /auth and /get-card expires after approximately 1 hour (3600 seconds). After expiry, authenticated endpoints like /get-card-data will return 401 Unauthorized.
The refresh_token is long-lived and can be used to get a new id_token without paying again.
Refreshing a token
CallPOST /auth with grant_type: "refresh_token" and your refresh_token. This follows the standard OAuth2 pattern and is free — no x402 payment required.
The response returns a new
refresh_token as well. Always store the latest refresh_token from each response.Best practices
Proactive refresh
Don’t wait for a401 error. Refresh the token before it expires:
Reactive refresh
Alternatively, catch401 errors and refresh on demand:
Store both tokens
Always persist both theid_token and refresh_token. If you lose the refresh_token, you’ll need to call GET /auth again (which costs $0.001 USDC).
Error responses
| Status | Meaning |
|---|---|
200 | Success — new tokens returned |
400 | Invalid or missing grant_type or refresh_token in request body |
401 | Token is invalid or revoked — must re-authenticate via /auth |