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

# Update Conversation Variable

> **Available for**: Chatflow

Updates one conversation variable.

**Standard API equivalent**: [Update Conversation Variable](/en/3.13.x/develop/api/conversations/update-conversation-variable). Differences:

- `user` is required.
- Error codes differ.



## OpenAPI

````yaml /en/3.13.x/develop/api/openapi_service.json put /v2/conversations/{conversation_id}/variables/{variable_id}
openapi: 3.0.1
info:
  title: Dify Service API
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: >-
      Base URL of the Dify Service API. Replace it with your deployment's API
      endpoint.
    variables:
      api_base_url:
        default: api.example.com/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - name: Chat Messages
    description: Operations related to chat messages and interactions.
  - name: Files
    description: File upload and preview operations.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: User feedback operations.
  - name: Conversations
    description: Operations related to managing conversations.
  - name: Audio
    description: Text-to-Speech and Speech-to-Text operations.
  - name: Applications
    description: Operations to retrieve application settings and information.
  - name: Annotations
    description: Operations related to managing annotations for direct replies.
  - name: Human Input
    description: Endpoints for resuming paused workflows that require human input.
  - name: Workflow Runs
    description: Operations for executing and managing workflows.
  - name: Completion Messages
    description: Operations related to text generation and completion.
  - name: Knowledge Bases
    description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
  - name: Documents
    description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
  - name: Chunks
    description: Operations for managing document chunks and child chunks.
  - name: Metadata
    description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
  - name: Tags
    description: Operations for managing knowledge base tags and tag bindings.
  - name: Models
    description: Operations for retrieving available models.
  - name: Knowledge Pipeline
    description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
  - name: Deployed Environments
    description: >-
      Endpoints served by deployed environments over the `v2` base URL. Deployed
      environments serve only the endpoints in this group; calling any other
      path there returns `404 not_found`. Authentication and errors differ from
      the standard Service API; each page here is authoritative for deployed
      environments.
paths:
  /v2/conversations/{conversation_id}/variables/{variable_id}:
    put:
      tags:
        - Deployed Environments
      summary: Update Conversation Variable
      description: >-
        **Available for**: Chatflow


        Updates one conversation variable.


        **Standard API equivalent**: [Update Conversation
        Variable](/en/3.13.x/develop/api/conversations/update-conversation-variable).
        Differences:


        - `user` is required.

        - Error codes differ.
      operationId: updateDeployedConversationVariable
      parameters:
        - name: conversation_id
          in: path
          required: true
          description: >-
            ID of the conversation that owns the variable. Get conversation IDs
            from [List
            Conversations](/en/3.13.x/develop/api/deployed-environments/list-conversations).
          schema:
            type: string
            format: uuid
        - name: variable_id
          in: path
          required: true
          description: >-
            ID of the variable to update. Get variable IDs from [List
            Conversation
            Variables](/en/3.13.x/develop/api/deployed-environments/list-conversation-variables).
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - user
                - value
              properties:
                user:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    End-user identifier, defined by your app and unique within
                    it. Must match the `user` the conversation was created with.
                    See [End User
                    Identity](/en/3.13.x/develop/api/guides/end-user-identity).
                value:
                  description: >-
                    New value: `null`, a string, a number, a boolean, an object,
                    or an array, matching the variable's declared type.
            examples:
              req:
                summary: Request Example
                value:
                  user: customer-001
                  value:
                    order_id: ORDER-1001
                    priority: false
      responses:
        '200':
          description: The updated variable.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Conversation variable ID.
                  name:
                    type: string
                    description: Variable name.
                  value_type:
                    type: string
                    description: >-
                      Declared type: `string`, `number`, `boolean`, `secret`,
                      `object`, `file`, `none`, or an array type such as
                      `array[string]`, `array[number]`, `array[object]`,
                      `array[file]`, `array[boolean]`, `array[any]`.
                  value:
                    type: string
                    nullable: true
                    description: >-
                      String variables come back as-is; other types come back as
                      a canonical JSON string; `none` comes back as `null`.
                  description:
                    type: string
                    nullable: true
                    description: Variable description.
                  created_at:
                    type: integer
                    description: Creation time as a Unix timestamp in seconds.
                  updated_at:
                    type: integer
                    description: Last-update time as a Unix timestamp in seconds.
              examples:
                ok:
                  summary: Response Example
                  value:
                    id: 6fa459ea-ee8a-3ca4-894e-db77e160355e
                    name: order_context
                    value_type: object
                    value: '{"order_id":"ORDER-1001","priority":false}'
                    description: Current order context
                    created_at: 1787788800
                    updated_at: 1787788980
        '400':
          description: >-
            - `invalid_param`: a path or body value breaks its validation rule.
            The message names the rule the value broke, such as `value length
            must be between 1 and 255 runes, inclusive` for a `user` longer than
            255 characters.

            - `invalid_param`: the body has no `value` field. The message is
            `invalid argument`. Sending `"value": null` counts as a value and is
            checked against the variable's type like any other.

            - `not_chat_app`: the API key belongs to an app that is not a
            Chatflow.

            - `app_unavailable`: the app can't serve API requests in this
            environment right now.
                - API access is turned off.
                - The app is not deployed here.
                - A deployment is still rolling out.
                - The environment is being deleted.

                Ask the app's owner to check its **Access Point** tab, or an administrator to check the environment in the Enterprise Dashboard, and retry once it serves again.
            - `bad_request`: the value's type does not match the variable's
            declared type.
          content:
            application/json:
              examples:
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: >-
                      invalid UpdateServiceAPIConversationVariableRequest.User:
                      value length must be between 1 and 255 runes, inclusive
                    status: 400
                invalid_param_missing_value:
                  summary: invalid_param (missing value)
                  value:
                    code: invalid_param
                    message: invalid argument
                    status: 400
                not_chat_app:
                  summary: not_chat_app
                  value:
                    status: 400
                    code: not_chat_app
                    message: Please check if your app mode matches the right API route.
                app_unavailable:
                  summary: app_unavailable
                  value:
                    status: 400
                    code: app_unavailable
                    message: App unavailable, please check your app configurations.
                bad_request:
                  summary: bad_request
                  value:
                    code: bad_request
                    message: >-
                      Type mismatch: variable 'order_context' expects object,
                      but got string type
                    status: 400
        '401':
          description: >-
            `unauthorized`: the API key is missing, malformed, unknown, or
            revoked.
          content:
            application/json:
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Access token is invalid
                    status: 401
        '404':
          description: >-
            - `not_found`: the conversation does not exist or does not belong to
            this `user`.

            - `not_found`: the variable does not exist or does not belong to
            this conversation.
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Conversation Not Exists.
                not_found_variable:
                  summary: not_found (variable)
                  value:
                    code: not_found
                    message: Conversation Variable Not Exists.
                    status: 404
        '500':
          description: >-
            `internal_server_error`: the platform could not complete the
            request; retry, and contact your administrator if it persists.
          content:
            application/json:
              examples:
                internal_server_error:
                  summary: internal_server_error
                  value:
                    code: internal_server_error
                    message: internal error
                    status: 500
      servers:
        - url: https://{deployed_api_base_url}
          description: >-
            Base URL shared by every deployed environment: the standard Service
            API address, with `/v2` in place of `/v1`.
          variables:
            deployed_api_base_url:
              default: api.example.com
              description: >-
                On the app's **Access Point** tab, copy the full URL from any
                deployed environment's **Backend Service API** card, then remove
                the `https://` prefix and the trailing `/v2`.
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        Every request authenticates with an API key: `Authorization: Bearer
        {API_KEY}`. App endpoints take an app API key; knowledge endpoints take
        a knowledge base API key ([Get
        Started](/en/3.13.x/develop/api/guides/get-started)).


        Keep keys server-side; never embed them in client code. Requests with a
        missing or invalid key fail with HTTP `401` (`unauthorized`).

````