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

# Start Agent Run



## OpenAPI

````yaml https://api.aiql.io/openapi.json post /queries/agent/runs
openapi: 3.1.0
info:
  title: aiql-api
  version: 0.1.0
servers:
  - url: https://api.aiql.io
security: []
tags:
  - name: Health
    description: Service health checks.
  - name: Workspaces
    description: Workspace management.
  - name: Ingestions
    description: Document ingestion pipeline.
  - name: Queries
    description: Natural-language queries.
  - name: Sources
    description: Ingested sources and their contents.
  - name: Requests
    description: Source addition/removal requests awaiting review.
  - name: Request Changes
    description: Individual source add/remove changes on a request.
  - name: Request Reviews
    description: Reviews of a request, including draft and submit.
  - name: Request Comments
    description: Comments on a request review.
  - name: Canvases
    description: Brainstorm canvases.
  - name: Dashboards
    description: Dashboards.
  - name: Presentations
    description: Slide presentations.
  - name: Tools
    description: Standalone convert/split/shape/extract tools.
  - name: Connectors
    description: Connector catalog and connect flows.
  - name: Connections
    description: Workspace connector connections.
paths:
  /queries/agent/runs:
    post:
      tags:
        - Queries
      summary: Start Agent Run
      operationId: start_agent_run_queries_agent_runs_post
      parameters:
        - name: AiQL-Workspace
          in: header
          required: true
          schema:
            type: string
            description: ID of the workspace the request operates on.
            title: Aiql-Workspace
          description: ID of the workspace the request operates on.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentRunCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRunResponse'
        '401':
          description: 'Authentication failed: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://api.aiql.io/queries/agent/runs \
              -H "Authorization: Bearer $AIQL_API_KEY" \
              -H "AiQL-Workspace: $AIQL_WORKSPACE_ID"
components:
  schemas:
    AgentRunCreate:
      properties:
        content:
          type: string
          title: Content
          description: >-
            Natural-language prompt for the agent turn. Empty when resuming
            deferred tools.
          default: ''
        chat_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Chat Id
          description: >-
            Chat/query id. Reused when present in this workspace; created when
            omitted or unknown.
        documentId:
          anyOf:
            - type: string
            - type: 'null'
          title: Documentid
          description: Optional document scope for the agent turn.
        interactionMode:
          type: string
          enum:
            - ask
            - reason
            - build
          title: Interactionmode
          description: 'Inquiry interaction mode: ask (Haiku), reason/build (Opus).'
          default: ask
        variant:
          type: string
          enum:
            - root
            - explore
            - canvas
            - app
            - written-document
            - presentation
            - dashboard-cards
          title: Variant
          description: Inquiry surface variant controlling available tools.
          default: root
        canvasId:
          anyOf:
            - type: string
            - type: 'null'
          title: Canvasid
          description: Bound canvas id for canvas-variant turns.
        deckId:
          anyOf:
            - type: string
            - type: 'null'
          title: Deckid
          description: Bound presentation deck id for presentation-variant turns.
        writtenDocumentId:
          anyOf:
            - type: string
            - type: 'null'
          title: Writtendocumentid
          description: Bound written document id for written-document-variant turns.
        deferredToolResults:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Deferredtoolresults
          description: Client-side tool results used to resume a deferred agent turn.
        message_history:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Message History
          description: Optional prior model/UI message history.
      type: object
      title: AgentRunCreate
    AgentRunResponse:
      properties:
        chat_id:
          type: string
          title: Chat Id
        run_id:
          type: string
          title: Run Id
        channel:
          type: string
          title: Channel
        token:
          type: string
          title: Token
        subscription_token:
          type: string
          title: Subscription Token
        ws_url:
          type: string
          title: Ws Url
        since:
          anyOf:
            - $ref: '#/components/schemas/StreamPosition'
            - type: 'null'
      type: object
      required:
        - chat_id
        - run_id
        - channel
        - token
        - subscription_token
        - ws_url
      title: AgentRunResponse
    ErrorResponse:
      type: object
      title: ErrorResponse
      properties:
        detail:
          type: string
          title: Detail
      required:
        - detail
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StreamPosition:
      properties:
        offset:
          type: integer
          title: Offset
        epoch:
          type: string
          title: Epoch
      type: object
      required:
        - offset
        - epoch
      title: StreamPosition
    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
  securitySchemes:
    HTTPBearer:
      type: http
      description: API key or UI session JWT passed as a Bearer token.
      scheme: bearer

````