Access Token Retrieval
Note: To execute API requests, you must pass the accessToken in the Authorization header. To obtain an access token, use the tokens.make method. To begin, you need to provide data from your personal account: email, password, and appId. After making the request, you will receive tokens: accessToken and refreshToken:
accessTokenis required to execute API requests and is valid for 24 hours.accessTokenEndTimeis the time (Unix timestamp) when theaccessTokenexpires.refreshTokenis required to obtain a new pair of tokens (extend access) and is valid for 14 days.refreshTokenEndTimeis the time (Unix timestamp) when therefreshTokenexpires.
The received tokens must be stored on the application side in order to continue making API requests and extending access.
Extending access
To extend access and obtain a new pair of tokens, use the tokens.refresh method.
The tokens received through this process must also be stored on the application side to allow repeated API requests and further access extension.
Recommendations for access token renewal
We have encountered cases where application developers, “just in case”, obtain an access token before every API request using the tokens.make call. This is an incorrect scenario that creates unnecessary load. The same applies to scenarios with automatic token renewal every hour or every day — this is unnecessary.
If you store the above-mentioned token pair on the application side, you simply need to make an API request using the saved accessToken (for example, in cases where you saved the accessToken but did not save its expiration date and time). If the token is no longer valid, you will receive an appropriate error response:
{
"success": false,
"error": {
"code": "ApiInvalidTokenError",
"message": "Invalid Token"
}
}
This is where you need to call tokens.refresh, using the previously saved refreshToken, to obtain a new pair of tokens. This new pair must be stored on the application side, after which you should repeat your API request using the new accessToken.
Limitations on obtaining access tokens
It is important to remember that obtaining new tokens via the tokens.make method is limited. For email-appId, the number of tokens is restricted to 100 tokens per day.