Get and use an access token
developers-tokensOn this page
Swap your app's client id and secret for a one-hour bearer token with the OAuth 2.0 client credentials grant, and send it on every call.
The API uses the OAuth 2.0 client credentials grant. Your app swaps its client id and secret for a short-lived bearer token.
Get a token with OAuth client credentials
To get a token, call POST /api/v1/oauth/token with grant_type=client_credentials, sending the client id and secret one of two ways:
| Way | How |
|---|---|
| HTTP Basic (preferred) | Authorization: Basic base64(client_id:client_secret) |
| In the body | client_id and client_secret fields (form or JSON) |
Sending both is invalid_request (400). Any other grant_type is unsupported_grant_type (400). Every credential problem is the same invalid_client (401). These answers use the OAuth format, { "error": "invalid_client" }, not the usual error envelope.
A successful answer has access_token, token_type (Bearer), expires_in (seconds) and scope (the app's scopes, separated by spaces).
Use the access token
Send the token in the Authorization header of each call:
Authorization: Bearer <access_token>
A token:
- lasts 1 hour (
expires_in: 3600) and carries the app's scopes as they were when it was issued - belongs to one business, so there's no business header or parameter to send
- stops working at once if the app is suspended or revoked, or a scope is removed from it
Cache the token and reuse it until shortly before it expires. Ask for a new one then, or when a call answers 401 unauthenticated. Token requests are rate limited, so fetching one per call will get you throttled.