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

# Create an agent

> Creates an agent identity owned by your Account. The handle must start
with your Account's handle prefix followed by a hyphen. An owner or
admin claims the prefix once, permanently, under **Agents** in the
dashboard. Read it with
[Retrieve your agent handle prefix](/api-reference/agents/retrieve-your-agent-handle-prefix).

The response is the identity. It contains no key: agent keys are
issued in the dashboard, and the agent acts for a business only after
that business approves an
agent grant request.




## OpenAPI

````yaml /openapi/agents.yaml post /agents
openapi: 3.0.3
info:
  title: Ionic Agents API
  version: '2026-11-05'
  description: |
    Create and manage your platform's agent identities from your server.

    These endpoints use a platform secret key with `agents:read` or
    `agents:write`, sent without `Ionic-Account`. The Account that owns the key
    owns each agent it creates. An agent identity carries no access to any
    business: a business allows an agent through an
    agent grant request, and agent keys
    are issued in the Ionic dashboard.
servers:
  - url: '{baseUrl}/v1'
    variables:
      baseUrl:
        default: https://api.ionicfi.com
        description: API base URL for your environment.
security:
  - secretKey: []
tags:
  - name: Agents
    description: Create and manage your platform's agent identities.
paths:
  /agents:
    post:
      tags:
        - Agents
      summary: Create an agent
      description: >
        Creates an agent identity owned by your Account. The handle must start

        with your Account's handle prefix followed by a hyphen. An owner or

        admin claims the prefix once, permanently, under **Agents** in the

        dashboard. Read it with

        [Retrieve your agent handle
        prefix](/api-reference/agents/retrieve-your-agent-handle-prefix).


        The response is the identity. It contains no key: agent keys are

        issued in the dashboard, and the agent acts for a business only after

        that business approves an

        agent grant request.
      operationId: createAgent
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentRequest'
            example:
              name: Booking assistant
              handle: acme-booking
              description: Books visits for front-desk staff.
              metadata:
                team: front-desk
      responses:
        '201':
          description: The new agent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agent'
        '400':
          description: >-
            `INVALID_REQUEST` for a malformed body or an unknown field.
            `AGENT_HANDLE_OUTSIDE_PREFIX` for a handle that does not start with
            your prefix. `IDEMPOTENCY_KEY_REQUIRED` without one
            `Idempotency-Key` header, and `IDEMPOTENCY_KEY_TOO_LONG` for a key
            over 255 characters. `ACCOUNT_CONTEXT_NOT_SUPPORTED` when the
            request sends `Ionic-Account`. `MIXED_AUTHENTICATION` when a
            dashboard session cookie accompanies the key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: >-
            `AGENT_HANDLE_PREFIX_REQUIRED` until your Account claims a handle
            prefix. `AGENT_HANDLE_TAKEN` for a handle already in use.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          $ref: '#/components/responses/RequestTooLarge'
        '422':
          $ref: '#/components/responses/IdempotencyBodyMismatch'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/Unavailable'
      security:
        - secretKey:
            - agents:write
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: |
        A unique key for this change. To retry, send the same key with the
        same body bytes. Ionic keeps successful results for at least 24 hours
        and checks the key's current access before returning one.
      schema:
        type: string
        minLength: 1
        maxLength: 255
  schemas:
    CreateAgentRequest:
      type: object
      additionalProperties: false
      required:
        - name
        - handle
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
          description: The agent's display name.
        handle:
          type: string
          description: >-
            Your prefix, a hyphen, and a name, for example `acme-booking`. The
            response adds a leading `@`. The handle cannot change.
        description:
          type: string
          maxLength: 2000
          description: What the agent does.
        metadata:
          type: object
          maxProperties: 50
          additionalProperties:
            type: string
          description: >-
            Up to 50 string entries for your own use. Keys are 1 to 40 bytes and
            values at most 500 bytes.
        avatar_hue:
          type: integer
          nullable: true
          minimum: 0
          maximum: 359
          description: >-
            Hue of the agent's tile, from 0 to 359. Omit it or send `null` to
            use the color derived from the handle.
    Agent:
      type: object
      description: An agent identity your Account owns.
      example:
        id: agt_3Wd9Kp2Lm7Xq4R
        object: agent
        owner_account_id: mer_9Jt4Wx8Qn2Lp6V
        name: Booking assistant
        handle: '@acme-booking'
        description: Books visits for front-desk staff.
        metadata:
          team: front-desk
        avatar_hue: null
        status: active
        version: 1
        created_by: sk_4Rt8Lm2Qx7Vn3Kp9Wd5Hs1Bz
        created_at: 1793782800
        updated_at: 1793782800
        last_active_at: null
      required:
        - id
        - object
        - owner_account_id
        - name
        - handle
        - description
        - metadata
        - avatar_hue
        - status
        - version
        - created_by
        - created_at
        - updated_at
        - last_active_at
      properties:
        id:
          type: string
          pattern: ^agt_[0-9A-Za-z]{14}$
          description: Unique identifier for the agent.
        object:
          type: string
          enum:
            - agent
        owner_account_id:
          type: string
          pattern: ^mer_[0-9A-Za-z]{14}$
          description: The Account that owns the agent.
        name:
          type: string
          minLength: 1
          maxLength: 120
          description: The agent's display name.
        handle:
          type: string
          description: >-
            The agent's permanent handle, with a leading `@`, for example
            `@acme-booking`.
        description:
          type: string
          maxLength: 2000
          description: What the agent does. An empty string when not set.
        metadata:
          type: object
          maxProperties: 50
          additionalProperties:
            type: string
          description: >-
            Up to 50 string entries for your own use. Keys are 1 to 40 bytes and
            values at most 500 bytes.
        avatar_hue:
          type: integer
          nullable: true
          minimum: 0
          maximum: 359
          description: >-
            Hue of the agent's tile, from 0 to 359. `null` uses the color
            derived from the handle.
        status:
          type: string
          enum:
            - active
            - suspended
            - deactivated
          description: >-
            `active` agents can act where a business allows them. `suspended`
            agents are paused by you or by Ionic. `deactivated` is permanent.
        version:
          type: integer
          minimum: 1
          description: >-
            Increases with each change to the identity. Send it as
            `expected_version` when you change the agent. Agent activity does
            not change it.
        created_by:
          type: string
          pattern: ^(user_.+|sk_[0-9A-Za-z]{24})$
          description: >-
            Who created the agent. The ID of the secret key (`sk_…`) for an
            agent created through the API, or the dashboard user (`user_…`).
            Never contains a key's secret.
        created_at:
          type: integer
          format: int64
          description: Unix timestamp when the agent was created.
        updated_at:
          type: integer
          format: int64
          description: Unix timestamp of the last change to the identity.
        last_active_at:
          type: integer
          format: int64
          nullable: true
          description: >-
            Unix timestamp of the agent's most recent activity, or `null` before
            any.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          description: Details about the error.
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        `PLATFORM_CREDENTIAL_REQUIRED` for a key that is not a platform secret
        key. `AGENT_MANAGEMENT_FORBIDDEN` when the key lacks this operation's
        permission, your Account is not active, or your Platform Program does
        not allow delegated API access with this permission in the key's mode.
        `AGENT_OPERATION_UNAVAILABLE` for an agent's own key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RequestTooLarge:
      description: '`REQUEST_TOO_LARGE` for a body over 64 KiB.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    IdempotencyBodyMismatch:
      description: >-
        `IDEMPOTENCY_BODY_MISMATCH` when an `Idempotency-Key` is reused with a
        different body. Any byte difference, including whitespace, counts.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: >-
        `AGENT_MANAGEMENT_UNAVAILABLE` when Ionic cannot check your key's
        current access. Retry later. For a change, retry with the same
        `Idempotency-Key` and body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: 'A platform secret key (`sk_…`) sent as `Authorization: Bearer <key>`.'

````

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