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

# Create agent

> Create a new agent in the caller's workspace. All fields are optional — if
omitted, the server picks an `Untitled Agent N` name and applies the default
config (default-enabled tools, empty prompt). The created agent is published
as version 1 and ready to run immediately.




## OpenAPI

````yaml POST /api/v1/agents
openapi: 3.1.0
info:
  title: Nanonets Agents Platform — Public API
  version: 1.0.0
  summary: >-
    Programmatically run AI agents, send follow-up messages, fetch results, and
    update agent prompts.
  description: >
    The Nanonets Agents Platform Public API lets you trigger agents, stream task
    progress,

    and integrate agent outputs into your own systems.


    ## Authentication


    All requests must include a workspace API key as a Bearer token:


    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    Workspace API keys are minted from the web app under **Settings → API
    Keys**. Each key

    is scoped to a single workspace; requests against agents or tasks outside
    that workspace

    return `403`.


    ## Lifecycle


    A typical integration is three calls:


    1. `POST /v1/agents/{agent_id}/run` — start a task. Returns a `task_id`
    immediately.

    2. Poll `GET /v1/tasks/{task_id}` until `status` is a terminal value
    (`completed`,
       `failed`, or `stopped`), **or** wait until it reaches `waiting_for_input` to
       respond with `POST /v1/tasks/{task_id}/message`.
    3. `GET /v1/tasks/{task_id}/summary` for the final answer, or `/result` for
    the full
       reasoning trace.

    ## Errors


    Every error response is `{"error": "<human-readable message>"}`. The HTTP
    status

    indicates the class:


    | Status | Meaning |

    |--------|---------|

    | 400 | Malformed request (bad UUID, missing required field, file too large)
    |

    | 401 | Missing or invalid API key |

    | 403 | API key is valid but the agent/task belongs to a different workspace
    |

    | 404 | Agent or task not found |

    | 500 | Server error — safe to retry with backoff |
  contact:
    name: Nanonets Support
    url: https://nanonets.com/support
  license:
    name: Proprietary
servers:
  - url: https://agents.nanonets.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Agents
    description: Manage agents — create, list, update, run, and version.
  - name: Tasks
    description: >-
      Inspect task status, fetch results, list and cancel tasks, and send
      follow-up messages.
paths:
  /api/v1/agents:
    post:
      tags:
        - Agents
      summary: Create an agent
      description: >
        Create a new agent in the caller's workspace. All fields are optional —
        if

        omitted, the server picks an `Untitled Agent N` name and applies the
        default

        config (default-enabled tools, empty prompt). The created agent is
        published

        as version 1 and ready to run immediately.
      operationId: createAgent
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentRequest'
            examples:
              minimal:
                summary: Minimal — auto-named, default config
                value: {}
              named:
                summary: With a name and system prompt
                value:
                  name: Invoice extractor
                  system_prompt: Extract line items from invoices and return JSON.
      responses:
        '201':
          description: Agent created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: An agent with the same name already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    CreateAgentRequest:
      type: object
      description: |
        All fields are optional. Omitted fields fall back to server defaults:
        `name` → "Untitled Agent N", `config` → default-enabled tools.
      properties:
        name:
          type: string
          description: Display name. Must be unique within the workspace.
        system_prompt:
          type: string
          description: >-
            Convenience field — written into `config.system_prompt`. Ignored if
            `config.system_prompt` is also provided.
        config:
          type: object
          additionalProperties: true
          description: Full configuration object. See `Agent.config` for known keys.
    Agent:
      type: object
      description: Full agent representation.
      required:
        - id
        - agent_group_id
        - version_number
        - status
        - name
        - config
        - is_active
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: ID of this specific version of the agent.
        agent_group_id:
          type: string
          format: uuid
          description: >
            Stable identifier across all versions of this agent. Use this when
            you

            need to refer to "the agent" as a logical entity rather than a
            specific

            version.
        version_number:
          type: integer
          description: Sequential version number (1, 2, 3 …) within this agent group.
        status:
          $ref: '#/components/schemas/AgentStatus'
        name:
          type: string
        config:
          description: >
            Full agent configuration object. Free-form JSON — common keys
            include

            `system_prompt`, `tools`, `states`, `milestones`, `model`. Treat
            unknown

            keys as opaque.
          type: object
          additionalProperties: true
        is_active:
          type: boolean
          description: >-
            Whether this agent can be run. Inactive agents reject runs with
            `403`.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
          examples:
            - Invalid agent_id format
    AgentStatus:
      type: string
      description: |
        Lifecycle status of an agent version.

        - `draft` — work-in-progress, not yet runnable for end users
        - `published` — live, runnable
        - `archived` — superseded by a newer version
      enum:
        - draft
        - published
        - archived
  responses:
    BadRequest:
      description: >-
        Malformed request — invalid UUID, missing required field, or oversized
        file.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Unexpected server error. Safe to retry with exponential backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Workspace API key issued from the web app. Pass as
        `Authorization: Bearer YOUR_API_KEY`.

````