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

# Agent Update

> Update an existing agent.

Args:
    agent_id: The ID of the agent to update
    agent_data: The updated agent data
    current_user: The current authenticated user
    tenant: The tenant database

Returns:
    Agent: The updated agent

Raises:
    HTTPException(400): If input validation fails
    HTTPException(404): If agent not found
    HTTPException(403): If trying to change to public agent without APIGENE tier
    HTTPException(409): If new name conflicts with existing agent
    HTTPException(500): If database operation fails or other error occurs



## OpenAPI

````yaml put /api/agent/update/{agent_id}
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/agent/update/{agent_id}:
    put:
      tags:
        - Agent
      summary: Agent Update
      description: |-
        Update an existing agent.

        Args:
            agent_id: The ID of the agent to update
            agent_data: The updated agent data
            current_user: The current authenticated user
            tenant: The tenant database

        Returns:
            Agent: The updated agent

        Raises:
            HTTPException(400): If input validation fails
            HTTPException(404): If agent not found
            HTTPException(403): If trying to change to public agent without APIGENE tier
            HTTPException(409): If new name conflicts with existing agent
            HTTPException(500): If database operation fails or other error occurs
      operationId: agent_update
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Agent'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    AgentUpdate:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Name of the agent
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Brief description of what the agent does
        instructions:
          anyOf:
            - {}
            - type: 'null'
          title: Instructions
          description: Long string with the agent instructions (can be string or dict)
        apis:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Apis
          description: List of API names that the agent contains
        mcps:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Mcps
          description: List of MCP server names that the agent contains
        context:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Context
          description: List of context IDs that the agent contains
        icon:
          anyOf:
            - {}
            - type: 'null'
          title: Icon
          description: Either a URL, base64 string, or dict for the agent icon
        agent_type:
          anyOf:
            - $ref: '#/components/schemas/AgentType'
            - type: 'null'
          description: Type of agent (private/public)
      type: object
      title: AgentUpdate
      description: Request model for updating an agent
    Agent:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier for the agent
        name:
          type: string
          title: Name
          description: Name of the agent
        description:
          type: string
          title: Description
          description: Brief description of what the agent does
        instructions:
          type: string
          title: Instructions
          description: Long string with the agent instructions
        apis:
          items:
            type: string
          type: array
          title: Apis
          description: List of API names that the agent contains
        mcps:
          items:
            type: string
          type: array
          title: Mcps
          description: List of MCP server names that the agent contains
        context:
          items:
            type: string
          type: array
          title: Context
          description: List of context IDs that the agent contains
        icon:
          anyOf:
            - type: string
            - type: 'null'
          title: Icon
          description: Either a URL or base64 string for the agent icon
        agent_type:
          type: string
          title: Agent Type
          description: Type of agent (private/public)
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the agent was created
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: When the agent was last updated
        created_by:
          type: string
          title: Created By
          description: Email of the user who created the agent
      type: object
      required:
        - id
        - name
        - description
        - instructions
        - agent_type
        - created_at
        - updated_at
        - created_by
      title: Agent
      description: Response model for agent
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentType:
      type: string
      enum:
        - private
        - public
      title: AgentType
      description: Agent visibility types
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````