Get SQL history overview

Summarize SQL execution-record counts in the current workspace by time range and SQL source. The result includes only the count for each execution status and does not return individual SQL execution records. By default, the API counts only records for the current identity. With the required permission, it can count records for the entire workspace.

POST https://moi.matrixorigin.cn/newmoi/query/history/overview

Preparation before calling

Prepare a personal access token with access to the current workspace and the current workspace ID.

Request body

curl -X POST "https://moi.matrixorigin.cn/newmoi/query/history/overview" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "start": "2026-08-26T08:00:00Z",
    "end": "2026-08-26T09:00:00Z"
  }'

Parameter

Type

Required

Description

scope

string

No

Counts records for the current identity or the current workspace.

start

string

No

Start time for the count, for example 2026-08-26T08:00:00Z.

end

string

No

End time for the count, for example 2026-08-26T09:00:00Z.

sql_source_type

string[]

No

Filters by SQL source type. A non-empty array filters by its values.

non_user

boolean

No

Whether to include non-user SQL in the count.

Read scope

scope value

Records counted

Permission

self

Records for the current identity.

Default scope.

workspace

Workspace-wide records.

Requires workspace audit read permission.

Query time and SQL source

Specify a complete date, time, and time zone. If both the start and end times are omitted, the API counts records from the five minutes before the request. You can specify only one of the times as a boundary.

When you specify an SQL source, sql_source_type takes precedence. When no SQL source is specified, non_user: true counts all sources; false or an omitted value counts only user SQL and external SQL.

Success response

On success, the API returns a count summary of SQL execution records. A data.total of 0 means no records can be counted for the current filters; it does not mean the query failed.

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "total": 3,
    "success": 2,
    "running": 0,
    "failed": 1
  }
}

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.total

integer

Total number of records that match the filters.

data.success

integer

Number of records with status Success.

data.running

integer

Number of records with status Running.

data.failed

integer

Number of records with status Failed.

Error response

{
  "code": "ErrParamInvalid",
  "msg": "Invalid request parameter",
  "data": null
}

Field

Type

Description

code

string

Error code.

msg

string

Error message.

data

null

Next steps

To inspect an individual SQL execution record, list SQL execution records.

Last updated on