# Create SQL draft version

Creates an editable draft version of a SQL save record and saves the original SQL content.

```text
POST $CLOUDSIGMA_API_BASE/workbook/version/create
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

First [create a saved SQL record](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-workbooks/create-workbook.html.md) to obtain its `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.

::::{div} mo-api-split
:::{div} mo-api-split-main
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>workbook_id</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>The ID of the SQL saved record.</dd></div>
<div class="mo-api-field"><dt><code>sql_content</code><span class="mo-api-field__type">string</span></dt><dd>Draft SQL content.</dd></div>
</dl>
:::
:::{div} mo-api-split-aside
<p class="mo-api-example-label">Request example</p>
```bash
curl -X POST "$CLOUDSIGMA_API_BASE/workbook/version/create" \
  -H "X-API-Key: $CLOUDSIGMA_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](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-workbooks/update-workbook-draft.html.md) or [final version](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-workbooks/finalize-workbook-version.html.md).

```json
{
  "code": 200,
  "data": {
    "id": "version-123",
    "version": "v1",
    "status": "draft"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.id` | string | New draft version ID. |
| `data.version` | string | Version name. |
| `data.status` | string | New version status, which is `draft`. |

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main
<dl class="mo-api-fields">
<div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">integer or string</span></dt><dd>Error code or status.</dd></div>
<div class="mo-api-field"><dt><code>message</code><span class="mo-api-field__type">string</span></dt><dd>Error message.</dd></div>
</dl>
:::
:::{div} mo-api-split-aside
<p class="mo-api-example-label">Error response example</p>
```json
{
  "code": 500,
  "message": "Internal server error"
}
```
:::
::::
## Follow-up operations

Log `data.id`. Use this ID [View saved SQL version content](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-processing/sql-workbooks/get-workbook.html.md) to confirm the save result.
