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

# Create an agent

> Creates an agent: a task for a phone, as instructions an agent works through a model or as code, with the model, output schema and limits its runs use. Sending instructions or code creates the agent's first revision with it; sending source_run_id saves one of your agent runs as the agent, its task or its script as the first revision. A name already used in the organization is 409; an unsupported model, an invalid output schema, both instructions and code, or a run with no task or script to save is 400; another organization's run is 404.

Minimum role required: Member


## OpenAPI

````yaml /api-reference/openapi-backend.json post /agents
openapi: 3.1.0
info:
  description: Axilio backend HTTP API.
  title: Axilio API
  version: 0.155.0
servers:
  - url: https://api.axilio.ai/api/v1
    description: Production
security: []
tags:
  - name: Agents
  - name: API Keys
  - name: Billing
  - name: Conversations
  - name: Files
  - name: Messages
  - name: Models
  - name: Organization
  - name: Phones
  - name: Runs
  - name: Sessions
  - name: Skill
  - name: Usage
  - name: Webhooks
paths:
  /agents:
    post:
      tags:
        - Agents
      summary: Create an agent
      description: >-
        Creates an agent: a task for a phone, as instructions an agent works
        through a model or as code, with the model, output schema and limits its
        runs use. Sending instructions or code creates the agent's first
        revision with it; sending source_run_id saves one of your agent runs as
        the agent, its task or its script as the first revision. A name already
        used in the organization is 409; an unsupported model, an invalid output
        schema, both instructions and code, or a run with no task or script to
        save is 400; another organization's run is 404.
      operationId: agents_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agent'
          description: Created
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Bad Request
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Forbidden
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Not Found
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Conflict
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Internal Server Error
      security:
        - apiKeyAuth: []
components:
  schemas:
    AgentCreateRequest:
      additionalProperties: false
      description: >-
        Request body for creating an agent. With instructions, code or
        source_run_id, the agent's first revision is created with it.
      properties:
        accessibility_enabled:
          description: >-
            Use accessibility mode for runs (default false). Needs your
            organization's access to accessibility mode: without it the create
            is refused with a 403 whose message starts with
            accessibility_unavailable.
          type: boolean
        capture_enabled:
          description: Capture the media runs produce into the file library (default true).
          type: boolean
        code:
          description: >-
            Python the agent runs. Creates a code revision. Leave out to add a
            revision later, or send instructions instead.
          type: string
        from:
          description: >-
            With source_run_id, what the first revision is. task (default): the
            run's task, as an instructions revision. script: the script the run
            left (GET /runs/{run_id}/script), as a code revision. A run with no
            task, or no script, is 400.
          enum:
            - task
            - script
          type: string
        instructions:
          description: >-
            The task for the agent to work through a model. Creates an
            instructions revision. Leave out to add a revision later, or send
            code instead.
          maxLength: 20000
          type: string
        max_cost_microdollars:
          description: >-
            Most a run's model steps may cost, in microdollars (default
            10000000).
          format: int64
          minimum: 1
          type: integer
        max_steps:
          description: Most model steps a run may take (default 500).
          format: int64
          maximum: 500
          minimum: 1
          type: integer
        model:
          description: >-
            The model instruction runs call, one of GET /models. Defaults to the
            platform default.
          type: string
        name:
          description: >-
            The agent's name: letters, numbers, hyphens and underscores, unique
            within the organization.
          maxLength: 100
          pattern: ^[A-Za-z0-9_-]+$
          type: string
        on_failure:
          description: >-
            With code: what a run does when a step fails. fail (default) fails
            the run. ask pauses the run for a person (reason step_check_failed),
            who retries the step or completes the run with its output. repair
            hands the run to the agent, which finishes the task from the live
            screen and proposes a fixed revision for a person to promote.
          enum:
            - fail
            - ask
            - repair
          type: string
        output_schema:
          additionalProperties: {}
          description: >-
            The JSON Schema a run's result must satisfy. Leave out to take any
            result.
          type: object
        pause_timeout_seconds:
          description: >-
            Longest a run waits paused for an answer, in seconds (default 600,
            60 to 3600).
          format: int64
          maximum: 3600
          minimum: 60
          type: integer
        recording_enabled:
          description: Record the screen of runs (default false).
          type: boolean
        source_run_id:
          description: >-
            Save one of your agent runs as the agent: its first revision comes
            from the run (see from), and the run's model, output schema and
            limits stand in for any left out here. Send it without instructions
            or code. Another organization's run is 404.
          format: uuid
          type: string
        telemetry_enabled:
          description: Emit telemetry for runs (default true).
          type: boolean
        timeout_seconds:
          description: Longest a run may take, in seconds (default 3600, at most 3600).
          format: int64
          maximum: 3600
          minimum: 1
          type: integer
      required:
        - name
      type: object
    Agent:
      additionalProperties: false
      description: >-
        An agent: a task for a phone, as instructions the agent works through a
        model or as code, with the settings its runs use.
      properties:
        accessibility_enabled:
          description: Runs use accessibility mode, which needs a phone that supports it.
          type: boolean
        capture_enabled:
          description: >-
            Runs capture the media they produce on the phone into the file
            library.
          type: boolean
        created_at:
          description: When the agent was created.
          format: date-time
          type: string
        current_revision_id:
          description: The revision runs of the agent use. Absent until the agent has one.
          format: uuid
          type: string
        id:
          description: The agent's id.
          format: uuid
          type: string
        last_run_at:
          description: When a run of the agent last started.
          format: date-time
          type: string
        max_cost_microdollars:
          description: Most a run's model steps may cost, in microdollars.
          format: int64
          type: integer
        max_steps:
          description: Most model steps a run may take.
          format: int64
          type: integer
        model:
          description: The model an instructions revision's runs call, one of GET /models.
          type: string
        name:
          description: The agent's name, unique within the organization.
          type: string
        output_schema:
          additionalProperties: {}
          description: >-
            The JSON Schema a run's result must satisfy. Absent takes any
            result.
          type: object
        pause_timeout_seconds:
          description: >-
            Longest a run waits paused for an answer, in seconds, before it
            fails with input_timeout. A pause also ends with the session.
          format: int64
          type: integer
        recording_enabled:
          description: Runs record the screen.
          type: boolean
        telemetry_enabled:
          description: Runs emit telemetry, live and stored.
          type: boolean
        timeout_seconds:
          description: Longest a run may take, in seconds, within the one-hour session cap.
          format: int64
          type: integer
        updated_at:
          description: When the agent was last changed.
          format: date-time
          type: string
      required:
        - id
        - name
        - model
        - max_steps
        - max_cost_microdollars
        - timeout_seconds
        - pause_timeout_seconds
        - recording_enabled
        - telemetry_enabled
        - capture_enabled
        - accessibility_enabled
        - created_at
        - updated_at
      type: object
    V2ErrorModel:
      additionalProperties: false
      description: >-
        Error response, following RFC 9457 (Problem Details for HTTP APIs).
        Returned with a application/problem+json content type.
      properties:
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/V2ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
      type: object
    V2ErrorDetail:
      additionalProperties: false
      description: >-
        One specific problem within an error response, locating the offending
        part of the request.
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    apiKeyAuth:
      description: Customer API key (axl_ prefix).
      in: header
      name: X-Axilio-Api-Key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.