Self-Hosted APIs
Rotate a service token
Get a new service token and keep the old one working while you switch over.
You call it with the service token you want to replace. Works on cloud and self-hosted.
curl --request POST https://api.usedatabrain.com/api/v2/service-token/rotate \ --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "expireAt": 86400 }'Auth
The service token to rotate. A data app API token gets 400; use Rotate an API token for those. See Authentication.
If you lost the token, rotate it as a signed-in user: select Rotate token in Settings > Developers > Tokens, or call Rotate a token as a signed-in user.
ApiTokenAuthorizationBearer <token>A service token or a data app API token.
Body
How many seconds the old token keeps working. 0 stops it at once. Not a date.
Response
{ "key": "7d2e4f6a-1b3c-4d5e-8f9a-0b1c2d3e4f5a", "keyId": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a8b", "keyLast4": "4f5a"}key is the new token. You see it only in this response. It has the old token's name and scopes, and no expiry. The old token is renamed <name> (replaced <date> UTC).
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | expireAt is missing |
| 400 | AUTHENTICATION_ERROR | Invalid Service Token: you used a data app API token |
| 400 | EXPIRED_SERVICE_TOKEN | This token is already being replaced, so it cannot rotate itself. Use the new token, or rotate in Settings > Developers > Tokens |
| 400 | API_TOKEN_NAME_ALREADY_EXISTS | Another key already has the name the new token would get. Rename or delete it |
| 400 | INVALID_SERVICE_TOKEN | The token was not found |
| 500 | INTERNAL_SERVER_ERROR | The rotation failed. The old token still works |
For errors that every endpoint returns, see Authentication.
curl -X POST 'https://api.usedatabrain.com/api/v2/service-token/rotate' \ -H 'Content-Type: application/json' \ -d '{ "expireAt": 86400}'{ "key": "7d2e4f6a-1b3c-4d5e-8f9a-0b1c2d3e4f5a", "keyId": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a8b", "keyLast4": "4f5a"}