Chuyển tới nội dung chính

Charts API

BI charts: CRUD, compile-to-SQL data requests, folders, trash + bookmarks.

This page lists 14 endpoints (OpenAPI tag charts). It is generated from openapi.json; see the REST API overview for authentication, CSRF and error conventions.

MethodPathOperation idNotes
GET/api/ws/{workspace}/chartsch_list
POST/api/ws/{workspace}/chartsch_create
POST/api/ws/{workspace}/charts/datach_data
POST/api/ws/{workspace}/charts/runch_run_specRun a client-supplied QuerySpec against a dataset and return the rows.
GET/api/ws/{workspace}/charts/{id}ch_get
PUT/api/ws/{workspace}/charts/{id}ch_update
DELETE/api/ws/{workspace}/charts/{id}ch_remove
POST/api/ws/{workspace}/charts/{id}/bookmarkch_bookmark_add
DELETE/api/ws/{workspace}/charts/{id}/bookmarkch_bookmark_remove
POST/api/ws/{workspace}/charts/{id}/datach_runObject-scoped: runs ONLY the chart's persisted query (no client-supplied spec — the handler takes only the path id), so an object guest with a chart:read g...
POST/api/ws/{workspace}/charts/{id}/duplicatech_duplicate
PATCH/api/ws/{workspace}/charts/{id}/folderch_set_folder
POST/api/ws/{workspace}/charts/{id}/restorech_restore
POST/api/ws/{workspace}/charts/{id}/trashch_trash

GET /api/ws/{workspace}/charts​

Operation id: ch_list. Auth: Session cookie. Forbidden (403): Missing chart:read permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
trashedquerybooleannoList only trashed charts when true

Response 200 (application/json): array of ChartDto

FieldTypeRequiredDescription
idstringyes
dataset_idstringyes
namestringyes
descriptionstringyes
viz_typestringyes
paramsobjectyes
created_bystring, nullableno
folder_idstring, nullableno
updated_atstring (date-time)yes
deleted_atstring (date-time), nullableno
bookmarkedbooleanyes
StatusMeaning
200Charts in the workspace
401Not authenticated
403Missing chart:read permission
500Internal error

POST /api/ws/{workspace}/charts​

Operation id: ch_create. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug

Request body (application/json): CreateChart

FieldTypeRequiredDescription
dataset_idstring (uuid)yes
namestringyes
descriptionstringno
viz_typestringyes
paramsobjectyes

Response 200 (application/json): ChartDto

FieldTypeRequiredDescription
idstringyes
dataset_idstringyes
namestringyes
descriptionstringyes
viz_typestringyes
paramsobjectyes
created_bystring, nullableno
folder_idstring, nullableno
updated_atstring (date-time)yes
deleted_atstring (date-time), nullableno
bookmarkedbooleanyes
StatusMeaning
200Chart created
400Malformed params (see the message)
401Not authenticated
403Missing chart:manage permission
404Referenced dataset not in this workspace
500Internal error

POST /api/ws/{workspace}/charts/data​

Operation id: ch_data. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:read permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug

Request body (application/json): ChartDataBody

FieldTypeRequiredDescription
dataset_idstring (uuid)yes
query_specQuerySpecyes

Response 200 (application/json): ChartDataResponse

FieldTypeRequiredDescription
sqlstringyes
database_idstringyes
StatusMeaning
200Compiled SQL + target database id (the client submits it to the query seam)
400Invalid query spec (unknown column/metric, bad filter, …)
401Not authenticated
403Missing chart:read permission
404Referenced dataset not in this workspace
500Internal error

POST /api/ws/{workspace}/charts/run​

Operation id: ch_run_spec. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:read permission, or the charts module is disabled.

Run a client-supplied QuerySpec against a dataset and return the rows.

This is ch_run for a spec that is not (yet) a saved chart: the chart builder's preview, dashboard edit-mode cards, and filter-value dropdowns. It exists so those three do not have to go through the free-form SQL endpoint — which lets POST /queries be gated on the SQL Lab entitlement without breaking chart authoring, and stops raw SQL crossing the wire when a user is only building a chart.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug

Request body (application/json): ChartDataBody

FieldTypeRequiredDescription
dataset_idstring (uuid)yes
query_specQuerySpecyes

Response 200 (application/json): ChartRunResponse

FieldTypeRequiredDescription
columnsColumnMeta[]yes
rowsobject[][]yesRow-major cell values; each inner vec is one row aligned to columns.
StatusMeaning
200The client-supplied spec, compiled + executed: columns + rows
400Invalid query spec (unknown column/metric, bad filter, …)
401Not authenticated
403Missing chart:read permission, or the charts module is disabled
404Referenced dataset not in this workspace
500Internal error
502Query engine error

GET /api/ws/{workspace}/charts/{id}​

Operation id: ch_get. Auth: Session cookie. Forbidden (403): Missing chart:read permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): ChartDto

FieldTypeRequiredDescription
idstringyes
dataset_idstringyes
namestringyes
descriptionstringyes
viz_typestringyes
paramsobjectyes
created_bystring, nullableno
folder_idstring, nullableno
updated_atstring (date-time)yes
deleted_atstring (date-time), nullableno
bookmarkedbooleanyes
StatusMeaning
200Chart detail
401Not authenticated
403Missing chart:read permission
404No such chart in this workspace
500Internal error

PUT /api/ws/{workspace}/charts/{id}​

Operation id: ch_update. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Request body (application/json): UpdateChart

FieldTypeRequiredDescription
dataset_idstring (uuid)yes
namestringyes
descriptionstringno
viz_typestringyes
paramsobjectyes

Response 200 (application/json): ChartDto

FieldTypeRequiredDescription
idstringyes
dataset_idstringyes
namestringyes
descriptionstringyes
viz_typestringyes
paramsobjectyes
created_bystring, nullableno
folder_idstring, nullableno
updated_atstring (date-time)yes
deleted_atstring (date-time), nullableno
bookmarkedbooleanyes
StatusMeaning
200Chart updated
400Malformed params (see the message)
401Not authenticated
403Missing chart:manage permission
404No such chart, or referenced dataset not in this workspace
500Internal error

DELETE /api/ws/{workspace}/charts/{id}​

Operation id: ch_remove. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart deleted
401Not authenticated
403Missing chart:manage permission
404No such chart in this workspace
500Internal error

POST /api/ws/{workspace}/charts/{id}/bookmark​

Operation id: ch_bookmark_add. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:read permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart bookmarked for the caller
401Not authenticated
403Missing chart:read permission
404No such chart in this workspace
500Internal error

DELETE /api/ws/{workspace}/charts/{id}/bookmark​

Operation id: ch_bookmark_remove. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:read permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart bookmark removed for the caller
401Not authenticated
403Missing chart:read permission
404No such chart in this workspace
500Internal error

POST /api/ws/{workspace}/charts/{id}/data​

Operation id: ch_run. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): No chart:read grant on this chart.

Object-scoped: runs ONLY the chart's persisted query (no client-supplied spec — the handler takes only the path id), so an object guest with a chart:read grant can view the shared chart's data without any query:run workspace permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): ChartRunResponse

FieldTypeRequiredDescription
columnsColumnMeta[]yes
rowsobject[][]yesRow-major cell values; each inner vec is one row aligned to columns.
StatusMeaning
200The chart's SAVED query, executed: columns + rows
400Chart has no runnable query, or its saved spec is invalid
401Not authenticated
403No chart:read grant on this chart
404No such chart in this workspace, or its dataset is gone
500Internal error
502Query engine error

POST /api/ws/{workspace}/charts/{id}/duplicate​

Operation id: ch_duplicate. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id to duplicate
workspacepathstringyes

Response 200 (application/json): ChartDto

FieldTypeRequiredDescription
idstringyes
dataset_idstringyes
namestringyes
descriptionstringyes
viz_typestringyes
paramsobjectyes
created_bystring, nullableno
folder_idstring, nullableno
updated_atstring (date-time)yes
deleted_atstring (date-time), nullableno
bookmarkedbooleanyes
StatusMeaning
200Chart duplicated
401Not authenticated
403Missing chart:manage permission
404No such chart in this workspace
500Internal error

PATCH /api/ws/{workspace}/charts/{id}/folder​

Operation id: ch_set_folder. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Request body (application/json): SetFolder

FieldTypeRequiredDescription
folder_idstring (uuid), nullableno

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart moved to folder
401Not authenticated
403Missing chart:manage permission
404No such chart or target folder in this workspace
500Internal error

POST /api/ws/{workspace}/charts/{id}/restore​

Operation id: ch_restore. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart restored from trash
401Not authenticated
403Missing chart:manage permission
404No such chart in this workspace
500Internal error

POST /api/ws/{workspace}/charts/{id}/trash​

Operation id: ch_trash. Auth: Session cookie and X-Egret-CSRF header. Forbidden (403): Missing chart:manage permission.

ParameterInTypeRequiredDescription
workspacepathstringyesWorkspace slug
idpathstring (uuid)yesChart id
workspacepathstringyes

Response 200 (application/json): Ack

FieldTypeRequiredDescription
okbooleanyes
StatusMeaning
200Chart moved to trash
401Not authenticated
403Missing chart:manage permission
404No such chart in this workspace
500Internal error