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

# Preview Parent Agent State Function Context Variables

> Preview context variables for a parent agent state function without saving changes.



## OpenAPI

````yaml /api-reference/openapi.json post /api/parent_agents/{parent_agent_id}/state_function/context_variables
openapi: 3.1.0
info:
  title: Maadify API
  description: Public and admin API endpoints for Maadify.
  version: 1.0.0
servers:
  - url: https://app.maadify.com
    description: Production
security: []
tags:
  - name: Parent agents
    description: Create, update, and configure parent agents.
  - name: Sub-agents
    description: Create sub-agents and assign them to parent agents.
  - name: Tools
    description: Search tools and manage tool assignments.
  - name: Prompt templates
    description: Search and manage prompt templates.
  - name: Users
    description: Search users available to the authenticated tenant.
  - name: Models
    description: Search available LLM models.
  - name: Files
    description: Check file upload status.
paths:
  /api/parent_agents/{parent_agent_id}/state_function/context_variables:
    post:
      tags:
        - Parent agents
      summary: Preview Parent Agent State Function Context Variables
      description: >-
        Preview context variables for a parent agent state function without
        saving changes.
      operationId: >-
        preview_parent_agent_state_function_context_variables_api_parent_agents__parent_agent_id__state_function_context_variables_post
      parameters:
        - name: parent_agent_id
          in: path
          required: true
          schema:
            type: integer
            title: Parent Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StateFunctionContextVariablesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StateFunctionContextVariablesResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    StateFunctionContextVariablesRequest:
      properties:
        state_function:
          anyOf:
            - items:
                $ref: '#/components/schemas/StateFunctionRule-Input'
              type: array
            - type: 'null'
          title: State Function
          description: >-
            Draft state-function rules to inspect. When omitted, the persisted
            parent-agent rules are used.
      type: object
      title: StateFunctionContextVariablesRequest
    StateFunctionContextVariablesResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Whether the request was successful.
        error_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Type
          description: Type of error if the request failed.
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
          description: Error message or informational message.
        data:
          $ref: '#/components/schemas/StateFunctionContextVariablesData'
          description: Parent agent state-function context variables.
      type: object
      required:
        - success
        - data
      title: StateFunctionContextVariablesResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StateFunctionRule-Input:
      properties:
        actions:
          items:
            $ref: '#/components/schemas/StateAction-Input'
          type: array
          title: Actions
          description: >-
            Actions to run when the rule matches. Actions can route to an agent,
            execute a tool, request approval, or set an error.
        conditions:
          $ref: '#/components/schemas/StateConditions-Input'
          description: Workflow context checks that determine whether this rule matches.
        order:
          anyOf:
            - type: integer
            - type: 'null'
          title: Order
          description: >-
            Rule evaluation priority. Lower values run first, and runtime stops
            on the first triggered rule.
      type: object
      title: StateFunctionRule
    StateFunctionContextVariablesData:
      properties:
        context_variables:
          items:
            $ref: '#/components/schemas/StateFunctionContextVariableGroup'
          type: array
          title: Context Variables
          description: Context variables available to state-function rules.
      type: object
      title: StateFunctionContextVariablesData
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    StateAction-Input:
      properties:
        name:
          type: string
          enum:
            - select_next_agent
            - set_error
            - send_approval
            - execute_tool
          title: Name
          description: >-
            Action to run when conditions match: select_next_agent,
            execute_tool, send_approval, or set_error.
        params:
          $ref: '#/components/schemas/StateActionParams-Input'
          description: Parameters for the selected state-function action.
      type: object
      required:
        - name
      title: StateAction
    StateConditions-Input:
      properties:
        all:
          items:
            anyOf:
              - $ref: '#/components/schemas/StateCondition'
              - $ref: '#/components/schemas/ConditionGroup-Input'
          type: array
          title: All
          description: Top-level all group. Every condition or nested group must match.
        any:
          items:
            anyOf:
              - $ref: '#/components/schemas/StateCondition'
              - $ref: '#/components/schemas/ConditionGroup-Input'
          type: array
          title: Any
          description: >-
            Top-level any group. At least one condition or nested group must
            match.
      type: object
      title: StateConditions
    StateFunctionContextVariableGroup:
      properties:
        key:
          type: string
          title: Key
          description: Unique context source key.
        tool_key:
          type: string
          title: Tool Key
          description: Context source key used by tool-output references.
        tool_name:
          type: string
          title: Tool Name
          description: Source display name.
        display_name:
          type: string
          title: Display Name
          description: Human-readable source name.
        tool_id:
          type: string
          title: Tool Id
          description: Tool or source identifier.
        source_type:
          type: string
          title: Source Type
          description: >-
            Context source type, such as tool, sub_agent, runtime_input,
            trigger, or loop.
        variables:
          items:
            $ref: '#/components/schemas/StateFunctionContextVariable'
          type: array
          title: Variables
          description: Variables available from this context source.
        output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Output Schema
          description: JSON schema describing the source output.
      additionalProperties: true
      type: object
      required:
        - key
        - tool_key
        - tool_name
        - display_name
        - tool_id
        - source_type
      title: StateFunctionContextVariableGroup
    StateActionParams-Input:
      properties:
        next_agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Agent Name
          description: Sub-agent name to route to when a select_next_agent action runs.
        sub_agent_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Sub Agent Id
          description: >-
            Linked sub-agent ID to route to. Runtime resolves it to the current
            name.
        is_error:
          anyOf:
            - type: string
            - type: boolean
            - type: 'null'
          title: Is Error
          description: Marks the run as an error when a set_error action runs.
        send_approval:
          anyOf:
            - type: string
            - type: 'null'
          title: Send Approval
          description: Approval action mode or flag.
        approval_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Approval Message
          description: >-
            Message shown in Notifications and Agent activity when approval is
            requested.
        approval_message_to_send:
          anyOf:
            - type: string
            - type: 'null'
          title: Approval Message To Send
          description: Message sent after approval is granted.
        send_approval_email:
          anyOf:
            - type: string
            - type: boolean
            - type: 'null'
          title: Send Approval Email
          description: Whether to email approval users.
        approval_users:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Approval Users
          description: >-
            Approver user IDs or identifiers. Strings may be comma-separated.
            Values are normalized to user IDs when send_approval_email is true.
        agent_tool_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Agent Tool Id
          description: Base tool ID to execute.
        parent_agent_tool_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Parent Agent Tool Id
          description: Parent-agent tool instance ID to execute.
        payload:
          anyOf:
            - type: string
            - additionalProperties: true
              type: object
            - items: {}
              type: array
            - type: 'null'
          title: Payload
          description: >-
            Tool input payload. Supports JSON dict/list values and templated
            JSON strings. Dict/list input is normalized to a JSON string for
            storage.
        loop_on:
          anyOf:
            - type: string
            - type: 'null'
          title: Loop On
          description: Context variable dot-path to an array. The tool runs once per item.
        max_iterations:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Max Iterations
          description: Maximum loop iterations when loop_on is set.
        fail_on_error:
          anyOf:
            - type: string
            - type: boolean
            - type: 'null'
          title: Fail On Error
          description: Stop loop execution when a loop item fails.
        skip_conditions:
          anyOf:
            - $ref: '#/components/schemas/StateConditions-Input'
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Skip Conditions
          description: Conditions that skip an item during looped tool execution.
      additionalProperties: false
      type: object
      title: StateActionParams
    StateCondition:
      properties:
        name:
          type: string
          minLength: 1
          title: Name
          description: >-
            Condition name or selected context-variable path. Static names are
            last_agent_name, last_message_content, and last_tool_executed.
            Frontend selector categories execute_tool_content and runtime_inputs
            are saved as the selected tool-output or input path.
        value:
          title: Value
          description: Expected value used by the selected operator.
          default: ''
        operator:
          type: string
          enum:
            - equal_to
            - not_equal_to
            - starts_with
            - ends_with
            - contains
            - does_not_contain
            - non_empty
            - matches_regex
            - greater_than
            - less_than
            - greater_than_or_equal_to
            - less_than_or_equal_to
            - is_true
            - is_false
            - contains_all
            - is_contained_by
            - shares_at_least_one_element_with
            - shares_exactly_one_element_with
            - shares_no_elements_with
          title: Operator
          description: >-
            Comparison operator. Allowed values match the state-function editor
            operators, with type-specific validation applied for tool-output and
            runtime-input paths.
        type:
          anyOf:
            - type: string
              enum:
                - text
                - numeric
                - boolean
                - select
                - select_multiple
                - array
            - type: 'null'
          title: Type
          description: >-
            Value type for runtime input and tool-output paths. Array operators
            compare array length.
        agent_tool_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Agent Tool Id
          description: Tool ID used to scope a condition to output from a specific tool.
        parent_agent_tool_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Parent Agent Tool Id
          description: >-
            Tool instance ID used when the parent agent has multiple instances
            of the same tool.
        sub_agent_id:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Sub Agent Id
          description: >-
            Linked sub-agent ID. Runtime resolves this to the current sub-agent
            name so renames do not break routing.
      additionalProperties: false
      type: object
      required:
        - name
        - operator
      title: StateCondition
    ConditionGroup-Input:
      properties:
        all:
          items:
            anyOf:
              - $ref: '#/components/schemas/StateCondition'
              - $ref: '#/components/schemas/ConditionGroup-Input'
          type: array
          title: All
          description: Nested conditions that must all be true.
        any:
          items:
            anyOf:
              - $ref: '#/components/schemas/StateCondition'
              - $ref: '#/components/schemas/ConditionGroup-Input'
          type: array
          title: Any
          description: Nested conditions where at least one must be true.
      additionalProperties: false
      type: object
      title: ConditionGroup
    StateFunctionContextVariable:
      properties:
        path:
          type: string
          title: Path
          description: Path within the context source output.
          default: ''
        type:
          type: string
          title: Type
          description: Value type for the context variable.
          default: any
        description:
          type: string
          title: Description
          description: Variable description.
          default: ''
        full_var:
          type: string
          title: Full Var
          description: Jinja expression that references this context variable.
        insert_value:
          type: string
          title: Insert Value
          description: Raw path value to insert into state-function expressions.
      additionalProperties: true
      type: object
      required:
        - full_var
        - insert_value
      title: StateFunctionContextVariable
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````