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

# Apply agent template

> Create a new agent from a template, substituting <<variable>> placeholders with provided values.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/agent-template/{template_id}/apply
openapi: 3.1.0
info:
  title: Diga API
  version: 0.1.0
servers:
  - url: https://api.diga.io
    description: Production
security: []
paths:
  /v1/agent-template/{template_id}/apply:
    post:
      tags:
        - Agent Templates
      summary: Apply agent template
      description: >-
        Create a new agent from a template, substituting <<variable>>
        placeholders with provided values.
      operationId: apply_agent_template_v1_agent_template__template_id__apply_post
      parameters:
        - name: template_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Template Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApplyAgentTemplateRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApplyAgentTemplateResponse'
        '400':
          description: Agent Template Invalid
          content:
            application/json:
              example:
                status: error
                error_code: AGENT_TEMPLATE_INVALID
                message: Missing variable values or invalid template
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '404':
          description: Agent Template Not Found
          content:
            application/json:
              example:
                status: error
                error_code: AGENT_TEMPLATE_NOT_FOUND
                message: 'Error: Agent Template Not Found'
              schema:
                $ref: '#/components/schemas/ErrorResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - CustomHTTPBearer: []
components:
  schemas:
    ApplyAgentTemplateRequest:
      properties:
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
          description: Custom name for the created agent. Defaults to template name.
        variables:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Variables
          description: Values to replace <<variable>> placeholders in the template.
        is_draft:
          type: boolean
          title: Is Draft
          description: If true, create the agent as a draft only.
          default: true
      type: object
      title: ApplyAgentTemplateRequest
      description: Request to create an agent from a template.
    ApplyAgentTemplateResponse:
      properties:
        agent_id:
          type: string
          format: uuid
          title: Agent Id
        version_id:
          type: string
          format: uuid
          title: Version Id
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
      type: object
      required:
        - agent_id
        - version_id
      title: ApplyAgentTemplateResponse
      description: Response after applying a template to create an agent.
    ErrorResponseSchema:
      properties:
        status:
          type: string
          title: Status
          description: Status of the response, always 'error' for error responses
          default: error
        error_code:
          type: string
          title: Error Code
          description: Machine-readable error code in SCREAMING_SNAKE_CASE format
          examples:
            - PROJECT_NOT_FOUND
            - INVALID_EMAIL
            - UNAUTHORIZED_ROLE
        message:
          type: string
          title: Message
          description: Human-readable error message with details
          examples:
            - Project with id 550e8400-e29b-41d4-a716-446655440000 not found
            - The email invalid@email is not valid
            - Insufficient permissions to perform this action
      type: object
      required:
        - error_code
        - message
      title: ErrorResponseSchema
      description: Standard error response format for all API errors.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    CustomHTTPBearer:
      type: http
      scheme: bearer

````