Skip to main content

Dashboards API

Create, manage, and query dashboards and widgets.

List Dashboards

GET /api/v1/dashboards

Request

curl "https://flux.brainzlab.ai/api/v1/dashboards" \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": [
    {
      "id": "dash_abc123",
      "name": "API Monitoring",
      "description": "Real-time API performance",
      "created_at": "2024-01-10T10:00:00Z",
      "updated_at": "2024-01-15T14:30:00Z",
      "widgets_count": 6
    }
  ]
}

Create Dashboard

POST /api/v1/dashboards

Request

curl https://flux.brainzlab.ai/api/v1/dashboards \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sales Dashboard",
    "description": "Revenue and order metrics"
  }'

Parameters

FieldTypeRequiredDescription
namestringYesDashboard name
descriptionstringNoDashboard description

Response

{
  "data": {
    "id": "dash_xyz789",
    "name": "Sales Dashboard",
    "description": "Revenue and order metrics",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Get Dashboard

Get a dashboard with all widgets and current values:
GET /api/v1/dashboards/:id

Request

curl "https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123" \
  -H "Authorization: Bearer sk_live_xxx"

Response

{
  "data": {
    "id": "dash_abc123",
    "name": "API Monitoring",
    "description": "Real-time API performance",
    "widgets": [
      {
        "id": "widget_1",
        "type": "number",
        "title": "Requests/min",
        "position": { "x": 0, "y": 0, "width": 2, "height": 1 },
        "query": {
          "metric": "api.requests",
          "aggregation": "rate"
        },
        "value": 1234
      },
      {
        "id": "widget_2",
        "type": "graph",
        "title": "Response Time (P95)",
        "position": { "x": 2, "y": 0, "width": 4, "height": 2 },
        "query": {
          "metric": "api.response_time",
          "aggregation": "p95"
        },
        "series": [
          { "timestamp": "2024-01-15T10:00:00Z", "value": 125.3 },
          { "timestamp": "2024-01-15T10:05:00Z", "value": 132.1 }
        ]
      }
    ]
  }
}

Update Dashboard

PATCH /api/v1/dashboards/:id

Request

curl -X PATCH https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123 \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Updated Dashboard Name",
    "description": "Updated description"
  }'

Delete Dashboard

DELETE /api/v1/dashboards/:id

Request

curl -X DELETE "https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123" \
  -H "Authorization: Bearer sk_live_xxx"

Widgets

Add Widget

POST /api/v1/dashboards/:dashboard_id/widgets

Request

curl https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123/widgets \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "graph",
    "title": "Request Latency",
    "position": { "x": 0, "y": 0, "width": 4, "height": 2 },
    "query": {
      "metric": "api.response_time",
      "aggregation": "p95",
      "interval": "5m"
    },
    "options": {
      "style": "line",
      "time_range": "24h"
    }
  }'

Widget Parameters

FieldTypeRequiredDescription
typestringYesWidget type
titlestringYesWidget title
positionobjectNoGrid position (x, y, width, height)
queryobjectYesData query configuration
optionsobjectNoType-specific options

Widget Types

number - Single value display:
{
  "type": "number",
  "title": "Active Users",
  "query": {
    "metric": "users.online",
    "aggregation": "last"
  },
  "options": {
    "format": { "suffix": " users" },
    "comparison": { "type": "previous_period" }
  }
}
graph - Time series chart:
{
  "type": "graph",
  "title": "Latency",
  "query": {
    "metric": "response_time",
    "aggregation": "p95",
    "interval": "5m"
  },
  "options": {
    "style": "line",
    "time_range": "24h"
  }
}
bar - Bar chart:
{
  "type": "bar",
  "title": "Requests by Endpoint",
  "query": {
    "metric": "api.requests",
    "aggregation": "sum",
    "group_by": "tags.endpoint"
  },
  "options": {
    "orientation": "horizontal",
    "limit": 10
  }
}
pie - Pie chart:
{
  "type": "pie",
  "title": "Users by Plan",
  "query": {
    "event": "user.active",
    "group_by": "tags.plan"
  },
  "options": {
    "show_legend": true
  }
}
table - Data table:
{
  "type": "table",
  "title": "Top Customers",
  "query": {
    "event": "order.placed",
    "group_by": "user_id",
    "aggregation": "sum",
    "field": "value"
  },
  "options": {
    "columns": ["user_id", "sum", "count"],
    "limit": 20,
    "sort": { "field": "sum", "order": "desc" }
  }
}
heatmap - Activity heatmap:
{
  "type": "heatmap",
  "title": "Request Activity",
  "query": {
    "metric": "api.requests",
    "aggregation": "count"
  },
  "options": {
    "x_axis": "hour_of_day",
    "y_axis": "day_of_week"
  }
}

Response

{
  "data": {
    "id": "widget_xyz",
    "type": "graph",
    "title": "Request Latency",
    "position": { "x": 0, "y": 0, "width": 4, "height": 2 },
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Update Widget

PATCH /api/v1/dashboards/:dashboard_id/widgets/:widget_id

Request

curl -X PATCH https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123/widgets/widget_xyz \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Title",
    "position": { "x": 2, "y": 0, "width": 4, "height": 3 }
  }'

Delete Widget

DELETE /api/v1/dashboards/:dashboard_id/widgets/:widget_id

Request

curl -X DELETE "https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123/widgets/widget_xyz" \
  -H "Authorization: Bearer sk_live_xxx"

Update Layout

Update multiple widget positions at once:
PATCH /api/v1/dashboards/:dashboard_id/layout

Request

curl -X PATCH https://flux.brainzlab.ai/api/v1/dashboards/dash_abc123/layout \
  -H "Authorization: Bearer sk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "widgets": [
      { "id": "widget_1", "x": 0, "y": 0, "width": 3, "height": 2 },
      { "id": "widget_2", "x": 3, "y": 0, "width": 3, "height": 2 },
      { "id": "widget_3", "x": 0, "y": 2, "width": 6, "height": 3 }
    ]
  }'

Errors

CodeDescription
dashboard_not_foundDashboard does not exist
widget_not_foundWidget does not exist
invalid_widget_typeType must be number/graph/bar/pie/table/heatmap
invalid_queryQuery configuration is invalid