# Execution

> Run workflows, follow progress over SSE and read instances, results and node executions.

Source: https://docs.sommatic.ai/en/api/reference/execution/

## Execute a full workflow

`POST /workflow-orchestration/data-plane/execution-engine/execution/workflow`

Resolves graph from a draft FlowDefinition or published FlowVersion, creates a FlowInstance, delegates execution to the orchestrator, and persists step results. Provide flow_definition_id for draft testing or flow_version_id for production.

Authentication: Bearer token

### Request body

- `organization_id` (string, required)
- `flow_definition_id` (string): Draft flow definition ID (for testing)
- `flow_version_id` (string): Published flow version ID (for production)
- `input` (object): Input data for the workflow

### Responses

- `200`: Workflow execution result

### Example request

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/execution/workflow" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "organization_id": "<organization_id>"
     }'
```

## Get an flow instance result by query selector.

`GET /workflow-orchestration/data-plane/execution-engine/flow-instance-result/{queryselector}`

Returns the flow instance result information that matches the query selector an search specified in the route.

Authentication: Bearer token

### Parameters

- `queryselector` (path, enum, required): Is the filter available for this query Allowed values: `id`, `organization-id`, `all`.
- `search` (query, string): Keyword to search for entities.
- `include_status` (query, string): Optional status parameter to include flow instance results of a specific status.
- `exclude_status` (query, string): Optional status parameter to exclude flow instance results of a specific status.
- `page` (query, integer): Page number, starting at 1 (default 1).
- `pageSize` (query, integer): Records per page (default 25).
- `hydrate` (query, boolean): When "true", every `$payloadRef` descriptor found in the returned documents is resolved server-side and replaced by the original externalized content, so the consumer receives the same inline payloads it would have seen before the claim-check optimization. Use it for programmatic consumers that need the full content in one response (Command Center context, integrations). Leave it off for UI reads — the Run Detail screen loads externalized content lazily per chip. Ephemeral `_truncated` markers cannot be hydrated (their content was never stored).

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X GET "https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/flow-instance-result/<queryselector>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"
```

## Get a node execution by query selector.

`GET /workflow-orchestration/data-plane/execution-engine/node-execution/{queryselector}`

Returns the node execution information that matches the query selector and search specified in the route.

Authentication: Bearer token

### Parameters

- `queryselector` (path, enum, required): Is the filter available for this query Allowed values: `id`, `organization-id`, `all`.
- `search` (query, string): Keyword to search for entities.
- `include_status` (query, string): Optional status parameter to include node executions of a specific status.
- `exclude_status` (query, string): Optional status parameter to exclude node executions of a specific status.
- `page` (query, integer): Page number, starting at 1 (default 1).
- `pageSize` (query, integer): Records per page (default 25).

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X GET "https://api.sommatic.ai/workflow-orchestration/data-plane/execution-engine/node-execution/<queryselector>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"
```

## Get an Flow Instance by query selector.

`GET /workflow-orchestration/data-plane/instance-runtime/flow-instance/{queryselector}`

Returns the Flow Instance information that matches the query selector an search specified in the route.

Authentication: Bearer token

### Parameters

- `queryselector` (path, enum, required): Is the filter available for this query Allowed values: `id`, `organization-id`, `all`.
- `search` (query, string): Keyword to search for entities.
- `include_status` (query, string): Optional status parameter to include flow instances of a specific status.
- `exclude_status` (query, string): Optional status parameter to exclude flow instances of a specific status.
- `page` (query, integer): Page number, starting at 1 (default 1).
- `pageSize` (query, integer): Records per page (default 25).

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X GET "https://api.sommatic.ai/workflow-orchestration/data-plane/instance-runtime/flow-instance/<queryselector>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"
```

## SSE stream for real-time workflow execution events

`GET /workflow-orchestration/execution/stream`

Opens a Server-Sent Events connection to receive real-time execution progress for a specific workflow and user.

Authentication: Bearer token

### Parameters

- `flow_definition_id` (query, string, required): The ID of the workflow to listen for execution events.
- `user_identity` (query, string, required): The identity of the user listening for events.

### Responses

- `200`: SSE stream opened successfully.

### Example request

```bash
curl -X GET "https://api.sommatic.ai/workflow-orchestration/execution/stream?flow_definition_id=<flow_definition_id>&user_identity=<user_identity>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -N
```
