To get started with our APIs, contact your Treasure integration team to receive your Client ID and Client Secret keys.
Your Client ID and Client Secret pair will be emailed to you via a single-use secure transfer mechanism. While your Client ID will not change, you can request a new Client Secret from Treasure directly by reaching out to your integration support team. Make sure to keep your credentials somewhere safe, as you may need to access them again.
Once you have your Client ID and Client Secret, you can create your OAuth token, which is used to authenticate all API calls. To receive your OAuth token, make the following call to POST /v1/oauth/token:
{
"client_id": "1234567890",
"client_secret": "1234567890"
}
The response will look something like this:
{
"expires_in": 83725,
"access_token": "eyJhbGciOiJSUzI1NiIsI...",
"token_type": "Bearer"
}
The response returns an access token, its expiration time, and the token type. In our sandbox and production environments this token will be "Bearer," and the token has a TTL (time-to-live) of 24 hours.
Note: the "expires_in" value is in seconds, so 24 hours would be a value of 86400.
The access_token value should be used as part of your Authorization header for all subsequent API requests. For example, a call to list all businesses would look like the following:
curl --request GET \
--url https://sandbox.treasurefinancial.com/v1/businesses \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsI...'
As a best practice, you should plan to call the OAuth Token API in the following cases:
- Your server does not have an access token cached and available for use.
- You receive a 401 Http Status code for an API request.
- The expiration time for your OAuth token has elapsed or is nearing expiration.