Skip to main content
A
Docs

Insights API reference

Endpoints, request and response examples, and errors for the Insights API: questions, data sources, dashboards and reports.

Authentication

Send a token as Authorization: Bearer <token>. Read API conventions.

Endpoints

MethodPathPurposeRole
POST/api/v1/insights/queryAsk a question about a data sourceAny
GET/api/v1/insights/query-historyRecent questionsAny
GET/api/v1/insights/queries/historyQuestion history, page by pageAny
GET/api/v1/insights/queries/searchSearch past questionsAny
POST/api/v1/insights/queries/batch-deleteDelete more than one past questionadmin
GET/api/v1/insights/trendsQuestion trendsAny
GET/api/v1/insights/statsUsage statisticsAny
GET/api/v1/sourcesList data sourcesAny
POST/api/v1/sourcesAdd a data sourceadmin
POST/api/v1/sources/uploadUpload a CSV file as a data sourceadmin
DELETE/api/v1/sources/{source_id}Delete a data sourceadmin
POST/api/v1/sources/{source_id}/refreshLoad the data of a source againAny
GET/api/v1/sources/{source_id}/statsStatistics of a data sourceAny
GET/api/v1/dashboardsList dashboardsAny
POST/api/v1/dashboardsCreate a dashboardadmin
GET/api/v1/dashboards/{dashboard_id}Get a dashboardAny
PUT/api/v1/dashboards/{dashboard_id}Change a dashboardadmin
DELETE/api/v1/dashboards/{dashboard_id}Delete a dashboardadmin
GET/api/v1/dashboards/{dashboard_id}/widgetsGet the widgets of a dashboardAny
PUT/api/v1/dashboards/{dashboard_id}/widgetsChange the widgets of a dashboardAny
POST/api/v1/dashboards/{dashboard_id}/cloneCopy a dashboardadmin
POST/api/v1/insights/dashboards/{dashboard_id}/duplicateCopy a dashboardadmin
POST/api/v1/insights/dashboards/batch-deleteDelete more than one dashboardadmin
GET/api/v1/insights/dashboards/{dashboard_id}/exportExport a dashboardAny
POST/api/v1/insights/dashboards/importImport a dashboardadmin
GET/api/v1/reportsList reportsAny
POST/api/v1/reports/generateWrite a report about a data sourceAny
GET/api/v1/reports/{report_id}Get a reportAny
GET/api/v1/reports/{report_id}/exportExport a reportAny
POST/api/v1/reports/compareCompare two reportsAny
DELETE/api/v1/reports/{report_id}Delete a reportadmin
GET/api/v1/healthHealth checkNone

Any user can change the widgets of a dashboard.

Ask a question

curl https://insights.example.gov/api/v1/insights/query \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question": "Which service centre had the most applications last quarter?", "language": "en", "source_id": "src_applications"}'
FieldTypeRequiredMeaning
questionstringYes1 to 2,000 characters
languagestringNoen or ar
source_idstringYesThe data source to query

Response fields

FieldMeaning
query_idThe identifier of the question
structured_queryThe query that Insights ran
resultsThe result rows
total_rowsThe number of rows
suggested_chartThe chart type to use
summaryA short answer in words

Errors

StatusCause
400The data source has no data. Upload a CSV file to it.
403Your role cannot change dashboards or data sources
404The data source, dashboard or report does not exist
422The question is empty or too long