> For the complete documentation index, see [llms.txt](https://docs.e6data.com/query-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.e6data.com/query-engine/reference/connectivity-reference/rest-v2-endpoints.md).

# REST v2 endpoints

Reference for the e6data HTTP REST v2 SQL endpoints, headers, and statement states.

The HTTP REST v2 API runs SQL over HTTPS (HTTP/2). Authenticate once for a session token, then submit statements and read results asynchronously. For the full walkthrough, see [REST API for SQL queries](/query-engine/developers/connecting-to-the-engine/rest-api-for-sql.md).

## Endpoints

| Method & path                                       | Purpose                                  |
| --------------------------------------------------- | ---------------------------------------- |
| `POST /api/v1/authenticate`                         | Exchange credentials for a session token |
| `POST /api/v2/sql/statements`                       | Submit a SQL statement                   |
| `GET /api/v2/sql/statements/{id}`                   | Poll status / get the first result chunk |
| `GET /api/v2/sql/statements/{id}/result/chunks/{n}` | Page through large results               |
| `POST /api/v2/sql/statements/{id}/cancel`           | Cancel a running statement               |
| `POST /api/v2/sql/statements/{id}/clearOrCancel`    | Free planner resources when finished     |
| `GET /api/v2/sql/statements/{id}/explain-analyze`   | Query plan and timings                   |

## Headers

| Header          | When                 | Value                                        |
| --------------- | -------------------- | -------------------------------------------- |
| `cluster-name`  | All requests         | The target cluster                           |
| `Content-Type`  | POST requests        | `application/json`                           |
| `Authorization` | After authenticating | `Bearer <session>`                           |
| `X-Session-Id`  | Polling/paging       | Reuse `session_id` to skip re-authentication |

## Statement states

```
PENDING → RUNNING → SUCCEEDED   (or FAILED / CANCELLED)
```

## Notes

* **HTTP/2 is required.** Use an HTTP/2-capable client and don't force curl's `--http2` flag.
* Use the v2 path (`/api/v2/sql/statements`), not the older `/api/v1/query`.
* Suspended clusters auto-resume on the first statement (\~30–90 s).

## See also

* [REST API for SQL queries](/query-engine/developers/connecting-to-the-engine/rest-api-for-sql.md)
* [Connecting to the engine](/query-engine/developers/connecting-to-the-engine.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.e6data.com/query-engine/reference/connectivity-reference/rest-v2-endpoints.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
