# Build a dashboard

Lay out the canned metric widgets you want at a glance, read the live figures, and rename or re-lay it as your questions change.

Insights · a play in 3 steps.

## The steps

1. Lay out the widgets. — [createDashboard](/reference/dashboard/createDashboard/)
2. Read the live figures — each tile answers honestly or not at all. — [dashboardMetrics](/reference/reading-your-records/dashboardMetrics/)
3. Rename it or replace the layout. — [updateDashboard](/reference/dashboard/updateDashboard/)

## The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

### createDashboard

[createDashboard](/reference/dashboard/createDashboard/) — mutation · Create a dashboard — an ordered layout of canned metric widgets.

**Example request**

```graphql
mutation ExampleCreateDashboard($input: NewDashboardInput!) {
  createDashboard(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "widgets": [
      {
        "metricKey": "sales_today",
        "ordinal": 1
      }
    ]
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "createDashboard": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "DA-EXMP-0000-000F",
      "type": "Dashboard",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### dashboardMetrics

[dashboardMetrics](/reference/reading-your-records/dashboardMetrics/) — query · One dashboard’s widgets answered with live figures — counts and per-currency totals computed at read time, each stamped with when it was read.

**Example request**

```graphql
query ExampleDashboardMetrics($id: ID!) {
  dashboardMetrics(id: $id) {
    dashboardId
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000"
}
```

**Example response**

```json
{
  "data": {
    "dashboardMetrics": {
      "dashboardId": "01900000-0000-7000-8000-71d51a360000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### updateDashboard

[updateDashboard](/reference/dashboard/updateDashboard/) — mutation · Rename a dashboard or replace its widget layout wholesale.

**Example request**

```graphql
mutation ExampleUpdateDashboard($id: ID!, $revision: ID!, $input: EditDashboardInput!) {
  updateDashboard(id: $id, revision: $revision, input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "input": {
    "caption": "Blue jeans"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "updateDashboard": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "DA-EXMP-0000-000F",
      "type": "Dashboard",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```
