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

# Update Agent Tags

> Change settings that apply to all versions of an agent, such as its environment tags.

Works for voice and chat agents. To learn how tags route calls, see [environment tags](https://docs.retellai.com/agent/version.md#environment-tags).

Tags you leave out stay as they are, and so do the fields you leave out of a tag. For example, `{"tags": {"prod": {"version": 3}}}` moves `prod` to version 3 and keeps its dynamic variables and every other tag.

Set a tag to `null` to delete it. Deleting a tag also removes it from every phone number that uses it.

To avoid overwriting a change made after you read the agent, send the `ETag` from your last response in the `If-Match` header. If the agent changed since then, the request returns `412` and changes nothing.


## OpenAPI

````yaml openapi-final patch /update-agent-root/{agent_id}
openapi: 3.0.3
info:
  title: Retell SDK
  version: 3.0.0
  x-retell-spec-revision: 2026-11-22-669f372
  contact:
    name: Retell Support
    url: https://www.retellai.com/
    email: support@retellai.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.retellai.com
    description: The production server.
security:
  - api_key: []
paths:
  /update-agent-root/{agent_id}:
    patch:
      description: >-
        Change settings that apply to all versions of an agent, such as its
        environment tags.
      operationId: updateAgentRoot
      parameters:
        - in: path
          name: agent_id
          schema:
            type: string
            minLength: 1
            example: agent_xxx
          required: true
          description: Unique id of the agent.
        - in: header
          name: If-Match
          schema:
            type: string
            pattern: ^("[0-9]+"|[0-9]+)$
            example: '"1744761835123"'
          required: false
          description: >-
            ETag from an earlier get-agent-root or update-agent-root response.
            If the agent changed since then, the update returns 412 and changes
            nothing.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAgentRootRequest'
      responses:
        '200':
          description: Agent settings updated successfully.
          headers:
            ETag:
              schema:
                type: string
              description: >-
                Pass this value in If-Match on your next update of the agent
                settings.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRootResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '412':
          $ref: '#/components/responses/PreconditionFailed'
        '422':
          $ref: '#/components/responses/UnprocessableContent'
        '500':
          $ref: '#/components/responses/InternalServerError'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Retell from 'retell-sdk';


            const client = new Retell({
              apiKey: process.env['RETELL_API_KEY'], // This is the default and can be omitted
            });


            const agentRootResponse = await
            client.agent.updateRoot('agent_xxx');


            console.log(agentRootResponse.agent_id);
        - lang: Python
          source: |-
            import os
            from retell import Retell

            client = Retell(
                api_key=os.environ.get("RETELL_API_KEY"),  # This is the default and can be omitted
            )
            agent_root_response = client.agent.update_root(
                agent_id="agent_xxx",
            )
            print(agent_root_response.agent_id)
components:
  schemas:
    UpdateAgentRootRequest:
      type: object
      additionalProperties: false
      properties:
        tags:
          type: object
          description: >-
            Environment tags to add, change, or delete, keyed by tag name. Set a
            tag to an object to add or change it, or to null to delete it. Tags
            you leave out stay as they are. The prod and staging tags cannot be
            deleted. An agent can have up to 10 tags. Tag names must be 1-20
            characters, start with a lowercase letter, use only lowercase
            letters, digits, underscores, or hyphens, and cannot be "latest",
            "latest_published", or "v" followed only by digits, such as "v2".
          example:
            prod:
              version: 3
          properties:
            prod:
              $ref: '#/components/schemas/AgentRootTagUpdate'
            staging:
              $ref: '#/components/schemas/AgentRootTagUpdate'
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/AgentRootTagUpdate'
              - type: object
                nullable: true
                enum:
                  - null
    AgentRootResponse:
      type: object
      required:
        - agent_id
        - is_suspended
        - tags
        - user_modified_timestamp
      properties:
        agent_id:
          type: string
          example: agent_xxx
          description: Unique id of the agent.
        is_suspended:
          type: boolean
          example: false
          description: Whether the agent is currently suspended.
        tags:
          type: object
          description: >-
            Environment tags for this agent, keyed by tag name. Every agent has
            prod and staging tags.
          example:
            prod:
              version: 3
            staging: {}
          additionalProperties:
            $ref: '#/components/schemas/AgentRootTagState'
        user_modified_timestamp:
          type: integer
          format: int64
          example: 1746105600000
          description: >-
            User modification timestamp (milliseconds since epoch). Either the
            time of last update or creation if no updates available.
    AgentRootTagUpdate:
      type: object
      additionalProperties: false
      properties:
        version:
          type: integer
          nullable: true
          minimum: 0
          example: 15
          description: >-
            Version for the tag to point to. Set to null to make the tag follow
            the latest version. If omitted, the tag keeps its current version.
        dynamic_variables:
          type: object
          nullable: true
          additionalProperties:
            type: string
          description: >-
            Dynamic variable values supplied when a call uses this tag. Replaces
            all of the tag's current values. Set to null to remove them. If
            omitted, the tag keeps its current values.
    AgentRootTagState:
      type: object
      properties:
        version:
          type: integer
          minimum: 0
          example: 15
          description: >-
            Version that the tag points to. Absent when the tag follows the
            latest version.
        dynamic_variables:
          type: object
          additionalProperties:
            type: string
          description: Dynamic variable values supplied when a call uses this tag.
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: Invalid request format, please check API reference.
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: API key is missing or invalid.
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: The requested resource was not found.
    PreconditionFailed:
      description: Precondition Failed
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: Precondition failed for conditional update.
    UnprocessableContent:
      description: Unprocessable Content
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: Cannot find requested asset under given api key.
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                example: An unexpected server error occurred.
  securitySchemes:
    api_key:
      type: http
      scheme: bearer
      bearerFormat: string
      description: >-
        Authentication header containing API key (find it in dashboard). The
        format is "Bearer YOUR_API_KEY"

````

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