# SQL Snapshot

## List SQL Snapshot Queries

> Returns all currently active SQL snapshot query executions. Each entry includes the query ID, SQL statement, execution start time, and current progress. Useful for monitoring and managing long-running queries.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_SqlSnapshot"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_ExecutionView":{"required":["id","started","sql","username","status"],"type":"object","properties":{"id":{"type":"string","format":"uuid"},"started":{"type":"string","format":"date-time"},"finished":{"type":"string","format":"date-time"},"sql":{"type":"string"},"username":{"type":"string"},"status":{"$ref":"#/components/schemas/agent_ExecutionStatus"},"message":{"type":"string"}}},"agent_ExecutionStatus":{"type":"string","enum":["Completed","Killed","Running"]},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/sql/queries":{"get":{"tags":["agent_SqlSnapshot"],"summary":"List SQL Snapshot Queries","description":"Returns all currently active SQL snapshot query executions. Each entry includes the query ID, SQL statement, execution start time, and current progress. Useful for monitoring and managing long-running queries.","operationId":"listSqlSnapshotQueries","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/agent_ExecutionView"}}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Stop SQL Snapshot Query

> Cancels an in-progress SQL snapshot query execution. The query will be terminated and resources released. Use the query ID returned from the execute endpoint to identify the query to cancel.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_SqlSnapshot"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/sql/execution/{queryId}":{"delete":{"tags":["agent_SqlSnapshot"],"summary":"Stop SQL Snapshot Query","description":"Cancels an in-progress SQL snapshot query execution. The query will be terminated and resources released. Use the query ID returned from the execute endpoint to identify the query to cancel.","operationId":"stopSqlSnapshotQuery","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"queryId","in":"path","description":"The SQL Snapshot query identifier","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":""},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get Topic Paging Details

> Returns partition-level offset information for a Kafka topic, including the earliest and latest offsets for each partition. This information is useful for understanding data availability and planning query ranges.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_SqlSnapshot"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_Paging":{"required":["tableName","type","label"],"type":"object","properties":{"tableName":{"$ref":"#/components/schemas/agent_TableName"},"type":{"$ref":"#/components/schemas/agent_PagingType"},"label":{"type":"string"},"partitions":{"type":"array","items":{"$ref":"#/components/schemas/agent_PagingPartition"}}}},"agent_TableName":{"required":["value"],"type":"object","properties":{"value":{"type":"string"}}},"agent_PagingType":{"required":["value"],"type":"object","properties":{"value":{"type":"string"}}},"agent_PagingPartition":{"required":["id","label","start","end"],"type":"object","properties":{"id":{"$ref":"#/components/schemas/agent_Partition1"},"label":{"type":"string"},"start":{"type":"integer","format":"int64"},"end":{"type":"integer","format":"int64"}}},"agent_Partition1":{"required":["value"],"type":"object","properties":{"value":{"type":"integer","format":"int64"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/sql/paging":{"get":{"tags":["agent_SqlSnapshot"],"summary":"Get Topic Paging Details","description":"Returns partition-level offset information for a Kafka topic, including the earliest and latest offsets for each partition. This information is useful for understanding data availability and planning query ranges.","operationId":"getKafkaTopicDataPagingDetails","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}},{"name":"table","in":"query","description":"The target table","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/agent_Paging"}}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```

## Get Snapshot SQL Intellisense

> Provides code completion, syntax validation, and schema suggestions for snapshot SQL queries. Returns available tables, columns, functions, and SQL keywords based on the cursor position. Supports multiple data connections.

```json
{"openapi":"3.0.0","info":{"title":"Lenses API","version":"6.1"},"tags":[{"name":"agent_SqlSnapshot"}],"servers":[{"url":"{server}","variables":{"server":{"default":"https://api.example.com"}}}],"security":[{"bearerAuth":[]},{"cookieAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The bearer token can be obtained by creating a ServiceAccount.\n"},"cookieAuth":{"type":"apiKey","in":"cookie","name":"session_id","description":"On successful SAML/SSO login, the API will set a cookie with a session id.\n"}},"schemas":{"agent_PresentationRequest":{"required":["sql"],"type":"object","properties":{"sql":{"type":"string"},"caret":{"type":"integer"},"connectorId":{"type":"string"}}},"agent_Presentation":{"required":["input","caret"],"type":"object","properties":{"input":{"type":"string"},"caret":{"type":"integer"},"lints":{"type":"array","items":{"$ref":"#/components/schemas/agent_Lint"}},"suggestions":{"type":"array","items":{"$ref":"#/components/schemas/agent_Suggestion"}},"highlights":{"type":"array","items":{"$ref":"#/components/schemas/agent_Highlight1"}},"tables":{"type":"array","items":{"$ref":"#/components/schemas/agent_TableFields"}},"statementsPositions":{"type":"array","items":{"$ref":"#/components/schemas/agent_StatementPos"}}}},"agent_Lint":{"required":["start","end","text","type"],"type":"object","properties":{"start":{"type":"integer"},"end":{"type":"integer"},"text":{"type":"string"},"type":{"$ref":"#/components/schemas/agent_HintType"}}},"agent_HintType":{"type":"string","enum":["Warning","Error","Obfuscation","Info","Security"]},"agent_Suggestion":{"required":["display","text","start","end","type","highlightStart","highlightEnd"],"type":"object","properties":{"display":{"type":"string"},"text":{"type":"string"},"start":{"type":"integer"},"end":{"type":"integer"},"type":{"type":"string"},"description":{"type":"string"},"highlightStart":{"type":"integer"},"highlightEnd":{"type":"integer"}}},"agent_Highlight1":{"required":["start","end","text","type"],"type":"object","properties":{"start":{"type":"integer"},"end":{"type":"integer"},"text":{"type":"string"},"type":{"$ref":"#/components/schemas/agent_HighlightType"}}},"agent_HighlightType":{"type":"string","enum":["Keyword","String","Integral","Float","Boolean","Type"]},"agent_TableFields":{"required":["tableName"],"type":"object","properties":{"tableName":{"$ref":"#/components/schemas/agent_TableName"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldName"}}}},"agent_TableName":{"required":["value"],"type":"object","properties":{"value":{"type":"string"}}},"agent_FieldName":{"required":["value"],"type":"object","properties":{"value":{"type":"string"}}},"agent_StatementPos":{"required":["index","start","end"],"type":"object","properties":{"index":{"type":"integer"},"start":{"type":"integer"},"end":{"type":"integer"}}},"agent_BadRequest":{"required":["error"],"type":"object","properties":{"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"error":{"type":"string"},"errorType":{"type":"string"}}},"agent_FieldError":{"required":["field","error"],"type":"object","properties":{"field":{"type":"string"},"error":{"type":"string"},"lineNumber":{"type":"integer"},"columnNumber":{"type":"integer"}}},"agent_Unauthorized":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_LicenseError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_Forbidden":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_NotFound":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}},"agent_InternalError":{"required":["error"],"type":"object","properties":{"error":{"type":"string"},"fields":{"type":"array","items":{"$ref":"#/components/schemas/agent_FieldError"}},"errorType":{"type":"string"}}}}},"paths":{"/api/v1/environments/{environment}/proxy/api/v1/sql/presentation":{"post":{"tags":["agent_SqlSnapshot"],"summary":"Get Snapshot SQL Intellisense","description":"Provides code completion, syntax validation, and schema suggestions for snapshot SQL queries. Returns available tables, columns, functions, and SQL keywords based on the cursor position. Supports multiple data connections.","operationId":"getSnapshotIntellisenseV1","parameters":[{"name":"environment","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_PresentationRequest"}}},"required":true},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Presentation"}}}},"400":{"description":"The request input was invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_BadRequest"}}}},"401":{"description":"Authentication error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Unauthorized"}}}},"402":{"description":"The purchased Lenses license does not provide access to this feature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_LicenseError"}}}},"403":{"description":"Authorisation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_Forbidden"}}}},"404":{"description":"The requested resource cannot be found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_NotFound"}}}},"500":{"description":"An internal server error has occurred","content":{"application/json":{"schema":{"$ref":"#/components/schemas/agent_InternalError"}}}}}}}}}
```


---

# Agent Instructions: 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:

```
GET https://docs.lenses.io/latest/api-reference/6.1/reference/sql-snapshot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
