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

# Add sub-agent

> **Auth:** organization API key with `write` scope, or a signed-in user.

`{"kind": "inline", "name", "description"}` adds a step inside the agent; `{"kind": "linked", "agent_id"}` lets the agent call another agent of the organization (not itself, not a hybrid one). At most 50 inline and 200 linked sub-agents per agent.



## OpenAPI

````yaml https://cp.xenovia.io/openapi.json post /api/v1/agents/{agent_id}/sub-agents
openapi: 3.1.0
info:
  title: Xenovia Control Plane API
  version: 1.0.0
  description: >-
    Management API for agents, providers, policies, telemetry, alerts and
    organization settings.
servers:
  - url: https://cp.xenovia.io
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v1/agents/{agent_id}/sub-agents:
    post:
      tags:
        - agents
      summary: Add sub-agent
      description: >-
        **Auth:** organization API key with `write` scope, or a signed-in user.


        `{"kind": "inline", "name", "description"}` adds a step inside the
        agent; `{"kind": "linked", "agent_id"}` lets the agent call another
        agent of the organization (not itself, not a hybrid one). At most 50
        inline and 200 linked sub-agents per agent.
      operationId: create_sub_agent_route_api_v1_agents__agent_id__sub_agents_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Agent Id
        - name: X-Request-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Request-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/InlineSubAgentCreate'
                - $ref: '#/components/schemas/LinkedSubAgentCreate'
              discriminator:
                propertyName: kind
                mapping:
                  inline: '#/components/schemas/InlineSubAgentCreate'
                  linked: '#/components/schemas/LinkedSubAgentCreate'
              title: Payload
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/InlineSubAgentRead'
                  - $ref: '#/components/schemas/LinkedSubAgentRead'
                title: >-
                  Response Create Sub Agent Route Api V1 Agents  Agent Id  Sub
                  Agents Post
        '422':
          description: >-
            Refused (`detail.code`): `invalid_name`, `duplicate_name`,
            `not_found` (no agent of this organisation has the id), `self`,
            `hybrid`, `duplicate_link`, `limit`, `not_inline`
components:
  schemas:
    InlineSubAgentCreate:
      properties:
        kind:
          type: string
          const: inline
          title: Kind
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
              maxLength: 500
            - type: 'null'
          title: Description
      additionalProperties: false
      type: object
      required:
        - kind
        - name
      title: InlineSubAgentCreate
    LinkedSubAgentCreate:
      properties:
        kind:
          type: string
          const: linked
          title: Kind
        agent_id:
          type: string
          format: uuid
          title: Agent Id
      additionalProperties: false
      type: object
      required:
        - kind
        - agent_id
      title: LinkedSubAgentCreate
    InlineSubAgentRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        kind:
          type: string
          const: inline
          title: Kind
          default: inline
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        created_at:
          type: string
          format: date-time
          title: Created At
        checks_count:
          type: integer
          title: Checks Count
          default: 0
        capabilities_count:
          type: integer
          title: Capabilities Count
          default: 0
        keys_count:
          type: integer
          title: Keys Count
          default: 0
      type: object
      required:
        - id
        - name
        - description
        - created_at
      title: InlineSubAgentRead
    LinkedSubAgentRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        kind:
          type: string
          const: linked
          title: Kind
          default: linked
        agent_id:
          type: string
          format: uuid
          title: Agent Id
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
        agent_status:
          $ref: '#/components/schemas/AgentStatus'
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - agent_id
        - agent_name
        - agent_status
        - created_at
      title: LinkedSubAgentRead
    AgentStatus:
      type: string
      enum:
        - draft
        - active
      title: AgentStatus
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token: an organization API key (`ak_…`) created under Settings →
        API Keys, or a dashboard user session token. Agent keys (`xe_…`) are not
        accepted here. Endpoints marked as user-only in their description reject
        organization keys with `403`.

````

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