Create SQL workbook¶
Create a SQL workbook that holds SQL content and its versions. After success, save the returned workbook_id for creating and managing versions.
POST https://moi.matrixorigin.cn/newmoi/workbook/create
Preparation before calling¶
Prepare a personal access token and target workspace ID with permission to create SQL save records. $AI_STUDIO_API_KEY is the personal access token used as the value of the X-API-Key request header; $WORKSPACE_ID is the target workspace ID used as the value of the X-Workspace-ID request header.
$WORKBOOK_NAME in the example below is the name of the saved record.
Request body¶
Replace caller-specific values in the example with actual values.
namestringRequired- The name of the saved record.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/workbook/create" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"name\": \"$WORKBOOK_NAME\"
}"
Successful response¶
data.workbook_id is the ID of the newly saved record, and data.name is the record name. After saving workbook_id, first View SQL saved record version to obtain the version ID; when you need to add an editable version, then Create SQL draft version.
{
"code": 200,
"data": {
"workbook_id": "workbook-123",
"name": "销售分析"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
Create a new SQL ID to save the record. |
|
string |
The name of the saved record. |
Error response¶
codeinteger or string- Error code or status.
messagestring- Error message.
Error response example
{
"code": 400,
"message": "请求参数无效"
}
Follow-up operations¶
Logging data.workbook_id. First View the version of the SQL saved record to obtain version_id, and then use the two IDs to View the version content of the saved SQL.