Skip to Content

Metric APIs

Publish or unpublish a metric

Show or hide a customer-made metric on an embedded dashboard.

PUT
/api/v2/data-app/metrics/publish
curl --request PUT https://api.usedatabrain.com/api/v2/data-app/metrics/publish \  --header "Authorization: Bearer $DATABRAIN_API_TOKEN" \  --header "Content-Type: application/json" \  --data '{ "embedId": "sales-overview", "metricId": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e", "isPublished": true }'

Auth

A data app API token. A service token gets 400 INVALID_DATA_APP_API_KEY. See Authentication.

Authorization

DataAppApiToken
headerAuthorizationBearer <token>

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

Body

embedIdstringrequired

The embed id of a dashboard embed of the data app.

metricIdstringrequired

The metric id, from Fetch metrics by embed

isPublishedbooleanrequired

true to publish, false to unpublish.

The flag is on the metric itself, so it changes on every dashboard that shows the metric. Databrain saves a revision of the metric.

Response

{ "id": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e" }

id is the metric id.

Errors

Statuserror.codeWhy
400INVALID_REQUEST_BODYA field is missing
400INVALID_DATA_APP_API_KEYYou used a service token
500INVALID_METRIC_IDInvalid metric id or embed id: the metric is not on that embed
500INTERNAL_SERVER_ERRORThe update failed

For errors that every endpoint returns, see Authentication.

Example Request
curl -X PUT 'https://api.usedatabrain.com/api/v2/data-app/metrics/publish' \  -H 'Content-Type: application/json' \  -d '{  "embedId": "sales-overview",  "metricId": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e",  "isPublished": true}'
Example Response
{  "id": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e"}