> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Invoke Workflow (Stream)

> Invoke a workflow with real-time streaming. Returns Server-Sent Events (SSE).

Invoke a workflow with real-time streaming via Server-Sent Events (SSE). Receive live updates as the pipeline progresses through each node on the canvas — including tool calls, agent reasoning, sub-agent triggers, and the final result.

## Path Parameters

<ParamField path="workflow_id" type="string" required>
  Workflow ID (UUID)
</ParamField>

## Query Parameters

<ParamField query="version" type="string">
  The workflow version to invoke. Defaults to the latest deployed version.
</ParamField>

## Request Body

Same as [Invoke Workflow (Sync)](/api-reference/v1/workflows/invoke-sync) — see that page for full request body documentation.

## Response

Returns a `text/event-stream` response with Server-Sent Events. Each event contains a JSON payload with task update information.

Events are sent as the workflow executes, including status changes, intermediate results, and the final `TaskFinished` event.

## Example Request

```bash theme={"dark"}
curl -N -X POST "https://api.xpander.ai/v1/workflows/<workflow-id>/invoke/stream" \
  -H "Content-Type: application/json" \
  -H "x-api-key: <your-api-key>" \
  -d '{"input": {"text": "Generate a comprehensive report"}}'
```

## Notes

* The stream ends with a `TaskFinished` event type
* Each SSE event is a `data:` line containing a JSON object
* Use `Cache-Control: no-cache` and `Connection: keep-alive` headers for best results
* Ideal for building real-time UIs that show pipeline progress across nodes


## OpenAPI

````yaml POST /v1/workflows/{workflow_id}/invoke/stream
openapi: 3.1.0
info:
  title: xpander.ai API Service
  description: |2-

        The xpander.ai API Service provides a unified REST API for managing AI agents,
        executing tasks, managing knowledge bases, and integrating with external systems.
        
        Features:
        - Agent Management: Create, update, deploy, and delete AI agents
        - Task Execution: Invoke agents with support for sync, async, and streaming modes
        - Knowledge Bases: Manage knowledge bases and documents for RAG workflows
        - Tools: Discover, connect, and attach tools (connectors, custom functions, MCP servers, sub-agents, workflows) to agents and workflows
        - MCP Integration: Model Context Protocol support for standardized AI interactions
        
        Authentication: All endpoints require authentication via either an API key (`x-api-key`) or an OAuth2 JWT (`Authorization: Bearer <jwt>`).
        
  version: '0.001'
servers:
  - url: https://api.xpander.ai
security: []
paths:
  /v1/workflows/{workflow_id}/invoke/stream:
    post:
      tags:
        - API v1
        - Workflows
        - Workflows Invocation
      summary: Invoke Workflow (Stream)
      description: >-
        Invoke a workflow with real-time streaming. Returns Server-Sent Events
        (SSE).
      operationId: Invoke_Workflow__Stream__v1_workflows__workflow_id__invoke_stream_post
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: string
            title: Workflow Id
        - name: version
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The workflow version to invoke. default = latest
            title: Version
          description: The workflow version to invoke. default = latest
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentExecutionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    AgentExecutionRequest:
      properties:
        input:
          $ref: '#/components/schemas/AgentExecutionInput-Input'
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        payload_extension:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Payload Extension
        parent_execution_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Execution Id
        worker_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Worker Id
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
        output_format:
          anyOf:
            - $ref: '#/components/schemas/OutputFormat'
            - type: 'null'
        output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Output Schema
        run_locally:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Run Locally
          default: false
        additional_context:
          anyOf:
            - type: string
            - type: 'null'
          title: Additional Context
        instructions_override:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions Override
        test_run_node_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Test Run Node Id
        expected_output:
          anyOf:
            - type: string
            - type: 'null'
          title: Expected Output
        events_streaming:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Events Streaming
          default: false
        mcp_servers:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Mcp Servers
          default: []
        triggering_agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Triggering Agent Id
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
        think_mode:
          anyOf:
            - $ref: '#/components/schemas/ThinkMode'
            - type: 'null'
          default: default
        disable_attachment_injection:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Disable Attachment Injection
          default: false
        user_tokens:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: User Tokens
        user_oidc_token:
          anyOf:
            - type: string
            - type: 'null'
          title: User Oidc Token
        return_metrics:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Return Metrics
          default: false
        llm_model_provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Llm Model Provider
          description: >-
            Per-execution override for the LLM provider (e.g. 'openai',
            'anthropic'). Falls back to the agent's configured provider when
            unset.
        llm_model_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Llm Model Name
          description: >-
            Per-execution override for the LLM model name. Falls back to the
            agent's configured model when unset.
        llm_reasoning_effort:
          anyOf:
            - $ref: '#/components/schemas/LLMReasoningEffort'
            - type: 'null'
          description: >-
            Per-execution override for reasoning effort on reasoning-capable
            models.
        source_node_type:
          anyOf:
            - $ref: '#/components/schemas/SourceNodeType'
            - type: 'null'
          description: >-
            Surface that created this execution (mirrored to
            AgentExecutionHistory.source_node_type). Falls back to
            SourceNodeType.SDK at persist time when unset.
      type: object
      required:
        - input
      title: AgentExecutionRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentExecutionInput-Input:
      properties:
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
          default: ''
        files:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Files
          default: []
        user:
          anyOf:
            - $ref: '#/components/schemas/User-Input'
            - type: 'null'
      type: object
      title: AgentExecutionInput
    OutputFormat:
      type: string
      enum:
        - text
        - markdown
        - json
        - voice
      title: OutputFormat
    ThinkMode:
      type: string
      enum:
        - default
        - harder
      title: ThinkMode
    LLMReasoningEffort:
      type: string
      enum:
        - low
        - medium
        - high
        - xhigh
      title: LLMReasoningEffort
    SourceNodeType:
      type: string
      enum:
        - workbench
        - sdk
        - task
        - assistant
        - webhook
        - mcp
        - a2a
        - telegram
        - slack
      title: SourceNodeType
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    User-Input:
      properties:
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        first_name:
          anyOf:
            - type: string
            - type: 'null'
          title: First Name
        last_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Name
        email:
          type: string
          title: Email
        additional_attributes:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Additional Attributes
        role:
          anyOf:
            - type: string
            - type: 'null'
          title: Role
          default: member
        is_super_admin:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Is Super Admin
          default: false
        timezone:
          anyOf:
            - type: string
            - type: 'null'
          title: Timezone
      type: object
      required:
        - email
      title: User
      description: |-
        Represents the details of a user.

        Attributes:
            id (Optional[str]): The unique identifier of the user. Defaults to None.
            first_name (Optional[str]): The first name of the user. Defaults to None.
            last_name (Optional[str]): The last name of the user. Defaults to None.
            email (str): The email address of the user. This field is required.
            additional_attributes (Optional[dict]): Possible additional parameters for the assistant's service.
            role (Optional[str]): The user's role in the organization. Defaults to "member".
            is_super_admin (Optional[bool]): Whether the user is a super admin. Defaults to False.
            timezone (Optional[str]): The user's timezone in IANA format (e.g. "America/New_York"). Defaults to None.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````