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

# Create Agent

> Create a new voice agent and get a botId

**What it does:** Creates a new voice agent and returns a `botId`. The agent starts with dashboard defaults — you configure voice, prompt, and integrations in a follow-up [Update Agent](https://docs.gnani.ai/Platform/Update_Agent.md) call.

```text theme={null}
1. POST /v1/agents          → get botId          (this page)
2. PUT  /v1/agents/{botId}  → set prompt, voice, webhook
3. POST /v1/agents/{botId}/trigger_call → test a call
```

## Required Permission

`agents`

## Minimum working example

```bash theme={null}
curl -X POST "https://api.inya.ai/platform/v1/agents" \
  -H "x-api-key: <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "botName": "Support Agent",
    "description": "Handles inbound customer support calls.",
    "region": "asia",
    "timeZone": "Asia/Kolkata"
  }'
```

Save the `botId` from the response — you need it for every other Agents API call.

### Success (201)

```json theme={null}
{
  "status": "success",
  "message": "Agent created successfully.",
  "response": {
    "botId": "fb79920229d144608ebf665a10e50275",
    "botName": "Support Agent"
  },
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
```

## Request body

| Field | Required | Default | Description |
| - | - | - | - |
| `botName` | Yes | — | Unique name within your organization. |
| `description` | No | `""` | Short description of the agent's purpose. |
| `region` | No | `"asia"` | Deployment region — `asia`, `america`, or `europe`. See [Get Regions](https://docs.gnani.ai/Platform/Get_Regions.md). |
| `timeZone` | No | `"Asia/Kolkata"` | IANA timezone. See [Get Timezones](https://docs.gnani.ai/Platform/Get_Timezones.md). |

> [!NOTE]
>
> New agents inherit sensible defaults: barge-in enabled, TTS caching on, LLM temperature `0.5`, max tokens `300`. Override any setting via [Update Agent](https://docs.gnani.ai/Platform/Update_Agent.md).

## What to do next

| Step | Endpoint | Why |
| - | - | - |
| Configure voice and prompt | [Update Agent](https://docs.gnani.ai/Platform/Update_Agent.md) | Set ASR, LLM, TTS, system prompt, webhook |
| Validate prompt syntax | [Validate Prompt](https://docs.gnani.ai/Platform/Validate_Prompt.md) | Check Jinja2 variables before saving |
| Pick compatible ASR/TTS | [Get Transcriber Config](https://docs.gnani.ai/Platform/Get_Transcriber_Config.md) | Ensure models support your languages |
| Place a test call | [Trigger Call](https://docs.gnani.ai/Platform/Trigger_Call.md) | Requires whitelisted phone number |
| Review the call | [Get Conversation Logs](https://docs.gnani.ai/Platform/Get_Conversation_Logs.md) → [Stats](https://docs.gnani.ai/Platform/Get_Conversation_Stats.md) | Read disposition and transcript |

## Edge cases

| Scenario | What happens |
| - | - |
| Duplicate `botName` | HTTP `409` — pick a unique name |
| QA role without create permission | HTTP `403` |
| Invalid `region` or `timeZone` | HTTP `400` — validate via Config API first |

## Errors

**409 Conflict — name already taken**

```json theme={null}
{
  "status": "failure",
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "message": "An agent named 'Support Agent' already exists in your organization"
}
```

**403 Forbidden — insufficient permissions**

```json theme={null}
{
  "status": "failure",
  "requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "message": "QA role does not have permission to create/update agents"
}
```

> [!TIP]
>
> Call [Get Regions](https://docs.gnani.ai/Platform/Get_Regions.md) and [Get Timezones](https://docs.gnani.ai/Platform/Get_Timezones.md) before your first create request so you use valid values.

> [!NOTE]
>
> Save the `requestId` from every response. You will need it if you contact Gnani support to trace a specific request.


## OpenAPI

````yaml POST /v1/agents
openapi: 3.0.3
info:
  title: Platform Agents API
  description: API endpoints for creating, managing, and interacting with voice agents
  version: 2.1.0
servers:
  - url: https://api.inya.ai/platform
    description: Production server
security:
  - ApiKeyAuth: []
tags:
  - name: Agents
    description: Agent management operations
  - name: AgentFAQ
    description: Agent FAQ management
  - name: AgentCallTriggers
    description: Outbound call triggers
  - name: ChatSDK
    description: Chat Widget configuration
  - name: Conversations
    description: Conversation logs, statistics, and audio
paths:
  /v1/agents:
    post:
      tags:
        - Agents
      summary: Create a new agent
      description: >-
        Create a new voice agent. All configuration fields default to the same
        values used when creating an agent through the Agent Builder dashboard.
      operationId: createAgent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentRequest'
            examples:
              asiaAgent:
                summary: Asia region agent
                value:
                  botName: Support Agent
                  description: Handles inbound customer support calls.
                  region: asia
                  timeZone: Asia/Kolkata
      responses:
        '201':
          description: Agent created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardResponse'
              examples:
                success:
                  value:
                    status: success
                    requestId: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    message: Agent created successfully.
                    response:
                      botId: fb79920229d144608ebf665a10e50275
                      botName: Support Agent
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: Agent name already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                conflict:
                  value:
                    status: failure
                    requestId: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                    message: >-
                      An agent named 'Support Agent' already exists in your
                      organization
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    CreateAgentRequest:
      type: object
      required:
        - botName
      properties:
        botName:
          type: string
          example: Support Agent
        description:
          type: string
          example: Handles inbound customer support calls.
        region:
          type: string
          enum:
            - asia
            - america
            - europe
          default: asia
          example: asia
        timeZone:
          type: string
          default: Asia/Kolkata
          example: Asia/Kolkata
    StandardResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        requestId:
          type: string
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        message:
          type: string
        response:
          type: object
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: failure
        requestId:
          type: string
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        message:
          type: string
  responses:
    Forbidden:
      description: Permission denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key with 'agents' permission

````

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