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

# Update Agent

> Update an agent through the API-key-authenticated frontend API surface.

Updates various settings and configurations for an existing agent.

### Request

**Method:** `POST`\
**Endpoint:** `/api/update-agent`\
**Headers:**

* `X-Authorization`: Your API key (required)
* `Content-Type`: `application/json`

**Request Body:**

```json theme={null}
{
  "uid": "string",
  "agentId": "string",
  "voiceId": "string",
  "agentName": "string",
  "greetingMessage": "string",
  "humanizeConversation": boolean,
  "conversationStyle": "string",
  "orgId": "string"
}
```

**Parameters:**

* `uid` (string, required): Your user ID
* `agentId` (string, required): The ID of the agent to update
* `voiceId` (string, optional): ID of the voice to use for the agent
* `agentName` (string, optional): New name for the agent (max 50 characters)
* `greetingMessage` (string, optional): New greeting message (max 500 characters)
* `humanizeConversation` (boolean, optional): Whether to humanize the conversation
* `conversationStyle` (string, optional): Style of conversation. Must be one of: "Casual", "Humorous", "Direct", "Formal", "Persuasive", "Friendly"
* `orgId` (string, optional): Organization ID to move the agent to

### Response

**Success Response (200):**

```json theme={null}
{
  "success": true
}
```

**Error Responses:**

* `400 Bad Request`: Invalid request body, invalid voice ID, agent name too long, greeting message too long, invalid conversation style, or agent already in organization
* `401 Unauthorized`: Invalid or missing API key, or insufficient permissions
* `500 Internal Server Error`: Server error

### Example

```bash theme={null}
curl -X POST https://app.phonely.ai/api/update-agent \
  -H "X-Authorization: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "uid": "user123",
    "agentId": "agent456",
    "agentName": "Updated Agent Name",
    "greetingMessage": "Hello! How can I help you today?",
    "conversationStyle": "Friendly",
    "humanizeConversation": true
  }'
```


## OpenAPI

````yaml POST /update-agent
openapi: 3.0.1
info:
  title: Phonely API
  description: API for Phonely services including agent management and call summaries
  version: 1.0.0
servers:
  - url: https://app.phonely.ai/api
security: []
paths:
  /update-agent:
    post:
      summary: Update agent's setup
      description: Update the setup for a specific agent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgentRequest'
      responses:
        '200':
          description: Agent updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: Indicates if the update was successful
        '400':
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    UpdateAgentRequest:
      type: object
      required:
        - uid
        - agentId
      properties:
        uid:
          type: string
          description: User ID
        agentId:
          type: string
          description: Agent ID to update
        orgId:
          type: string
          description: Organization ID to update
        voiceId:
          type: string
          description: ID of the voice to assign to the agent
        agentName:
          type: string
          description: Name of the agent, limited to 50 characters
        greetingMessage:
          type: string
          description: >-
            Greeting message to be used when the agent is called, limited to 500
            characters
        humanizeConversation:
          type: boolean
          description: Add a vocal ticks such as hmm, umm etc. to your conversation.
        conversationStyle:
          type: string
          description: >-
            'Casual' | 'Humorous' | 'Direct' | 'Formal' | 'Persuasive' |
            'Friendly'
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code or identifier
        message:
          type: string
          description: Detailed error message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Authorization

````