# Deltastream

## POST /statements

> Submit one statement for execution.

```json
{"openapi":"3.0.3","info":{"title":"DeltaStream REST API","version":"2.0.0"},"servers":[{"url":"https://api.deltastream.io/v2"}],"security":[{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"DeltaStream API token."}},"schemas":{"StatementRequest":{"type":"object","properties":{"statement":{"description":"DeltaStream SQL statement or batch of SQL statements to execute","type":"string"},"organization":{"description":"Organization Name or ID in which the statement should be executed","type":"string"},"role":{"description":"Role to use when executing a statement. This value is case sensitive","type":"string"},"database":{"description":"Database to add to search path for name resolution. This value is case sensitive","type":"string"},"schema":{"description":"Database schema to add to search path for name resolution. This value is case sensitive","type":"string"},"store":{"description":"Store to use when executing a statement. This value is case sensitive","type":"string"},"computePool":{"description":"Compute_pool to use when executing a statement. This value is case sensitive","type":"string"},"parameters":{"type":"object","properties":{"timezone":{"type":"string"},"sessionID":{"type":"string"}}}},"required":["statement"]},"ResultSet":{"type":"object","properties":{"sqlState":{"type":"string"},"message":{"type":"string"},"statementID":{"type":"string","format":"uuid"},"statementIDs":{"type":"array","items":{"type":"string","format":"uuid"},"description":"IDs for each statement when a multi-statement SQL is submitted"},"createdOn":{"type":"integer","format":"int64","description":"UTC POSIX timestamp of when statement was submitted"},"metadata":{"$ref":"#/components/schemas/ResultSetMetadata"},"data":{"type":"array","minItems":0,"items":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"null","nullable":true}]}},"description":"Each item within a column of data is expressed as a string, regardless of the DeltaStream type of the column.\nFor example, the number 1.0 will be returned as \"1.0\"."}},"required":["sqlState","statementID","createdOn","metadata"]},"ResultSetMetadata":{"type":"object","properties":{"encoding":{"type":"string","enum":["json"]},"partitionInfo":{"type":"array","items":{"$ref":"#/components/schemas/ResultSetPartitionInfo"}},"columns":{"$ref":"#/components/schemas/ResultSetColumns"},"dataplaneRequest":{"$ref":"#/components/schemas/DataplaneRequest"},"context":{"$ref":"#/components/schemas/ResultSetContext"}},"required":["encoding","partitionInfo","columns"]},"ResultSetPartitionInfo":{"type":"object","properties":{"rowCount":{"type":"integer","format":"int32","minimum":0}},"required":["id","rowCount"]},"ResultSetColumns":{"type":"array","minItems":0,"items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"nullable":{"type":"boolean"},"display_hint":{"type":"string"}},"required":["name","type","nullable"]}},"DataplaneRequest":{"type":"object","properties":{"token":{"type":"string"},"uri":{"type":"string"},"statementID":{"type":"string"},"queryID":{"type":"string"},"requestType":{"type":"string","enum":["result-set","streaming"]}},"required":["token","uri","requestType","statementID"]},"ResultSetContext":{"type":"object","properties":{"organizationID":{"type":"string","format":"uuid"},"roleName":{"type":"string"},"databaseName":{"type":"string"},"schemaName":{"type":"string"},"storeName":{"type":"string"},"computePoolName":{"type":"string"}}},"StatementStatus":{"type":"object","properties":{"sqlState":{"type":"string"},"message":{"type":"string"},"statementID":{"type":"string","format":"uuid"},"statementIDs":{"type":"array","items":{"type":"string","format":"uuid"},"description":"IDs for each statement when a multi-statement SQL is submitted"},"createdOn":{"type":"integer","format":"int64","description":"UTC POSIX timestamp of when statement was submitted"}},"required":["sqlState","statementID","createdOn"]},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"traceID":{"type":"string"}},"required":["message"]}},"responses":{"ErrBadRequest":{"description":"Server cannot process the request due to a client error (malformed request syntax, invalid request message etc).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrForbidden":{"description":"Server cannot process the request due to invalid token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrNotFound":{"description":"Requested REST endpoint is not valid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrDeadlineExceeded":{"description":"Request execution was cancelled because it exceeded the timeout value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrInternal":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrServiceUnavailable":{"description":"Service is temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/statements":{"post":{"operationId":"SubmitStatement","description":"Submit one statement for execution.","tags":["deltastream"],"parameters":[],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"request":{"$ref":"#/components/schemas/StatementRequest"},"attachments":{"type":"array","items":{"type":"string","format":"binary"}}},"required":["request"]},"encoding":{"request":{"contentType":"application/json","style":"form"},"attachments":{"contentType":"application/octet-stream","style":"form"}}},"application/json":{"schema":{"$ref":"#/components/schemas/StatementRequest"}}}},"responses":{"200":{"description":"Statement successfully executed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultSet"}}}},"202":{"description":"Statement execution is in progress. Use GET /statements/{statementID} to poll for status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatementStatus"}}}},"400":{"$ref":"#/components/responses/ErrBadRequest"},"403":{"$ref":"#/components/responses/ErrForbidden"},"404":{"$ref":"#/components/responses/ErrNotFound"},"408":{"$ref":"#/components/responses/ErrDeadlineExceeded"},"500":{"$ref":"#/components/responses/ErrInternal"},"503":{"$ref":"#/components/responses/ErrServiceUnavailable"}}}}}}
```

## GET /statements/{statementID}

> Lookup the status of a statement.

```json
{"openapi":"3.0.3","info":{"title":"DeltaStream REST API","version":"2.0.0"},"servers":[{"url":"https://api.deltastream.io/v2"}],"security":[{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"DeltaStream API token."}},"parameters":{"statementID":{"schema":{"type":"string","format":"uuid"},"name":"statementID","in":"path","required":true,"allowEmptyValue":false},"sessionID":{"schema":{"type":"string"},"name":"sessionID","in":"query","allowEmptyValue":false},"partitionID":{"schema":{"type":"integer","format":"int32","minimum":0},"name":"partitionID","in":"query","allowEmptyValue":false},"timezone":{"schema":{"type":"string"},"name":"timezone","in":"query","allowEmptyValue":false}},"schemas":{"ResultSet":{"type":"object","properties":{"sqlState":{"type":"string"},"message":{"type":"string"},"statementID":{"type":"string","format":"uuid"},"statementIDs":{"type":"array","items":{"type":"string","format":"uuid"},"description":"IDs for each statement when a multi-statement SQL is submitted"},"createdOn":{"type":"integer","format":"int64","description":"UTC POSIX timestamp of when statement was submitted"},"metadata":{"$ref":"#/components/schemas/ResultSetMetadata"},"data":{"type":"array","minItems":0,"items":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"null","nullable":true}]}},"description":"Each item within a column of data is expressed as a string, regardless of the DeltaStream type of the column.\nFor example, the number 1.0 will be returned as \"1.0\"."}},"required":["sqlState","statementID","createdOn","metadata"]},"ResultSetMetadata":{"type":"object","properties":{"encoding":{"type":"string","enum":["json"]},"partitionInfo":{"type":"array","items":{"$ref":"#/components/schemas/ResultSetPartitionInfo"}},"columns":{"$ref":"#/components/schemas/ResultSetColumns"},"dataplaneRequest":{"$ref":"#/components/schemas/DataplaneRequest"},"context":{"$ref":"#/components/schemas/ResultSetContext"}},"required":["encoding","partitionInfo","columns"]},"ResultSetPartitionInfo":{"type":"object","properties":{"rowCount":{"type":"integer","format":"int32","minimum":0}},"required":["id","rowCount"]},"ResultSetColumns":{"type":"array","minItems":0,"items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"nullable":{"type":"boolean"},"display_hint":{"type":"string"}},"required":["name","type","nullable"]}},"DataplaneRequest":{"type":"object","properties":{"token":{"type":"string"},"uri":{"type":"string"},"statementID":{"type":"string"},"queryID":{"type":"string"},"requestType":{"type":"string","enum":["result-set","streaming"]}},"required":["token","uri","requestType","statementID"]},"ResultSetContext":{"type":"object","properties":{"organizationID":{"type":"string","format":"uuid"},"roleName":{"type":"string"},"databaseName":{"type":"string"},"schemaName":{"type":"string"},"storeName":{"type":"string"},"computePoolName":{"type":"string"}}},"StatementStatus":{"type":"object","properties":{"sqlState":{"type":"string"},"message":{"type":"string"},"statementID":{"type":"string","format":"uuid"},"statementIDs":{"type":"array","items":{"type":"string","format":"uuid"},"description":"IDs for each statement when a multi-statement SQL is submitted"},"createdOn":{"type":"integer","format":"int64","description":"UTC POSIX timestamp of when statement was submitted"}},"required":["sqlState","statementID","createdOn"]},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"traceID":{"type":"string"}},"required":["message"]}},"responses":{"ErrBadRequest":{"description":"Server cannot process the request due to a client error (malformed request syntax, invalid request message etc).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrForbidden":{"description":"Server cannot process the request due to invalid token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrNotFound":{"description":"Requested REST endpoint is not valid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrDeadlineExceeded":{"description":"Request execution was cancelled because it exceeded the timeout value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrInternal":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrServiceUnavailable":{"description":"Service is temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/statements/{statementID}":{"get":{"operationId":"GetStatementStatus","description":"Lookup the status of a statement.","tags":["deltastream"],"parameters":[{"$ref":"#/components/parameters/statementID"},{"$ref":"#/components/parameters/sessionID"},{"$ref":"#/components/parameters/partitionID"},{"$ref":"#/components/parameters/timezone"}],"responses":{"200":{"description":"Statement successfully executed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResultSet"}}}},"202":{"description":"Statement execution is in progress. Use GET /statements/{statementID} to poll for status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatementStatus"}}}},"400":{"$ref":"#/components/responses/ErrBadRequest"},"403":{"$ref":"#/components/responses/ErrForbidden"},"404":{"$ref":"#/components/responses/ErrNotFound"},"408":{"$ref":"#/components/responses/ErrDeadlineExceeded"},"500":{"$ref":"#/components/responses/ErrInternal"},"503":{"$ref":"#/components/responses/ErrServiceUnavailable"}}}}}}
```

## GET /version

> Returns the server version

```json
{"openapi":"3.0.3","info":{"title":"DeltaStream REST API","version":"2.0.0"},"servers":[{"url":"https://api.deltastream.io/v2"}],"security":[{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"DeltaStream API token."}},"schemas":{"Version":{"type":"object","properties":{"major":{"type":"integer"},"minor":{"type":"integer"},"patch":{"type":"integer"}},"required":["major","minor","patch"]},"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"traceID":{"type":"string"}},"required":["message"]}},"responses":{"ErrForbidden":{"description":"Server cannot process the request due to invalid token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrInternal":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrServiceUnavailable":{"description":"Service is temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/version":{"get":{"description":"Returns the server version","operationId":"GetVersion","tags":["deltastream"],"responses":{"200":{"description":"server version","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Version"}}}},"403":{"$ref":"#/components/responses/ErrForbidden"},"500":{"$ref":"#/components/responses/ErrInternal"},"503":{"$ref":"#/components/responses/ErrServiceUnavailable"}}}}}}
```

## GET /download/{resourceType}/{organizationID}/{resourceName}

> Download a resource

```json
{"openapi":"3.0.3","info":{"title":"DeltaStream REST API","version":"2.0.0"},"servers":[{"url":"https://api.deltastream.io/v2"}],"security":[{"apiToken":[]}],"components":{"securitySchemes":{"apiToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"DeltaStream API token."}},"parameters":{"resourceType":{"name":"resourceType","in":"path","schema":{"type":"string","enum":["function_source","descriptor_source"]},"required":true},"organizationID":{"name":"organizationID","in":"path","schema":{"type":"string","format":"uuid"},"required":true},"resourceName":{"name":"resourceName","in":"path","schema":{"type":"string"},"required":true}},"responses":{"ErrBadRequest":{"description":"Server cannot process the request due to a client error (malformed request syntax, invalid request message etc).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrForbidden":{"description":"Server cannot process the request due to invalid token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrNotFound":{"description":"Requested REST endpoint is not valid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrDeadlineExceeded":{"description":"Request execution was cancelled because it exceeded the timeout value","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrInternal":{"description":"Internal server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ErrServiceUnavailable":{"description":"Service is temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"ErrorResponse":{"type":"object","properties":{"message":{"type":"string"},"traceID":{"type":"string"}},"required":["message"]}}},"paths":{"/download/{resourceType}/{organizationID}/{resourceName}":{"get":{"operationId":"DownloadResource","description":"Download a resource","tags":["deltastream"],"parameters":[{"$ref":"#/components/parameters/resourceType"},{"$ref":"#/components/parameters/organizationID"},{"$ref":"#/components/parameters/resourceName"}],"responses":{"200":{"description":"Download file","content":{"application/octet-stream":{"schema":{"type":"string","format":"bytes"}}}},"400":{"$ref":"#/components/responses/ErrBadRequest"},"403":{"$ref":"#/components/responses/ErrForbidden"},"404":{"$ref":"#/components/responses/ErrNotFound"},"408":{"$ref":"#/components/responses/ErrDeadlineExceeded"},"500":{"$ref":"#/components/responses/ErrInternal"},"503":{"$ref":"#/components/responses/ErrServiceUnavailable"}}}}}}
```


---

# 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.deltastream.io/reference/deltastream-openapi/deltastream.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.
