Skip to Content

API Tokens

Create an API token

Make a data app API token for your backend to create guest tokens with.

POST
/api/v2/data-app/api-tokens
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.

Authorization

ServiceToken
headerAuthorizationBearer <token>

A service token. A data app API token is refused.

Body

dataAppNamestringrequired

The data app.

namestringrequired

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"}
FieldDescription
keyThe API token. You see it only in this response
keyIdThe public id of the token. It is not a credential
keyLast4The 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

Statuserror.codeWhy
400INVALID_REQUEST_BODYA field is missing or unknown
400DATA_APP_NOT_FOUNDNo data app has this name
400API_TOKEN_NAME_ALREADY_EXISTSAn API key with this name already exists. Use a different name.
403AUTHENTICATION_ERRORYou used a data app API token
403entitlement_requiredYour plan does not include embedding

For errors that every endpoint returns, see Authentication.

Next, create a guest token with it.

Example Request
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"}