Skip to content

Dashboard Widgets

Widgets are configurable dashboard tiles that compute a metric over one of a fixed set of data sources and render it as a number, percentage, chart, table, or a static shortcuts panel. Each widget belongs to a user; a widget can be marked shared to make it visible to the whole organization. Widgets are positioned on a grid (grid_x, grid_y, grid_w, grid_h).

Each data source exposes a fixed set of filterable and group-by fields:

Data sourceFields
messagesstatus, direction, message_type, whatsapp_account
contactswhatsapp_account, is_read
campaignsstatus, message_status
transfersstatus, source
sessionsstatus
  • Metrics: count, sum, avg. (sum/avg require a numeric field; the set of aggregatable fields is restricted server-side.)
  • Display types: number, percentage, chart, table, shortcuts. shortcuts is a static type that needs no data source or metric.
  • Chart types (when display_type is chart): line, bar, pie. Combined with a group_by_field, a line chart renders grouped time-series and bar/pie render grouped totals.

Retrieve the current user's widgets plus any shared widgets in the organization, ordered by display order.

Terminal window
GET /api/widgets
{
"status": "success",
"data": {
"widgets": [
{
"id": "uuid",
"name": "Messages Sent",
"description": "",
"data_source": "messages",
"metric": "count",
"field": "",
"filters": [
{ "field": "direction", "operator": "equals", "value": "outbound" }
],
"display_type": "number",
"chart_type": "",
"group_by_field": "",
"show_change": true,
"color": "#2563eb",
"size": "small",
"display_order": 1,
"grid_x": 0,
"grid_y": 0,
"grid_w": 3,
"grid_h": 3,
"config": {},
"is_shared": false,
"is_default": false,
"is_owner": true,
"created_by": "",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
]
}
}

Retrieve a single widget you own or that is shared with your organization.

Terminal window
GET /api/widgets/{id}

Returns a single widget object (same shape as the list items above).

List the available data sources, metrics, display types, and filter operators for building widgets.

Terminal window
GET /api/widgets/data-sources
{
"status": "success",
"data": {
"data_sources": [
{ "name": "messages", "label": "Messages", "fields": ["status", "direction", "message_type", "whatsapp_account"] },
{ "name": "contacts", "label": "Contacts", "fields": ["whatsapp_account", "is_read"] }
],
"metrics": ["count", "sum", "avg"],
"display_types": ["number", "percentage", "chart", "table", "shortcuts"],
"operators": [
{ "value": "equals", "label": "Equals" },
{ "value": "not_equals", "label": "Not Equals" },
{ "value": "contains", "label": "Contains" },
{ "value": "gt", "label": "Greater Than" },
{ "value": "lt", "label": "Less Than" },
{ "value": "gte", "label": "Greater Than or Equal" },
{ "value": "lte", "label": "Less Than or Equal" }
]
}
}

Create a new widget owned by the current user.

Terminal window
POST /api/widgets
{
"name": "Messages Sent",
"data_source": "messages",
"metric": "count",
"display_type": "number",
"filters": [
{ "field": "direction", "operator": "equals", "value": "outbound" }
],
"show_change": true,
"color": "#2563eb",
"size": "small"
}
FieldTypeRequiredDescription
namestringYesWidget name
data_sourcestringYes*One of messages, contacts, campaigns, transfers, sessions. Not required for the shortcuts display type
metricstringYes*One of count, sum, avg. Not required for the shortcuts display type
display_typestringNoOne of number, percentage, chart, table, shortcuts. Defaults to number
fieldstringNoField to aggregate for sum/avg metrics
filtersarrayNoFilter conditions, each { field, operator, value }
chart_typestringNoline, bar, or pie (for chart display type)
group_by_fieldstringNoField to group by; must be a valid field for the data source
show_changebooleanNoShow period-over-period change. Defaults to true
colorstringNoDisplay color
sizestringNosmall, medium, or large. Defaults to small
configobjectNoFree-form display config
is_sharedbooleanNoShare with the whole organization. Defaults to false
grid_x, grid_y, grid_w, grid_hintegerNoGrid position and size. Sensible defaults are chosen per display type

Returns the created widget object.

Update a widget. Only the owner may update it. Only fields present in the request body are changed (except group_by_field, which is always applied — send an empty string to clear it).

Terminal window
PUT /api/widgets/{id}

Accepts the same fields as Create Widget. All fields are optional.

Returns the updated widget object.

Delete a widget. Only the owner may delete it.

Terminal window
DELETE /api/widgets/{id}
{
"status": "success",
"data": {
"message": "Widget deleted successfully"
}
}

Compute and return the data for a single widget. Defaults to the current month; pass a date range to override.

Terminal window
GET /api/widgets/{id}/data
ParameterTypeDescription
fromstringStart of the period (date)
tostringEnd of the period (date)
{
"status": "success",
"data": {
"widget_id": "uuid",
"value": 1250,
"change": 12.5,
"prev_value": 1111,
"chart_data": [
{ "label": "Jan 01", "value": 40 }
],
"data_points": [],
"grouped_series": null,
"table_rows": []
}
}
FieldTypeDescription
valuenumberThe metric value for the current period
changenumberPercentage change from the previous period
prev_valuenumberThe metric value for the previous period
chart_dataarrayDaily points for a chart widget with no group-by
data_pointsarrayGrouped totals ({ label, value }) for grouped bar/pie or grouped table
grouped_seriesobjectGrouped time-series ({ labels, datasets }) for a grouped line chart
table_rowsarrayLast records for a table widget with no group-by

Compute data for all of the current user's widgets in a single request. Returns a map keyed by widget ID.

Terminal window
GET /api/widgets/data

Same from / to parameters as Get Widget Data.

{
"status": "success",
"data": {
"data": {
"widget-uuid-1": {
"widget_id": "widget-uuid-1",
"value": 1250,
"change": 12.5,
"prev_value": 1111,
"chart_data": [],
"data_points": [],
"grouped_series": null,
"table_rows": []
}
}
}
}

Bulk-save grid positions for widgets in a single transaction. Each entry updates the widget's grid position; the order of the array sets each widget's display order.

Terminal window
POST /api/widgets/layout
{
"layout": [
{ "id": "widget-uuid-1", "grid_x": 0, "grid_y": 0, "grid_w": 3, "grid_h": 3 },
{ "id": "widget-uuid-2", "grid_x": 3, "grid_y": 0, "grid_w": 6, "grid_h": 5 }
]
}
FieldTypeRequiredDescription
layoutarrayYesNon-empty list of { id, grid_x, grid_y, grid_w, grid_h } entries
{
"status": "success",
"data": {
"message": "Layout saved successfully"
}
}