Metric APIs
Publish or unpublish a metric
Show or hide a customer-made metric on an embedded dashboard.
PUT
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.
DataAppApiTokenheader
AuthorizationBearer <token>A data app API token. A service token is refused.
Body
The embed id of a dashboard embed of the data app.
The metric id, from Fetch metrics by embed
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
| Status | error.code | Why |
|---|---|---|
| 400 | INVALID_REQUEST_BODY | A field is missing |
| 400 | INVALID_DATA_APP_API_KEY | You used a service token |
| 500 | INVALID_METRIC_ID | Invalid metric id or embed id: the metric is not on that embed |
| 500 | INTERNAL_SERVER_ERROR | The update failed |
For errors that every endpoint returns, see Authentication.
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"}