Authentication and tokens
OAuth 2.0 client_credentials, validating, renewing and revoking tokens.
SAPI+ uses OAuth 2.0 client_credentials. The client obtains access_token using the allocated client_id and client_secret; sends the header for protected calls:
Authorization: Bearer YOUR_ACCESS_TOKEN
Generate Client ID and Client Secret in the web application via Account overview → SAPI+ connections according to the instructions Creating SAPI+ connection. Keep them on the server in secure storage. Do not put the secret key or tokens in the client JavaScript, public repository, or logs.
Call limits can be found in the report rate limits by endpoints.
Endpoint - Token acquisition
Status: Implemented, Deployed: Sandbox
POST /v1/sapi/auth/token
Content-Type: application/json
Request example:
{
"client_id": "client_123",
"client_secret": "secret_value",
"grant_type": "client_credentials",
"scope": "document:send document:receive"
}
Request body:
| Field | Mandatory | Description |
|---|---|---|
client_id | yes | Client identifier assigned in Doklado. |
client_secret | yes | Client secret key. Must be kept safely in KMS. |
grant_type | yes | The value must be client_credentials. |
scope | no | Optional scope of authorizations, e.g. document:send document:receive. |
Successful response: HTTP 200
{
"access_token": "<jwt_access_token>",
"token_type": "Bearer",
"expires_in": 900,
"scope": "document:send document:receive",
"refresh_token": "<refresh_token_if_supported>"
}
Response body:
| Field | Type | Description |
|---|---|---|
access_token | string | JWT token for API calls. |
token_type | string | Always Bearer. |
expires_in | integer | Lifetime of the access token in seconds. |
scope | string | Granted scope if used. |
refresh_token | string | Optional field if the implementation supports token renewal via refresh token. |
Error states:
| HTTP | The reason |
|---|---|
400 | Invalid request, missing field or not supported grant_type. |
401 | Invalid client_id or client_secret. |
403 | The client does not have access or his account is not active. |
423 | Account or client is temporarily blocked. |
Endpoint - Token status check
Status: Implemented, Deployed: Sandbox
GET /v1/sapi/auth/token/status
Authorization: Bearer <access_token>
Successful response: HTTP 200
{
"valid": true,
"expires_in_seconds": 420,
"should_refresh": false,
"refresh_recommended_at": "2026-05-11T12:25:00Z",
"expires_at": "2026-05-11T12:30:00Z"
}
| Field | Type | Description |
|---|---|---|
valid | boolean | Whether the token is currently valid. |
expires_in_seconds | integer | Remaining validity in seconds. |
should_refresh | boolean | true, if it is recommended to refresh the token before the next call. |
refresh_recommended_at | datetime | Recommended token refresh time. |
expires_at | datetime | Exact token expiration time in ISO 8601. |
Recommended use: call the endpoint before sending the document if the client needs to verify that the token will be valid during request preparation.
Token expiration
Determine the validity from expires_in, not from a fixed constant. The example answer above gives 900 seconds (15 minutes). Keep the token with the expiration time.
Token renewal
POST /v1/sapi/auth/renew receives a JSON body with the field refresh_token. Use the value obtained during authentication. The example uses SAPI_BASE_URL including /v1 by first call.
curl --request POST --fail-with-body --silent --show-error \
"$SAPI_BASE_URL/sapi/auth/renew" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
"refresh_token": "YOUR_REFRESH_TOKEN"
}'
The specific format of the answer is not defined in the current documents. If the response contains new tokens and an expiration time, update them in the integration store. If you do not have a usable refresh token, get a new access token via client_credentials.
Token revocation
POST /v1/sapi/auth/revoke accepts the token to revoke and token_type_hint. The following example revokes a refresh token:
curl --request POST --fail-with-body --silent --show-error \
"$SAPI_BASE_URL/sapi/auth/revoke" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
"token": "YOUR_REFRESH_TOKEN",
"token_type_hint": "refresh_token"
}'
For renew and revoke, the examples do not send the Authorization header; the token is part of the JSON body. The format of the response and the exact effects of cancellation on other issued tokens are not defined in the current documents.
If you do not yet have client_id and client_secret, follow the instructions Creating SAPI+ connection.