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

# Update AI Agent

> Updates an AI agent. Supported fields: `name`, `description`, `roles`, and `vectorStore.required`. Changed roles regenerate their OpenAI function tools.

**Field length limits** (same as the Pingmee app; exceeding them returns `400`):

| Field | Max length |
| --- | --- |
| `description` | 5000 |
| `roles[].name` | 40 |
| `roles[].description` | 1500 |
| `roles[].instructions` | 1500 |
| `roles[].webhook` | 300 |

<Note>
  Call this endpoint on the AI service: `https://ai.pingmee.co.il`.
</Note>

You can update `name`, `description`, `roles`, and `vectorStore.required`. When a role changes, its OpenAI function tool is regenerated automatically.

## Field length limits

These match the Pingmee app. Requests that exceed them return `400`.

| Field                  | Max length |
| ---------------------- | ---------- |
| `description`          | 5000       |
| `roles[].name`         | 40         |
| `roles[].description`  | 1500       |
| `roles[].instructions` | 1500       |
| `roles[].webhook`      | 300        |


## OpenAPI

````yaml PUT /ai-agents/{id}
openapi: 3.1.0
info:
  title: Pingmee API
  description: A complete guide to Pingmee micro service architecture.
  version: 1.0.0
servers:
  - url: https://api.pingmee.co.il
security:
  - cookieAuth: []
    ApiKeyAuth: []
paths:
  /ai-agents/{id}:
    servers:
      - url: https://ai.pingmee.co.il
        description: AI service
    put:
      summary: Update AI agent
      description: >-
        Updates an AI agent. Supported fields: `name`, `description`, `roles`,
        and `vectorStore.required`. Changed roles regenerate their OpenAI
        function tools.


        **Field length limits** (same as the Pingmee app; exceeding them returns
        `400`):


        | Field | Max length |

        | --- | --- |

        | `description` | 5000 |

        | `roles[].name` | 40 |

        | `roles[].description` | 1500 |

        | `roles[].instructions` | 1500 |

        | `roles[].webhook` | 300 |
      parameters:
        - name: id
          in: path
          required: true
          description: AI agent identifier
          schema:
            type: string
      requestBody:
        required: true
        description: Fields to update on the AI agent
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAIAgent'
      responses:
        '200':
          description: AI agent updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                properties:
                  message:
                    type: string
                    example: AIAgent '123' updated successfully.
                additionalProperties: false
        '400':
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: AI agent ID missing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UpdateAIAgent:
      type: object
      description: >-
        Partial update payload for an AI agent. Length limits: description 5000;
        role name 40; role description/instructions 1500; role webhook 300.
      properties:
        name:
          type: string
          description: New display name
        description:
          type: string
          maxLength: 5000
          description: New description (max 5000 characters)
        roles:
          type: array
          description: >-
            Full roles list. Changed roles regenerate their tool schemas.
            Limits: name 40, description 1500, instructions 1500, webhook 300.
          items:
            $ref: '#/components/schemas/AIAgentRole'
        vectorStore:
          type: object
          description: Only `required` is updatable
          properties:
            required:
              type: boolean
              description: Whether the agent must use the vector store
          additionalProperties: false
      additionalProperties: false
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    AIAgentRole:
      type: object
      required:
        - name
        - description
        - instructions
        - webhook
        - allRequired
      properties:
        name:
          type: string
          maxLength: 40
          description: >-
            Role name (max 40 characters). Also used to derive the OpenAI
            function tool name.
        description:
          type: string
          maxLength: 1500
          description: Short description of the role (max 1500 characters)
        instructions:
          type: string
          maxLength: 1500
          description: >-
            Instructions used when generating the role tool schema (max 1500
            characters)
        webhook:
          type: string
          maxLength: 300
          description: >-
            Webhook URL invoked when this role tool is called (max 300
            characters)
        allRequired:
          type: boolean
          description: When true, generated tool parameters are all required (strict mode)
        tool:
          type: object
          description: Generated OpenAI function tool definition
          additionalProperties: true
      additionalProperties: false
  securitySchemes:
    cookieAuth:
      type: apiKey
      in: header
      name: Cookie
      description: Personal access token from Pingmee Settings → Developer Tools
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Business API key from Pingmee Settings → Developer Tools

````