API Tokens
Create an API token
Make a data app API token for your backend to create guest tokens with.
POST
curl --request POST https://api.usedatabrain.com/api/v2/data-app/api-tokens \ --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "dataAppName": "Customer portal", "name": "Production backend" }'Before you start
- You have a service token. See Authentication.
- Your plan includes embedding.
ServiceTokenheader
AuthorizationBearer <token>A service token. A data app API token is refused.
Body
The data app.
A label for the token. Unique in your organization, in any letter case.
Response
{ "key": "3f9a1c2e-8b7d-4e6f-9a0b-1c2d3e4f5a6b", "keyId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f", "keyLast4": "5a6b"}| Field | Description |
|---|---|
key | The API token. You see it only in this response |
keyId | The public id of the token. It is not a credential |
keyLast4 | The last 4 characters of the token |
Store key now. Databrain keeps only a hash of it, so no screen or API can show it again. If you lose it, rotate the token in Data Apps > API tokens with Rotate token, or create a new one.
The token has the Access Metrics and Access Dashboards scopes and does not expire.
Errors
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | A field is missing or unknown |
| 400 | DATA_APP_NOT_FOUND | No data app has this name |
| 400 | API_TOKEN_NAME_ALREADY_EXISTS | An API key with this name already exists. Use a different name. |
| 403 | AUTHENTICATION_ERROR | You used a data app API token |
| 403 | entitlement_required | Your plan does not include embedding |
For errors that every endpoint returns, see Authentication.
Next, create a guest token with it.
curl -X POST 'https://api.usedatabrain.com/api/v2/data-app/api-tokens' \ -H 'Content-Type: application/json' \ -d '{ "dataAppName": "Customer portal", "name": "Production backend"}'Example Response
{ "key": "3f9a1c2e-8b7d-4e6f-9a0b-1c2d3e4f5a6b", "keyId": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f", "keyLast4": "5a6b"}