> ## 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.

# Get workflow variables

> Retrieve all variables available in a workflow, including both fixed system variables and variables discovered from execution history.

Returns two categories of variables:
- **Fixed variables**: Built-in system and context variables always available (flow_id, started_at, channel, phone_number, etc.)
- **Discovered variables**: User-defined variables observed during workflow executions, with sample values and usage statistics

Use this endpoint to:
- Understand what variables are available for use in workflow steps
- Review variable types and sample values for debugging
- Build autocomplete for variable references in workflow editors




## OpenAPI

````yaml /api/platform/v1/openapi-workflows.yaml get /workflows/{workflow_id}/variables
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:
  /workflows/{workflow_id}/variables:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Workflow identifier
    get:
      tags:
        - Workflows
      summary: Get workflow variables
      description: >
        Retrieve all variables available in a workflow, including both fixed
        system variables and variables discovered from execution history.


        Returns two categories of variables:

        - **Fixed variables**: Built-in system and context variables always
        available (flow_id, started_at, channel, phone_number, etc.)

        - **Discovered variables**: User-defined variables observed during
        workflow executions, with sample values and usage statistics


        Use this endpoint to:

        - Understand what variables are available for use in workflow steps

        - Review variable types and sample values for debugging

        - Build autocomplete for variable references in workflow editors
      operationId: getWorkflowVariables
      responses:
        '200':
          description: Variables retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowVariablesResponse'
              example:
                data:
                  fixed:
                    system:
                      system.flow_id:
                        type: string
                        description: Flow identifier
                        always_available: true
                      system.started_at:
                        type: datetime
                        description: Flow execution start time
                        always_available: true
                    context:
                      context.channel:
                        type: string
                        description: Communication channel (api or whatsapp)
                        always_available: false
                      context.phone_number:
                        type: string
                        description: Contact phone number
                        always_available: false
                  discovered:
                    system: []
                    context: []
                    vars:
                      - path: vars.user_name
                        name: user_name
                        type: string
                        sample_values:
                          - Alice
                          - Bob
                        usage_count: 42
                        last_seen_at: '2025-01-15T10:30:00.000Z'
                        reference: '{{vars.user_name}}'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  schemas:
    WorkflowVariablesResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - fixed
            - discovered
          properties:
            fixed:
              type: object
              description: Built-in variables always available in workflows
              properties:
                system:
                  type: object
                  description: System variables (flow_id, started_at, trigger_type, etc.)
                  additionalProperties:
                    type: object
                    properties:
                      type:
                        type: string
                        description: >-
                          Variable data type (string, number, datetime, array,
                          object)
                      description:
                        type: string
                        description: Human-readable description
                      always_available:
                        type: boolean
                        description: Whether this variable is always present
                context:
                  type: object
                  description: Context variables (channel, phone_number, contact, etc.)
                  additionalProperties:
                    type: object
                    properties:
                      type:
                        type: string
                      description:
                        type: string
                      always_available:
                        type: boolean
            discovered:
              type: object
              description: Variables discovered from workflow execution history
              properties:
                system:
                  type: array
                  items:
                    $ref: '#/components/schemas/DiscoveredVariable'
                context:
                  type: array
                  items:
                    $ref: '#/components/schemas/DiscoveredVariable'
                vars:
                  type: array
                  description: User-defined variables discovered during executions
                  items:
                    $ref: '#/components/schemas/DiscoveredVariable'
      description: >-
        Workflow variables including fixed system variables and discovered user
        variables
    DiscoveredVariable:
      type: object
      required:
        - path
        - name
        - type
      properties:
        path:
          type: string
          description: Full variable path (e.g., "vars.user_name", "system.flow_id")
        name:
          type: string
          description: Variable name without namespace
        type:
          type:
            - string
            - 'null'
          description: Inferred data type (string, number, boolean, object, array)
        sample_values:
          type: array
          description: Sample values observed during executions (up to 5)
          items:
            type:
              - string
              - number
              - boolean
              - object
              - 'null'
        usage_count:
          type: integer
          description: Number of times this variable has been set
        last_seen_at:
          type:
            - string
            - 'null'
          format: date-time
          description: Last time this variable was recorded
        reference:
          type: string
          description: Template reference syntax (e.g., "{{vars.user_name}}")
      description: Variable discovered from workflow execution history
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
  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

````