> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Save a query document

> Save reusable SQL without executing it. The workspace service must be enabled.

How-to guideApplies to: Unified engine deployments

Save reusable SQL without executing it. The workspace service must be enabled.

### Save a reusable query

Save SQL as a workspace document, then read its recorded revision. Creating a document does not execute its SQL.

| Placeholder | Value |
| - | - |
| `{{submission_id}}` | A new UUID for this request; reuse it when recovering the same submission. |

Replace the placeholders in your client. Keep returned IDs for later requests. Paths below use the native API prefix; adjust it for your deployment.

#### 1. Save the query

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
POST /api/v1/workspace/documents
Host: <ENGINE_HOST>
Content-Type: application/json

{
  "submission_id": "{{submission_id}}",
  "name": "HTTP example - saved query",
  "body": {
    "type": "Query",
    "sql": "WITH orders(id, category, region, amount) AS (VALUES (1, 'Books', 'North', 20), (2, 'Games', 'South', 30), (3, 'Games', 'North', 15), (4, 'Books', 'North', 40), (5, 'Garden', 'South', 25), (6, 'Garden', 'North', 10)) SELECT category, SUM(amount) AS sales FROM orders GROUP BY category ORDER BY category",
    "settings": {
      "current_catalog": "default",
      "namespace": [
        "default"
      ],
      "time_zone": "UTC",
      "case_sensitive": false,
      "ansi_enabled": true
    }
  }
}
```

From the response, keep `document_id` from `/document/document_id`.

[Endpoint reference](https://docs.e6data.com/transformation/http/reference/create-workspace-document.md).

#### 2. Read the saved query

```http theme={"theme":{"light":"github-light","dark":"github-dark"}}
GET /api/v1/workspace/documents/{{document_id}}
Host: <ENGINE_HOST>
```

[Endpoint reference](https://docs.e6data.com/transformation/http/reference/get-workspace-document.md).

Creation returns the document ID and revision. The next request reads the same saved document. Verify its name, SQL, settings, and revision.

Edits need the current expected revision and a new submission identity. Deletion removes the saved document; it does not undo earlier SQL executions or delete source tables.

Use session operations to execute SQL. Saving a document and executing a query are separate actions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.