Self-Hosted APIs
Rotate a token as a signed-in user
Replace a service token or data app API token by its keyId, also when you lost the token.
This is the API behind Rotate token in the app. You need a user's access token and the token's keyId, not the token itself.
curl --request POST https://databrain-api.example.com/api/v2/service-token/rotate-from-app \ --header "Authorization: Bearer $ADMIN_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "tokenId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f", "expireAt": 3600 }'Auth
Authorization: Bearer <accessToken>, a user's access token, for example from Create an admin JWT on self-hosted. The user needs permission to create API tokens.
AdminJwtAuthorizationBearer <JWT>Self-hosted only: the admin JWT from Create admin JWT.
Body
The keyId of the service token or data app API token, from the create response or List API tokens
How many seconds the old token keeps working. 0 stops it at once.
A token that is already being replaced can be rotated again. Its end time never moves later.
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.
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | A field is missing, or tokenId is not a UUID. The message calls it "token" |
| 401 | UNAUTHORIZED | No access token was sent |
| 403 | FORBIDDEN | You do not have permission to rotate tokens. |
| 404 | TOKEN_NOT_FOUND | No token of your organization has this keyId |
| 500 | INTERNAL_SERVER_ERROR | The rotation failed |
curl -X POST 'https://api.usedatabrain.com/api/v2/service-token/rotate-from-app' \ -H 'Content-Type: application/json' \ -d '{ "tokenId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f", "expireAt": 3600}'{ "key": "7d2e4f6a-1b3c-4d5e-8f9a-0b1c2d3e4f5a", "keyId": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a8b", "keyLast4": "4f5a"}