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

> Updates an existing BYO Agent by its UID. Use this endpoint to modify agent configuration, update referenced tools, or change the connected AI framework.  **Validation:** Referenced tools and actions

# Update BYO Agent

For the complete error reference, see [Error Guide](/rest-api/byo-ai-agents-apis/error-codes).


## OpenAPI

````yaml patch /ai-agents/agents/{uid}
openapi: 3.0.0
info:
  title: AI Agents APIs
  description: API reference for CometChat AI Agents service
  version: '1.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: ai-agent
    description: ''
paths:
  /ai-agents/agents/{uid}:
    patch:
      tags:
        - Agents
      summary: Update BYO Agent
      description: >-
        Updates an existing BYO Agent by its UID. Use this endpoint to modify
        agent configuration, update referenced tools, or change the connected AI
        framework.


        **Validation:** Referenced tools and actions are validated if provided.
      operationId: AgentsController_updateAgent
      parameters:
        - name: uid
          required: true
          in: path
          description: Unique identifier of the agent
          schema:
            type: string
        - name: chatApiVersion
          required: false
          in: header
          description: Chat API version. Defaults to `v3.0`.
          schema:
            type: string
            default: v3.0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgentDTO'
      responses:
        '200':
          description: Agent updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessBooleanResponse'
              example:
                success: true
      security:
        - apiKey: []
components:
  schemas:
    UpdateAgentDTO:
      discriminator:
        propertyName: integrateWith
        mapping:
          mastra:
            $ref: '#/components/schemas/UpdateMastraAgentDTO'
          mastra-legacy:
            $ref: '#/components/schemas/UpdateMastraLegacyAgentDTO'
          langgraph:
            $ref: '#/components/schemas/UpdateLangGraphAgentDTO'
          crewai:
            $ref: '#/components/schemas/UpdateCrewAIAgentDTO'
          vercelV5:
            $ref: '#/components/schemas/UpdateVercelV5AgentDTO'
          ag2:
            $ref: '#/components/schemas/UpdateAG2AgentDTO'
          rasa:
            $ref: '#/components/schemas/UpdateRasaAgentDTO'
          agno:
            $ref: '#/components/schemas/UpdateAgnoAgentDTO'
          ag-ui:
            $ref: '#/components/schemas/UpdateAGUIAgentDTO'
      oneOf:
        - $ref: '#/components/schemas/UpdateMastraAgentDTO'
        - $ref: '#/components/schemas/UpdateMastraLegacyAgentDTO'
        - $ref: '#/components/schemas/UpdateLangGraphAgentDTO'
        - $ref: '#/components/schemas/UpdateCrewAIAgentDTO'
        - $ref: '#/components/schemas/UpdateVercelV5AgentDTO'
        - $ref: '#/components/schemas/UpdateAG2AgentDTO'
        - $ref: '#/components/schemas/UpdateRasaAgentDTO'
        - $ref: '#/components/schemas/UpdateAgnoAgentDTO'
        - $ref: '#/components/schemas/UpdateAGUIAgentDTO'
    SuccessBooleanResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
          description: Indicates whether the operation was successful
      required:
        - success
    UpdateMastraAgentDTO:
      title: Mastra
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - mastra
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: Mastra-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Mastra agent is hosted
              example: https://my-mastra-app.example.com
            agentId:
              type: string
              description: Mastra Agent ID
              example: weatherAgent
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateMastraLegacyAgentDTO:
      title: Mastra (Legacy)
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - mastra-legacy
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: Mastra (Legacy) configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Mastra agent is hosted
              example: https://my-mastra-legacy.example.com
            agentId:
              type: string
              description: Mastra Agent ID
              example: weatherAgent
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateLangGraphAgentDTO:
      title: LangGraph
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - langgraph
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: LangGraph-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your agent is hosted
              example: https://my-langgraph-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateCrewAIAgentDTO:
      title: CrewAI
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - crewai
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: CrewAI compatible agent configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your CrewAI agent is hosted
              example: https://my-crewai-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateVercelV5AgentDTO:
      title: Vercel AI V5
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - vercelV5
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: Vercel AI V5 configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Vercel AI agent is hosted
              example: https://my-vercel-app.vercel.app/api/chat
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Bearer token123
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateAG2AgentDTO:
      title: AG2
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - ag2
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: AG2-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your AG2 agent is hosted
              example: https://my-ag2-app.example.com
            defaultUserId:
              type: string
              description: Default User ID
              example: user_123
            headers:
              type: string
              description: >-
                Headers as key:value pairs, each on a new line. Should be valid
                JSON
              example: '{"authorization": "Bearer token123"}'
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateRasaAgentDTO:
      title: Rasa
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - rasa
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: Rasa-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Rasa agent is hosted
              example: https://my-rasa-app.example.com
            headers:
              type: string
              description: Headers as key:value pairs, each on a new line
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateAgnoAgentDTO:
      title: Agno
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - agno
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: Agno-specific configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your Agno agent is hosted
              example: https://my-agno-app.example.com
            agentId:
              type: string
              description: Agno Agent ID
              example: my-agent-id
            headers:
              type: string
              description: Headers as key:value pairs, each on a new line
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
    UpdateAGUIAgentDTO:
      title: AG-UI
      type: object
      properties:
        name:
          type: string
          description: Name of the agent
        icon:
          type: string
          format: url
          description: URL to the icon/avatar of the agent
        isActive:
          type: boolean
          default: true
          description: Whether the agent is active
        integrateWith:
          type: string
          enum:
            - ag-ui
          description: Integration platform identifier
        integrationType:
          type: string
          enum:
            - agent
          description: Type of connection
        integrationMeta:
          type: object
          description: AG-UI compatible agent configuration
          properties:
            baseUrl:
              type: string
              description: The web address where your AG-UI agent is hosted
              example: https://my-agui-app.example.com
            headers:
              type: object
              description: Custom headers as JSON object (e.g., authorization tokens)
              example:
                authorization: Basic your_basic_auth
        tools:
          type: array
          items:
            type: string
          description: List of tool names (must exist in the app's tools)
        actions:
          type: array
          items:
            type: string
          description: List of action names (must exist in the app's actions)
        metaData:
          type: object
          description: Metadata for the agent
          properties:
            greetingMessage:
              type: string
              description: Greeting message shown when a conversation starts
            introductoryMessage:
              type: string
              description: Introductory message for the agent
            suggestedMessages:
              type: array
              items:
                type: string
              description: Quick prompts users can click to start a conversation
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key (i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````