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

# Retrieve workflow execution

> Get complete details for a workflow execution including current status, execution context, variables, and full event history.

**This is the only endpoint that returns the full execution_context** (vars, system, context, metadata) along with the complete event history.

Use this endpoint to:
- Monitor execution progress and current step
- Debug failed executions with full event log
- Review execution variables and context
- Check error details when status is 'failed'

The response includes:
- Current status and step
- Complete event chronology (step transitions, agent actions, variable updates)
- Full execution_context with standard structure (vars, system, context, metadata)
- Error details if execution failed




## OpenAPI

````yaml /api/platform/v1/openapi-workflows.yaml get /workflow_executions/{execution_id}
openapi: 3.1.0
info:
  title: Kapso Platform API – Advanced Resources
  version: 0.1.0
  description: >
    Build WhatsApp automation workflows and serverless functions. Create
    multi-step conversation flows, inspect executions, and deploy custom logic.
servers:
  - url: https://api.kapso.ai/platform/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Workflows
    description: Create and manage conversation workflows and executions
  - name: Workflow Triggers
    description: Configure workflow triggers to automate execution
  - name: Functions
    description: Manage serverless functions, deployments, and secrets
  - name: WhatsApp Conversations
    description: Query WhatsApp conversation data and related resources
paths:
  /workflow_executions/{execution_id}:
    parameters:
      - name: execution_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Execution identifier
    get:
      tags:
        - Workflows
      summary: Retrieve workflow execution
      description: >
        Get complete details for a workflow execution including current status,
        execution context, variables, and full event history.


        **This is the only endpoint that returns the full execution_context**
        (vars, system, context, metadata) along with the complete event history.


        Use this endpoint to:

        - Monitor execution progress and current step

        - Debug failed executions with full event log

        - Review execution variables and context

        - Check error details when status is 'failed'


        The response includes:

        - Current status and step

        - Complete event chronology (step transitions, agent actions, variable
        updates)

        - Full execution_context with standard structure (vars, system, context,
        metadata)

        - Error details if execution failed
      operationId: getWorkflowExecution
      responses:
        '200':
          description: Execution details retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowExecutionResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  schemas:
    WorkflowExecutionResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/WorkflowExecutionDetail'
      description: Single workflow execution with full details
    WorkflowExecutionDetail:
      allOf:
        - $ref: '#/components/schemas/WorkflowExecution'
        - type: object
          properties:
            execution_context:
              type: object
              description: >
                Full execution context with standard structure. This is the
                exact execution context stored on the execution.
              properties:
                vars:
                  type:
                    - object
                    - 'null'
                  description: >-
                    User-defined variables set during workflow execution
                    (key-value pairs)
                  additionalProperties: true
                  example:
                    lead_id: 123
                    last_user_input:
                      button_id: 'yes'
                system:
                  type:
                    - object
                    - 'null'
                  description: >-
                    System fields including trigger_type, tracking_id, and other
                    internal metadata
                  properties:
                    trigger_type:
                      type: string
                      description: How the execution was initiated
                      example: api_call
                    tracking_id:
                      type: string
                      format: uuid
                      description: External tracking identifier for correlation
                  additionalProperties: true
                context:
                  type:
                    - object
                    - 'null'
                  description: >-
                    Contextual data about the execution environment (channel,
                    phone_number, etc.)
                  properties:
                    channel:
                      type: string
                      description: Communication channel
                      example: api
                    phone_number:
                      type: string
                      description: Phone number associated with execution
                      example: '+15551234567'
                  additionalProperties: true
                metadata:
                  type:
                    - object
                    - 'null'
                  description: Optional extra data (request details, timestamps, etc.)
                  properties:
                    request:
                      type: object
                      description: Request metadata
                      properties:
                        ip:
                          type: string
                        user_agent:
                          type: string
                        timestamp:
                          type: string
                          format: date-time
                      additionalProperties: true
                  additionalProperties: true
              additionalProperties: true
            events:
              type: array
              description: >-
                Chronological log of workflow events (step transitions, variable
                updates, agent actions)
              items:
                $ref: '#/components/schemas/WorkflowEvent'
      description: >-
        Detailed execution with full context and event history (only returned by
        show endpoint)
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
    WorkflowExecution:
      allOf:
        - $ref: '#/components/schemas/WorkflowExecutionSummary'
        - type: object
          properties:
            error_details:
              type:
                - object
                - 'null'
              description: >-
                Error information when status is 'failed' (error message, stack
                trace, step identifier)
              additionalProperties: true
      description: Base workflow execution schema
    WorkflowEvent:
      type: object
      required:
        - id
        - event_type
        - created_at
      properties:
        id:
          type: string
          format: uuid
          description: Event identifier
        event_type:
          type: string
          description: >
            Event type indicating what happened in the workflow execution.
            Common types:

            - `execution_started`, `execution_ended`, `execution_failed`:
            Execution lifecycle

            - `step_entered`, `step_completed`, `step_failed`: Step lifecycle

            - `decision_evaluating`, `decision_evaluated`: Conditional branching

            - `action_executing`, `action_performed`, `action_failed`: Action
            execution

            - `variables_set`, `variables_merged`: Variable updates

            - `wait_timeout`, `user_input_received`: Wait step events

            - `agent_iteration_started`, `agent_tool_called`,
            `agent_message_sent`: Agent step events
        direction:
          type:
            - string
            - 'null'
          description: >-
            Edge direction/label for transition events (used when moving between
            steps)
        edge_label:
          type:
            - string
            - 'null'
          description: Label of the edge taken during decision or transition events
        created_at:
          type: string
          format: date-time
          description: Event timestamp
        payload:
          type: object
          additionalProperties: true
          description: Event-specific data (varies by event_type)
        step:
          $ref: '#/components/schemas/WorkflowStepReference'
      description: Workflow execution event capturing state changes and transitions
    WorkflowExecutionSummary:
      type: object
      required:
        - id
        - status
        - started_at
        - last_event_at
      properties:
        id:
          type: string
          format: uuid
          description: Unique execution identifier
        status:
          type: string
          enum:
            - running
            - waiting
            - ended
            - failed
            - handoff
          description: |
            Execution status:
            - `running`: Currently executing workflow steps
            - `waiting`: Paused, awaiting user input or timeout
            - `ended`: Successfully completed
            - `failed`: Terminated due to error
            - `handoff`: Transferred to human agent
        started_at:
          type: string
          format: date-time
          description: Execution start timestamp
        ended_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Execution completion timestamp, null if still active
        last_event_at:
          type: string
          format: date-time
          description: Timestamp of most recent workflow event or activity
        tracking_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Optional external tracking identifier for correlating with external
            systems
        whatsapp_conversation_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Associated WhatsApp conversation identifier, links execution to its
            conversation
        workflow:
          $ref: '#/components/schemas/WorkflowMinimal'
        current_step:
          $ref: '#/components/schemas/WorkflowStepReference'
      description: Minimal execution representation for list endpoints
    WorkflowStepReference:
      type: object
      required:
        - id
        - identifier
      properties:
        id:
          type: string
          format: uuid
          description: Internal ID of the workflow step
        identifier:
          type: string
          description: >-
            Step identifier within the workflow (e.g., 'start', 'step1',
            'agent_greeting')
        stepable_type:
          type:
            - string
            - 'null'
          description: >
            Ruby class name of the step type (e.g., 'FlowAgentStep',
            'FlowActionStep', 'FlowWaitStep', 'FlowDecideStep')
        position:
          type:
            - object
            - 'null'
          description: Canvas position for visual editor
          properties:
            x:
              type: number
            'y':
              type: number
          additionalProperties: true
      additionalProperties: true
      description: Reference to a workflow step (used in execution current_step tracking)
    WorkflowMinimal:
      type: object
      required:
        - id
        - name
        - status
      properties:
        id:
          type: string
          format: uuid
          description: Workflow identifier
        name:
          type: string
          description: Workflow name
        status:
          type: string
          description: Workflow status
      description: Compact workflow reference used in execution objects
  responses:
    UnauthorizedError:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````