Skip to Content

Workspace APIs

Create a dashboard from tiles

Make a dashboard in a workspace from a JSON list of chart tiles in one call.

POST
/api/v2/workspace/dashboard

You describe the dashboard as a tile list. Databrain makes the dashboard and one metric per tile, and checks every tile.

curl --request POST "https://api.usedatabrain.com/api/v2/workspace/dashboard?workspaceName=Customer%20analytics" \  --header "Authorization: Bearer $DATABRAIN_SERVICE_TOKEN" \  --header "Content-Type: application/json" \  --header "Idempotency-Key: 6c1f0b7e-2d3a-4e5f-8a9b-0c1d2e3f4a5b" \  --data '{    "schemaVersion": 1,    "title": "Sales overview",    "layout": { "columns": 24 },    "tiles": [      {        "id": "revenue-by-month",        "kind": "databrain-chart",        "title": "Revenue by month",        "position": { "x": 0, "y": 0, "w": 12, "h": 8 },        "chart": { "type": "line", "metricRef": "<metric id>" }      }    ]  }'

Auth

A service token only. See Authentication.

Authorization

ServiceToken
headerAuthorizationBearer <token>

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

Query and headers

workspaceNamestringrequired

The workspace, up to 200 characters.

Idempotency-Keystringheader

A UUID v4. A retry with the same key and body returns the first answer, with the header Idempotency-Replay: true. Databrain keeps the answer for 24 hours, also a 422 or 500 answer. After a 500, read the dashboards to see if the dashboard was made, then retry with a new key.

Body

The body follows the tile-list schema https://schemas.usedatabrain.com/agent/tile-list/v1.json. Unknown fields are refused, except inside chart.

schemaVersionintegerrequired

1

titlestringrequired

Dashboard name, 1 to 200 characters.

Up to 2,000 characters.

layoutobject

The grid. columns is the grid width, an integer.

1 field in layout
columnsinteger

12 or 24. Default 24

tilesobject[]required

1 to 50 tiles.

5 fields in tiles
idstringrequired

Your id for the tile: lower-case letters, numbers and -, up to 63 characters. Unique in the body.

kindstringrequired

databrain-chart

titlestringrequired

Tile title, 1 to 200 characters.

positionobjectrequired

x 0 to 23, y from 0, w 1 to 24, h 1 to 40. x + w must not be more than layout.columns. Tiles must not overlap.

chartobject

A tile without chart fails with 422. Give a metricRef, or a query and a companyIntegrationId.

5 fields in chart
typestringrequired

A Databrain chart type, for example line, bar, pie, table or single value. Or custom:<key> for a published custom chart.

metricRefstring

A live metric of this workspace, as its metricId or UUID. Or the id of another tile in this body. Databrain makes a new metric for the tile from it. Metrics that a customer made are not found.

querystring

SQL for a new metric: one read-only SELECT. Send it with companyIntegrationId. Databrain runs it on a few rows to check it. With a metricRef, it must be the same as the metric's query.

Required with query. The UUID of the datasource that runs the query. With a metricRef, it must be the metric's datasource.

Chart settings.

Response

The status is 201.

{  "dashboardId": "4e5f6a7b-8c9d-4e0f-a1b2-c3d4e5f6a7b8",  "workspaceId": "9a7c1e2b-3d4f-4a5b-8c6d-7e8f9a0b1c2d",  "slugMap": { "revenue-by-month": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e" },  "tileVerdicts": [{ "id": "revenue-by-month", "ok": true, "problems": [] }]}

slugMap gives the metric id made for each tile id.

Errors

Errors on this endpoint have only a message: { "error": { "message": "..." } }. The 403 also has code AUTHENTICATION_ERROR.

StatusWhy
400workspaceName is missing, sent twice or over 200 characters, Idempotency-Key is not a UUID v4, there is no body, or the body does not match the schema outside tiles
403You used a data app API token
404Workspace not found.
409The Idempotency-Key was used with a different body, or the first request is still running
422A tile is not valid. This includes a schema error inside tiles. The body has tileVerdicts with each tile's problems. Nothing was made
500Dashboard creation failed. This is also the answer when the trial has ended
503Idempotency storage is unavailable. Retry with the same key. or Could not save the retry response. Retry with the same key.

For errors that every endpoint returns, see Authentication.

Next, read the dashboard back.

Example Request
curl -X POST 'https://api.usedatabrain.com/api/v2/workspace/dashboard?workspaceName=string' \  -H 'Content-Type: application/json' \  -d '{  "schemaVersion": 1,  "title": "Sales overview",  "layout": {    "columns": 24  },  "tiles": [    {      "id": "revenue-by-month",      "kind": "databrain-chart",      "title": "Revenue by month",      "position": {        "x": 0,        "y": 0,        "w": 12,        "h": 8      },      "chart": {        "type": "line",        "metricRef": "<metric id>"      }    }  ]}'
Example Response
{  "dashboardId": "4e5f6a7b-8c9d-4e0f-a1b2-c3d4e5f6a7b8",  "workspaceId": "9a7c1e2b-3d4f-4a5b-8c6d-7e8f9a0b1c2d",  "slugMap": {    "revenue-by-month": "b3c4d5e6-f7a8-4b9c-8d0e-1f2a3b4c5d6e"  },  "tileVerdicts": [    {      "id": "revenue-by-month",      "ok": true,      "problems": []    }  ]}