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

# Create Agent

> Create a new voice AI agent with system instructions and voice configuration.



## OpenAPI

````yaml /api-reference/openapi.json post /agents
openapi: 3.1.0
info:
  title: Truedy API
  description: >-
    Truedy Public API - Build voice AI agents and make automated phone calls.


    ## Authentication

    All requests require **Authorization: Bearer <your_api_key>**.

    Get your API key from the [Truedy Dashboard](https://app.truedy.ai).


    ## Response Format

    All successful responses follow this format:

    ```json

    {
      "data": { /* resource or list of resources */ },
      "meta": {
        "request_id": "req_xxx",
        "ts": "2026-03-03T20:30:21.310278Z"
      },
      "pagination": { /* optional, for list endpoints */ }
    }

    ```


    ## Error Handling

    Errors return appropriate HTTP status codes with structured error messages.
    Always check the `error` field in the response body for details.
  version: 1.0.0
servers:
  - url: https://api.truedy.ai/api/public/v1
    description: Truedy Public API
security:
  - BearerAuth: []
paths:
  /agents:
    post:
      tags:
        - Agents
      summary: Create Agent
      description: >-
        Create a new voice AI agent with system instructions and voice
        configuration.
      operationId: create_agent
      parameters:
        - name: X-Idempotency-Key
          in: header
          required: false
          description: Optional idempotency key for safe retries
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentCreateRequest'
            examples:
              basic:
                summary: Basic agent creation
                value:
                  name: Customer Support Agent
                  voice_id: voice_c7d82fec
                  system_prompt: >-
                    You are a helpful customer support agent. Be friendly and
                    professional. Ask how you can help the customer today.
              advanced:
                summary: Agent with advanced settings
                value:
                  name: Sales Agent
                  description: Proactive sales agent for product demos
                  voice_id: voice_c7d82fec
                  system_prompt: >-
                    You are a sales agent. Your goal is to understand customer
                    needs and present relevant solutions.
                  greeting: >-
                    Hi! Thanks for calling. I'd like to help you find the
                    perfect product.
                  temperature: 0.8
                  language_hint: en-US
                  recording_enabled: true
                  max_duration: 3600s
                  join_timeout: 45s
      responses:
        '201':
          description: Agent created successfully
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - meta
                properties:
                  data:
                    $ref: '#/components/schemas/AgentResponse'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
              examples:
                success:
                  value:
                    data:
                      id: agt_f9447372
                      name: Customer Support Agent
                      description: AI-powered customer support
                      status: active
                      voice_id: voice_c7d82fec
                      voice_name: Sarah
                      system_prompt: You are a helpful customer support agent.
                      model: ultravox-v0.7
                      tools: []
                      knowledge_bases: []
                      temperature: 0.7
                      created_at: '2026-03-03T20:30:21.310278Z'
                      updated_at: '2026-03-03T20:30:21.310278Z'
                    meta:
                      request_id: req_32e7531c-8
                      ts: '2026-03-03T20:30:21.310278Z'
              example:
                data:
                  id: agt_f9447372
                  name: Customer Support Agent
                  description: Handles inbound support inquiries
                  status: active
                  model: ultravox-v0.7
                  voice_id: voice_c7d82fec
                  voice_name: Sarah
                  system_prompt: >-
                    You are a helpful customer support agent. Be friendly and
                    professional.
                  greeting: Hello! Thanks for calling. How can I help you today?
                  inactivity_message: Are you still there? Take your time.
                  inactivity_timeout: 30
                  max_duration: 1800
                  tools:
                    - tool_p1q2r3s4
                  knowledge_base_ids:
                    - kb_x9y8z7w6
                  created_at: '2026-03-15T09:00:00Z'
                  updated_at: '2026-04-01T14:30:00Z'
                meta:
                  request_id: req_32e7531c
                  ts: '2026-04-05T10:22:00Z'
        '400':
          description: Bad request - Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
              examples:
                error:
                  value:
                    detail:
                      - loc:
                          - body
                          - name
                        msg: field required
                        type: value_error.missing
                      - loc:
                          - body
                          - voice_id
                        msg: voice_id does not exist
                        type: value_error
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AgentCreateRequest:
      type: object
      required:
        - name
        - voice_id
        - system_prompt
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
          description: Display name for the agent
          example: Customer Support Agent
        description:
          maxLength: 1000
          description: Optional description of the agent's purpose
          example: AI-powered customer support agent for handling inquiries
          type:
            - string
            - 'null'
        voice_id:
          type: string
          description: ID of the voice to use (get available voices from GET /voices)
          example: voice_c7d82fec
        system_prompt:
          type: string
          minLength: 1
          description: Instructions for how the agent should behave during calls
          example: >-
            You are a helpful customer support agent. Be friendly and
            professional. Ask how you can help.
        greeting:
          description: Optional custom greeting message
          example: Hello! Thank you for calling. How can I help you today?
          type:
            - string
            - 'null'
        temperature:
          minimum: 0
          maximum: 1
          description: 'LLM temperature (0=deterministic, 1=creative). Default: 0.7'
          example: 0.7
          type:
            - number
            - 'null'
        language_hint:
          description: BCP47 language code (e.g., en-US, es-ES, fr-FR)
          example: en-US
          type:
            - string
            - 'null'
        recording_enabled:
          description: 'Enable call recording. Default: true'
          example: true
          type:
            - boolean
            - 'null'
        max_duration:
          description: Maximum call duration (e.g., 3600s for 1 hour)
          example: 3600s
          type:
            - string
            - 'null'
        join_timeout:
          description: Timeout for callee to answer (e.g., 30s)
          example: 30s
          type:
            - string
            - 'null'
    AgentResponse:
      type: object
      required:
        - id
        - name
        - voice_id
        - status
        - model
        - created_at
        - updated_at
      properties:
        id:
          type: string
          description: Unique agent identifier
          example: agt_f9447372
        name:
          type: string
          description: Display name of the agent
          example: Customer Support Agent
        description:
          description: Optional description of the agent's purpose
          example: Handles customer inquiries and support requests
          type:
            - string
            - 'null'
        voice_id:
          type: string
          description: ID of the voice used for this agent
          example: voice_c7d82fec
        voice_name:
          description: Resolved voice display name
          example: Sarah
          type:
            - string
            - 'null'
        system_prompt:
          description: System prompt defining agent behavior and personality
          example: >-
            You are a helpful customer support agent. Be friendly and
            professional.
          type:
            - string
            - 'null'
        model:
          type: string
          description: AI model identifier
          example: ultravox-v0.7
        tools:
          type: array
          items:
            type: string
          description: List of tool IDs attached to the agent
          example:
            - tool_abc123
            - tool_def456
        knowledge_bases:
          type: array
          items:
            type: string
          description: List of knowledge base IDs attached to the agent
          example:
            - kb_xyz789
        status:
          type: string
          enum:
            - active
            - draft
          description: Agent status
          example: active
        temperature:
          minimum: 0
          maximum: 1
          description: LLM temperature controlling randomness (0=deterministic, 1=creative)
          example: 0.7
          type:
            - number
            - 'null'
        language_hint:
          description: BCP47 language code for speech recognition
          example: en-US
          type:
            - string
            - 'null'
        recording_enabled:
          description: Whether call recording is enabled
          example: true
          type:
            - boolean
            - 'null'
        join_timeout:
          description: Timeout for the callee to answer (e.g., 30s)
          example: 30s
          type:
            - string
            - 'null'
        max_duration:
          description: Maximum call duration (e.g., 3600s for 1 hour)
          example: 3600s
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
          description: When the agent was created
          example: '2026-03-03T20:30:21.310278Z'
        updated_at:
          type: string
          format: date-time
          description: When the agent was last updated
          example: '2026-03-03T20:30:21.310278Z'
    ResponseMeta:
      type: object
      required:
        - request_id
        - ts
      properties:
        request_id:
          type: string
          description: Unique request identifier for debugging and support
          example: req_32e7531c-8
        ts:
          type: string
          format: date-time
          description: Server timestamp when the response was generated
          example: '2026-03-03T20:30:21.310278Z'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Error code
              example: not_found
            message:
              type: string
              description: Human-readable error message
              example: The requested resource does not exist
            details:
              description: Additional error context
              example:
                resource: agent
                id: agt_invalid
              type:
                - object
                - 'null'
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            properties:
              loc:
                type: array
              msg:
                type: string
              type:
                type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Include your API key in the Authorization
        header: Bearer <your_api_key>

````