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

# Create Agent By Template



## OpenAPI

````yaml POST /ext/agentbytemplate
openapi: 3.0.3
info:
  title: TruGen Developer Platform API
  version: 1.0.0
  description: OpenAPI specification for MCP endpoint
servers:
  - url: https://api.trugen.ai/v1
security: []
paths:
  /ext/agentbytemplate:
    post:
      summary: Create a new Agent from a template
      operationId: createAgentByTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                avatar_ids:
                  type: array
                  items:
                    type: string
                  description: List of avatar IDs to associate with the new agent
                template_id:
                  type: string
                  format: uuid
                  description: ID of the template to use for creating the agent
              required:
                - avatar_ids
                - template_id
            example:
              avatar_ids:
                - 1e4ea106
                - 665a1170
              template_id: 76d9ff1d-b1d5-4dee-9b9a-d4c4d58c9c55
      responses:
        '200':
          description: Agent created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: ID of the newly created agent
                  message:
                    type: string
                    description: Confirmation message
                example:
                  id: 51ed8d70-9379-422f-aed4-f9f2b293ba4a
                  message: Agent created successfully
        '400':
          description: Invalid request body
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: Invalid request body
        '401':
          description: Unauthorized – missing or invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: 'Unauthorized: not a valid authorization api key'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              example:
                error: Failed to fetch template/avatar
      security:
        - apiKeyAuth: []
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````