This endpoint is in preview and may be modified or removed at any time.
To use this endpoint, add preview=true to the request query parameters.
Executes a Query and returns results as a Server-Sent Events (text/event-stream) stream.
By default, this executes the latest version of the query. The latest version is the one
that was most recently published, which may be a pre-release version.
This endpoint supports all Query functions. Each SSE event's data field is a JSON-encoded
StreamingExecuteQueryResponse – either a data batch (type: data) carrying one or more
result values, or an error (type: error) emitted before stream termination if execution
fails. Non-streaming functions emit a single data event containing the entire result;
streaming functions emit a data event per batch as results become available.
Per the Server-Sent Events specification, each event is terminated by a blank line:
data: {"type":"data","value":[{"productId":"SKU-001","price":29.99}]}
data: {"type":"error","errorCode":"INVALID_ARGUMENT","errorName":"QueryRuntimeError","errorInstanceId":"3f8a9c7b-2e4d-4a1f-9b8c-7d6e5f4a3b2c","errorDescription":"Division by zero","parameters":{}}
Third-party applications using this endpoint via OAuth2 must request the following operation scope: api:functions-execute.
stringoptionalThe ID of a transaction to read from. Transactions are an experimental feature and not all workflows may be supported.
booleanoptionalEnables the use of preview functionality.
objectstringoptionalOptional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function.
map<ParameterId, DataValue>optionalstringoptionalThe version of the query to execute. When used with branch, the specified version must exist on the branch.
stringoptionalThe Foundry branch to execute the query from. If not specified, the default branch is used.
When provided without version, the latest version on this branch is used.
When provided with version, the specified version must exist on the branch.
unionReturns a stream of Server-Sent Events (text/event-stream). Each event's data field is a JSON-encoded payload of the type described below.
A single message in a streaming Query execution response. Each message contains either a data batch or an error.
objectoptionalA batch of query results.
objectoptionalAn error that occurred during query execution.
1
2
3
4
5
curl -X POST \
\t-H "Content-type: application/json" \
\t-H "Authorization: Bearer $TOKEN" \
"https://$HOSTNAME/api/v2/functions/queries/myQueryFunction/streamingExecute?transactionId=transaction-1&preview=true" \
-d '{"parameters":{"price":29.99},"version":"1.2.3","branch":"ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252","ontology":"example-ontology"}'| Error Name | ||
|---|---|---|
Streaming | Error Code | PERMISSION_DENIED |
| Status Code | 403 | |
| Description | Could not streamingExecute the Query. | |
| Parameters | queryApiName | |
See Errors for a general overview of errors in the platform.