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

# Start Agent Run

> Execute an agent with the provided input data and return results



## OpenAPI

````yaml openapi.json post /agents/{agentId}/runs
openapi: 3.1.0
info:
  title: Ag.dev API
  description: Public API for Ag.dev
  version: 0.1.0
servers:
  - url: https://api.ag.dev/v0.1
security: []
tags:
  - name: Agents
    description: Agent management and configuration
  - name: Runs
    description: Agent run execution and monitoring
  - name: Versioning
    description: Agent versioning, revisions, and publishing
  - name: MCP Servers
    description: MCP server management and tool discovery
  - name: Settings
    description: Organization settings and API keys
  - name: Users
    description: User information and authentication
  - name: Drives
    description: Drive management and file operations
  - name: Webhooks
    description: Webhook health checks
paths:
  /agents/{agentId}/runs:
    post:
      tags:
        - Runs
      summary: Start Agent Run
      description: Execute an agent with the provided input data and return results
      parameters:
        - name: agentId
          in: path
          required: true
          schema:
            type: string
            description: Agent ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Input data that matches the agent's input schema
      responses:
        '200':
          description: Run created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRun'
        '400':
          description: Invalid input data
        '401':
          description: Authentication required
        '404':
          description: Agent not found
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AgentRun:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the run
        agentId:
          type: string
          description: ID of the agent that executed this run
        input:
          type: object
          description: Input data provided for the run
        status:
          type: string
          enum:
            - pending
            - running
            - done
            - error
          description: Current status of the run
        createdAt:
          type: string
          format: date-time
          description: Run creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Run last update timestamp
        error:
          $ref: '#/components/schemas/AgentRunError'
          description: Error information (only present when status is 'error')
        resultType:
          type: string
          enum:
            - document
            - json
          nullable: true
          description: Type of result (null until run completes)
        resultData:
          oneOf:
            - $ref: '#/components/schemas/AgentRunDocumentResult'
            - type: object
              description: JSON result data (structure depends on agent's resultSchema)
          nullable: true
          description: The result data (null until run completes successfully)
      required:
        - id
        - agentId
        - input
        - status
        - createdAt
        - updatedAt
      discriminator:
        propertyName: status
        mapping:
          pending:
            $ref: '#/components/schemas/AgentRun'
          running:
            $ref: '#/components/schemas/AgentRun'
          done:
            $ref: '#/components/schemas/AgentRun'
          error:
            $ref: '#/components/schemas/AgentRun'
    AgentRunError:
      type: object
      properties:
        code:
          type: string
          description: Error code
        message:
          type: string
          description: Error message
      required:
        - code
        - message
    AgentRunDocumentResult:
      type: object
      properties:
        result:
          type: string
          description: The document result content
        sources:
          type: array
          items:
            $ref: '#/components/schemas/AgentRunSource'
          description: Sources used in the result
      required:
        - result
        - sources
    AgentRunSource:
      type: object
      properties:
        url:
          type: string
          description: Source URL
        title:
          type: string
          description: Source title (optional)
      required:
        - url
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'Provide either X-API-Key: <key> or Authorization: Bearer <key>'

````