client_id and client_secret for a short-lived access_token, then send that token as a Bearer credential on each request.
Obtain an Access Token
CallPOST /api/v1/oauth2/token with the client_credentials grant. You receive both an access_token (for API calls) and a refresh_token (to renew it without re-sending your secret).
Response
| Field | Description |
|---|---|
access_token | The token you send on every API request. Valid for ~15 minutes. |
refresh_token | Used to obtain a new access_token without re-sending your client_secret. Valid for 24 hours. |
token_type | Always Bearer. |
expires_in | Lifetime of the access_token in seconds (900 = 15 minutes). |
Authenticate Requests
Send the access token in theAuthorization header on every Payment API call:
401 (with code NO_TOKEN or INVALID_TOKEN). Branch on the 401 status rather than the code. See Errors for the full error envelope.
Refresh Before Expiry
Access tokens are intentionally short-lived. Rather than calling/oauth2/token for every request, cache the token and refresh it before it expires using the refresh_token.
access_token and expires_in. It does not return a new refresh_token: reuse your existing one until it expires.
Token Lifecycle
| Token | Validity | Renewed by |
|---|---|---|
access_token | ~15 minutes | POST /api/v1/oauth2/refresh |
refresh_token | 24 hours | POST /api/v1/oauth2/token (with client_id + client_secret) |
refresh_token itself expires (after 24 hours), authenticate again from scratch using your client_id and client_secret.
Best Practices
Keep credentials server-side
Keep credentials server-side
Store
client_id and client_secret in environment variables or a secrets manager (Google Secret Manager, HashiCorp Vault, etc.). Never ship them to a browser, mobile binary, or public repository.Cache and reuse the access token
Cache and reuse the access token
Hold the
access_token in memory across requests for its full lifetime instead of minting a new one each time. Track expires_in and refresh proactively.Handle 401 gracefully
Handle 401 gracefully
If a request returns
401, refresh the token once and retry. If the refresh also fails, fall back to a full client_credentials exchange.Next Steps
Issue a Token
Try the OAuth flow in the interactive playground
Idempotency
Make create calls safe to retry
Errors
Error envelope, status codes, and handling
API Reference
Base URLs, response format, and conventions