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

# Start a new agent execution

> Triggers a new execution of the specified agent



## OpenAPI

````yaml api/legacy/openapi-agents.yaml post /agents/{agent_id}/executions
openapi: 3.0.3
info:
  title: Kapso External API - Agents & Flows API
  description: >-
    API for programmatically interacting with Kapso agents, executions, and
    WhatsApp conversations. This specification includes only Agents & Flows API
    endpoints.
  version: 1.0.0
  contact:
    name: Kapso Support
servers:
  - url: https://app.kapso.ai/api/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /agents/{agent_id}/executions:
    post:
      tags:
        - Agent Executions
      summary: Start a new agent execution
      description: Triggers a new execution of the specified agent
      operationId: startAgentExecution
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  oneOf:
                    - type: string
                      description: >-
                        Legacy format - Initial message to send to the agent
                        (string)
                      example: I need help with my order
                    - type: object
                      description: Structured message to send to the agent
                      properties:
                        type:
                          type: string
                          enum:
                            - user_input
                            - payload
                          description: The type of message to send
                          example: user_input
                        content:
                          type: object
                          description: The content of the message
                          properties:
                            text:
                              type: string
                              description: The text content (for user_input type)
                              example: I need help with my order
                          additionalProperties: true
                phone_number:
                  type: string
                  description: WhatsApp phone number to associate with this execution
                  example: '+1234567890'
                whatsapp_config_id:
                  type: string
                  format: uuid
                  description: >-
                    Optional specific WhatsApp configuration to use for this
                    execution
                  example: config-123abc
      responses:
        '202':
          description: Execution accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/AgentExecution'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AgentExecution:
      type: object
      properties:
        id:
          type: string
          example: execution-789ghi
        agent_id:
          type: string
          example: agent-123abc
        thread_id:
          type: string
          example: thread-101jkl
        status:
          type: string
          enum:
            - started
            - running
            - paused
            - ended
            - handoff
          example: running
        started_at:
          type: string
          format: date-time
        ended_at:
          type: string
          format: date-time
          nullable: true
        duration:
          type: integer
          description: Duration in seconds
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          example: Resource not found
        status:
          type: integer
          example: 404
        message:
          type: string
          example: The requested resource could not be found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key required for all endpoints

````