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

# Create an agent run

> Start an agent run on a natural-language goal. Asynchronous — poll `GET /api/agents/runs/{id}` for status and results.

A run that hits an ambiguity **pauses** and asks a question rather than guessing; read it from `result_summary` and answer with `POST /api/agents/runs/{id}/reply` to resume the same run.

Requires the `agents` permission.



## OpenAPI

````yaml POST /api/agents/runs
openapi: 3.1.0
info:
  title: ManyPI API
  description: >-
    The REST API behind ManyPI — AI lead generation, email validation,
    cold-email outreach, agent runs and web scraping. Every endpoint is
    authenticated with a ManyPI API key (`mpi_...`) or an OAuth 2.1 access
    token, and honours the permissions granted to that credential.
  version: 2.0.0
  contact:
    name: ManyPI Support
    email: support@manypi.com
    url: https://manypi.com
servers:
  - url: https://app.manypi.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Leads
    description: Find, store, enrich and manage leads.
  - name: Email validation
    description: Verify that lead addresses can receive mail.
  - name: Outreach
    description: Inboxes, sequences, campaigns, sending and replies.
  - name: Agent
    description: Agent runs, replies and skills.
  - name: Scraping
    description: Scrapers, runs and extracted data.
  - name: Endpoints
    description: Publish scrapers as typed REST endpoints.
  - name: Account
    description: Key validation and account information.
paths:
  /api/agents/runs:
    post:
      tags:
        - Agent
      summary: Create an agent run
      description: >-
        Start an agent run on a natural-language goal. Asynchronous — poll `GET
        /api/agents/runs/{id}` for status and results.


        A run that hits an ambiguity **pauses** and asks a question rather than
        guessing; read it from `result_summary` and answer with `POST
        /api/agents/runs/{id}/reply` to resume the same run.


        Requires the `agents` permission.
      operationId: createAgentRun
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - goal
              properties:
                goal:
                  type: string
                  description: What you want ManyPI to do, in plain language.
                conversation_id:
                  type: string
                  format: uuid
                  description: Attach to an existing conversation.
                playbook:
                  type: string
                  description: A named behaviour, e.g. `lead_generation`.
                sources:
                  type: array
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - file
                          - scraper_run
                          - url
                      id:
                        type: string
                      url:
                        type: string
                output_schema:
                  type: object
                  description: A JSON schema the result must conform to.
                max_steps:
                  type: integer
                max_pages:
                  type: integer
            example:
              goal: >-
                Find the pricing pages of the ten largest Shopify agencies in
                Berlin and summarise their packages.
      responses:
        '200':
          description: The run was created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  run_id:
                    type: string
                    format: uuid
                  conversation_id:
                    type: string
                    format: uuid
                  status:
                    type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Too many runs already in flight for the plan.
components:
  responses:
    BadRequest:
      description: The request body or parameters failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >-
        Missing, invalid or expired credential — or a key that lacks the
        permission this route requires.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable message.
        code:
          type: string
          description: >-
            A machine-readable code on gated failures: `lead_limit`,
            `outreach_locked`, `validation_credits_exhausted`.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A ManyPI API key (`mpi_...`) from Settings → API keys, or an OAuth 2.1
        access token obtained through the MCP consent flow.

````