Create a chart

Creates a new chart on a specific dashboard.

POST https://telemetry.betterstack.com/api/v2/dashboards/{dashboard_id}/charts

URL parameters

dashboard_id
required integer

Headers

Authorization
required string

Body parameters

chart_type
required string
queries
required array
name
string
description
string
x
integer
y
integer
w
6 integer
h
4 integer
settings
object
201

Response body

{
  "data": {
    "id": "568",
    "type": "chart",
    "attributes": {
      "chart_type": "line_chart",
      "name": "New API Chart",
      "x": 0,
      "y": 4,
      "w": 6,
      "h": 4,
      "queries": [...]
    }
  }
}

Queries

Each object in the queries array defines a data source for the chart.

  • query_type - The type of query. Choose one of:
    • sql_expression for querying using SQL.
    • tail_query for log filtering, similar to Live tail.
    • static_text for static markdown text.
  • sql_query - The SQL query string. Required for sql_expression.
  • where_condition - The filter query for tail_query.
  • static_text - The markdown content for static_text_chart.
  • source_variable - The name of the source type variable to use. Defaults to source.

Read-only query types (query_builder, pql_expression, and funnel_query) cannot be created or modified via the API as they require client-side compilation to SQL.

If the created chart's position overlaps with existing charts or sections, the layout will be automatically consolidated after a short delay. The response will include a warnings field in this case.

Example Request

cURL
curl --request POST \
  --url https://telemetry.betterstack.com/api/v2/dashboards/1234/charts \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "chart_type": "line_chart",
    "name": "New API Chart",
    "x": 0,
    "y": 4,
    "queries": [
      {
        "query_type": "sql_expression",
        "sql_query": "SELECT {{time}} as time, count(*) as value FROM {{source}} GROUP BY time"
      }
    ]
  }'