Create SQL draft version¶
Creates an editable draft version of a SQL save record and saves the original SQL content.
POST https://moi.matrixorigin.cn/newmoi/workbook/version/create
Preparation before calling¶
Prepare your personal access token, workspace ID, and SQL save record ID with update permissions. $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. You can first Create SQL Save Record to obtain workbook_id.
$WORKBOOK_ID in the example below is the ID of the SQL saved record. sql_content only saves the SQL content and does not execute the SQL.
Request body¶
Replace caller-specific values in the example with actual values.
workbook_idstringRequired- The ID of the SQL saved record.
sql_contentstring- Draft SQL content.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/workbook/version/create" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"workbook_id\": \"$WORKBOOK_ID\",
\"sql_content\": \"SELECT 1\"
}"
Successful response¶
data.id is the new draft version ID. After saving the ID, you can update draft version or final version.
{
"code": 200,
"data": {
"id": "version-123",
"version": "v1",
"status": "draft"
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
New draft version ID. |
|
string |
Version name. |
|
string |
New version status, which is |
Error response¶
codeinteger or string- Error code or status.
messagestring- Error message.
Error response example
{
"code": 500,
"message": "Internal server error"
}
Follow-up operations¶
Log data.id. Use this ID View saved SQL version content to confirm the save result.