# Synchronous Execution

## Execute Chatflow (Synchronous)

> Executes the latest published version of a specific Chatflow and waits for the complete result. The response is formatted for immediate use in chat applications.\
> This is a blocking call, best used for quick-running chatflows.

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"servers":[{"url":"https://api.waterflai.ai","description":"Production Server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your secret API key."}},"schemas":{"ExecutionRequest":{"type":"object","properties":{"input_data":{"type":"object","description":"A JSON object containing the input variables for the Chatflow or Workflow. The keys should match the names of the input nodes.","additionalProperties":true}}},"ChatCompletionResponse":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"created":{"type":"integer","format":"unixtime"},"model":{"type":"string","description":"The model that generated the response (the Chatbot ID)."},"choices":{"type":"array","items":{"$ref":"#/components/schemas/ChatCompletionResponseChoice"}},"usage":{"$ref":"#/components/schemas/UsageInfo"}}},"ChatCompletionResponseChoice":{"type":"object","properties":{"index":{"type":"integer"},"message":{"$ref":"#/components/schemas/ResponseChatMessage"},"finish_reason":{"type":"string","enum":["stop","length","model_length","error","tool_calls",null]}}},"ResponseChatMessage":{"type":"object","properties":{"role":{"type":"string","description":"The role of the author of this message."},"content":{"type":"string","description":"The contents of the message."}}},"UsageInfo":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}},"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}},"responses":{"UnauthorizedError":{"description":"API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/execute_chatflow/{chatflow_id}/execute":{"post":{"summary":"Execute Chatflow (Synchronous)","description":"Executes the latest published version of a specific Chatflow and waits for the complete result. The response is formatted for immediate use in chat applications.\nThis is a blocking call, best used for quick-running chatflows.","tags":["Synchronous Execution"],"parameters":[{"name":"chatflow_id","in":"path","required":true,"description":"The unique identifier of the Chatflow to execute.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutionRequest"}}}},"responses":{"200":{"description":"The execution was successful and the final output is returned in an OpenAI-compatible format.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Execute Chatflow with Streaming (Synchronous)

> Executes the latest published version of a specific Chatflow and streams structured events in real-time using Server-Sent Events (SSE).\
> Each event is a JSON object sent in the format \`data: \<json\_object>\n\n\`. This provides a detailed, live feed of the execution progress, node by node.

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"servers":[{"url":"https://api.waterflai.ai","description":"Production Server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your secret API key."}},"schemas":{"ExecutionRequest":{"type":"object","properties":{"input_data":{"type":"object","description":"A JSON object containing the input variables for the Chatflow or Workflow. The keys should match the names of the input nodes.","additionalProperties":true}}},"StreamEvent":{"oneOf":[{"$ref":"#/components/schemas/StreamEvent_ExecutionStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeCompleted"},{"$ref":"#/components/schemas/StreamEvent_NodeSkipped"},{"$ref":"#/components/schemas/StreamEvent_NodeError"},{"$ref":"#/components/schemas/StreamEvent_ExecutionCompleted"},{"$ref":"#/components/schemas/StreamEvent_ExecutionError"}],"discriminator":{"propertyName":"type"}},"StreamEvent_ExecutionStarted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_started"]},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeStarted":{"type":"object","properties":{"type":{"type":"string","enum":["node_started"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["node_completed"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeSkipped":{"type":"object","properties":{"type":{"type":"string","enum":["node_skipped"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"reason":{"type":"string","description":"Reason why the node was skipped (e.g., Condition not met)."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeError":{"type":"object","properties":{"type":{"type":"string","enum":["node_error"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"error":{"type":"string","description":"The error message from the node."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_ExecutionCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_completed"]},"final_output":{"type":"object","additionalProperties":true,"description":"The final computed output of the entire flow."},"workflow_execution":{"$ref":"#/components/schemas/ExecutionResult"},"timestamp":{"type":"string","format":"date-time"}}},"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}},"StreamEvent_ExecutionError":{"type":"object","properties":{"type":{"type":"string","enum":["execution_error"]},"error":{"type":"string","description":"A fatal error that stopped the execution."},"timestamp":{"type":"string","format":"date-time"}}},"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}},"responses":{"UnauthorizedError":{"description":"API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/execute_chatflow/{chatflow_id}/stream_execute":{"post":{"summary":"Execute Chatflow with Streaming (Synchronous)","description":"Executes the latest published version of a specific Chatflow and streams structured events in real-time using Server-Sent Events (SSE).\nEach event is a JSON object sent in the format `data: <json_object>\\n\\n`. This provides a detailed, live feed of the execution progress, node by node.","tags":["Synchronous Execution"],"parameters":[{"name":"chatflow_id","in":"path","required":true,"description":"The unique identifier of the Chatflow to execute.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutionRequest"}}}},"responses":{"200":{"description":"A stream of structured JSON events representing the real-time execution progress and output.","content":{"text/event-stream":{"schema":{"$ref":"#/components/schemas/StreamEvent"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Execute Workflow (Synchronous)

> Executes the latest published version of a specific Workflow and waits for the complete, detailed result.\
> This is a blocking call that returns the final output and optionally the execution details of each node.

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"servers":[{"url":"https://api.waterflai.ai","description":"Production Server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your secret API key."}},"schemas":{"ExecutionRequest":{"type":"object","properties":{"input_data":{"type":"object","description":"A JSON object containing the input variables for the Chatflow or Workflow. The keys should match the names of the input nodes.","additionalProperties":true}}},"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}},"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}},"responses":{"UnauthorizedError":{"description":"API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/execute_workflow/{workflow_id}/execute":{"post":{"summary":"Execute Workflow (Synchronous)","description":"Executes the latest published version of a specific Workflow and waits for the complete, detailed result.\nThis is a blocking call that returns the final output and optionally the execution details of each node.","tags":["Synchronous Execution"],"parameters":[{"name":"workflow_id","in":"path","required":true,"description":"The unique identifier of the Workflow to execute.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutionRequest"}}}},"responses":{"200":{"description":"The execution was successful and the final output is returned as a detailed JSON object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutionResult"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```

## Execute Workflow with Streaming (Synchronous)

> Executes the latest published version of a specific Workflow and streams structured events in real-time using Server-Sent Events (SSE).\
> Each event is a JSON object sent in the format \`data: \<json\_object>\n\n\`. This provides a detailed, live feed of the workflow's progress, node by node.

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"servers":[{"url":"https://api.waterflai.ai","description":"Production Server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your secret API key."}},"schemas":{"ExecutionRequest":{"type":"object","properties":{"input_data":{"type":"object","description":"A JSON object containing the input variables for the Chatflow or Workflow. The keys should match the names of the input nodes.","additionalProperties":true}}},"StreamEvent":{"oneOf":[{"$ref":"#/components/schemas/StreamEvent_ExecutionStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeCompleted"},{"$ref":"#/components/schemas/StreamEvent_NodeSkipped"},{"$ref":"#/components/schemas/StreamEvent_NodeError"},{"$ref":"#/components/schemas/StreamEvent_ExecutionCompleted"},{"$ref":"#/components/schemas/StreamEvent_ExecutionError"}],"discriminator":{"propertyName":"type"}},"StreamEvent_ExecutionStarted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_started"]},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeStarted":{"type":"object","properties":{"type":{"type":"string","enum":["node_started"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["node_completed"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeSkipped":{"type":"object","properties":{"type":{"type":"string","enum":["node_skipped"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"reason":{"type":"string","description":"Reason why the node was skipped (e.g., Condition not met)."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeError":{"type":"object","properties":{"type":{"type":"string","enum":["node_error"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"error":{"type":"string","description":"The error message from the node."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_ExecutionCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_completed"]},"final_output":{"type":"object","additionalProperties":true,"description":"The final computed output of the entire flow."},"workflow_execution":{"$ref":"#/components/schemas/ExecutionResult"},"timestamp":{"type":"string","format":"date-time"}}},"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}},"StreamEvent_ExecutionError":{"type":"object","properties":{"type":{"type":"string","enum":["execution_error"]},"error":{"type":"string","description":"A fatal error that stopped the execution."},"timestamp":{"type":"string","format":"date-time"}}},"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}},"responses":{"UnauthorizedError":{"description":"API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/execute_workflow/{chatflow_id}/stream_execute":{"post":{"summary":"Execute Workflow with Streaming (Synchronous)","description":"Executes the latest published version of a specific Workflow and streams structured events in real-time using Server-Sent Events (SSE).\nEach event is a JSON object sent in the format `data: <json_object>\\n\\n`. This provides a detailed, live feed of the workflow's progress, node by node.","tags":["Synchronous Execution"],"parameters":[{"name":"chatflow_id","in":"path","required":true,"description":"The unique identifier of the Workflow to execute.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutionRequest"}}}},"responses":{"200":{"description":"A stream of structured JSON events representing the real-time execution progress and output.","content":{"text/event-stream":{"schema":{"$ref":"#/components/schemas/StreamEvent"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```
