client_credentials grant type for server-to-server communication. Your backend exchanges a client ID and secret for a short-lived access token.
Get your credentials
Your client ID and secret are provided by Tesouro during onboarding. To request access, have your designated team lead submit an access request.Store your client secret securely. It is not recoverable after creation — if lost, you must
submit a new access request to have
a new one issued.
Generate an access token
Call the token endpoint with your credentials:Request
Response
Use the token
Include the token in theAuthorization header of subsequent API requests:
Tokens expire after the duration specified in
expires_in (in seconds). Your application should
handle token refresh by requesting a new token before the current one expires.For production, use
https://api.tesouro.com instead of https://api.sandbox.tesouro.com
with your production credentials.Handle token expiration
An app token expires after the duration specified inexpires_in (in seconds). If you make a request with an expired token, Tesouro responds with a 400 Bad Request error:
Revoke a token
Tokens expire automatically based onexpires_in, but you can also revoke one explicitly — for example, when a user logs out of your application.
Call POST /auth/revoke with your credentials and the token to revoke:
Request
Response