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

# Update Input Variable

> Update a User Defined input variable's type/description, or soft-delete it by passing status = 2. System variables cannot be modified, and deleting a variable that is still in use by an agent or audience is blocked.

Use this endpoint to **update or soft-delete a User Defined input variable**.

## Endpoint

**POST** `/input-variable/update`

**Content-Type:** `application/json`
**Authentication:** Required (workspace auth)

## Request Body

### Update fields

```json theme={null}
{
  "variable_id": 57,
  "type": "amount",
  "description": "Updated description"
}
```

### Soft-delete a variable

```json theme={null}
{
  "variable_id": 57,
  "status": 2
}
```

| Field          | Type   | Required | Description                                                                                                             |
| -------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `variable_id`  | number | Yes      | ID of the input variable to update                                                                                      |
| `variable_key` | string | No       | Accepted but ignored — the key is immutable and is never changed (see Behavior).                                        |
| `type`         | string | No       | New data type. One of: `string`, `number`, `date`, `email`, `phone`, `name`, `amount`, `address`, `pincode`, `no_type`. |
| `description`  | string | No       | New description                                                                                                         |
| `status`       | number | No       | `0` (inactive), `1` (active), or `2` (**deleted** — soft-deletes the variable)                                          |

## Response

```json theme={null}
{
  "message": "Input variable updated successfully",
  "data": { "id": 57 }
}
```

When `status: 2` is sent:

```json theme={null}
{
  "message": "Input variable deleted successfully",
  "data": { "id": 57 }
}
```

## Behavior

* Only **User Defined** variables can be updated — System variables always fail with `System variables cannot be modified`.
* `variable_key` is accepted in the request but is **immutable** and never applied — renaming a key would break every audience and agent that references it.
* Passing `status: 2` **soft-deletes** the variable (`STATUS` is set to `2`; it no longer appears in [List Input Variables](/api-reference/input-variables/list-input-variables)). Deleting is blocked while the variable is referenced by any agent or audience.
* Editing `type` and/or `description` **is allowed even while the variable is in use**. The change is propagated into every agent flow that references the variable by key — the matching `metadata_input` entry's `type`/`data_type` and `description` are updated in place. Audiences store variable keys only (no type/description), so they need no propagation.
* Only the fields you send are applied; omitted fields are left unchanged.

## Error Cases

| Error                                                                                                                                     | Cause                                                                           |
| ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `Input variable not found`                                                                                                                | `variable_id` is invalid, belongs to another workspace, or is already deleted   |
| `System variables cannot be modified`                                                                                                     | The target variable has `IS_SYSTEM = 1`                                         |
| `Type must be one of: string, number, date, email, phone, name, amount, address, pincode, no_type`                                        | `type` is not one of the allowed values                                         |
| `The input variable is linked to <N> active agent(s) and/or <N> active audience(s). First remove it from the agents/audiences to delete.` | `status: 2` sent while the variable is still referenced by an agent or audience |

## Example cURL

```bash theme={null}
curl -X POST https://www.tryunleashx.com/api/v1/global/input-variable/update \
  -H "Content-Type: application/json" \
  -H "token: <api_key>" \
  -d '{
    "variable_id": 57,
    "type": "amount",
    "description": "Updated description"
  }'
```


## OpenAPI

````yaml api-reference/openapi.json POST /input-variable/update
openapi: 3.1.0
info:
  title: >-
    UnleashX - Build human like conversations | Voice Agents | Automations | AI
    Workforce
  version: 1.0.0
  description: UnleashX - Your home for human like conversations
servers:
  - url: https://www.tryunleashx.com/api/v1/global/
security:
  - bearerAuth: []
paths:
  /input-variable/update:
    post:
      tags:
        - Input Variables
      summary: Update input variable
      description: >-
        Update a User Defined input variable's type/description, or soft-delete
        it by passing status = 2. System variables cannot be modified, and
        deleting a variable that is still in use by an agent or audience is
        blocked.
      parameters:
        - name: token
          in: header
          required: true
          description: API token for authentication
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - variable_id
              properties:
                variable_id:
                  type: integer
                  description: ID of the input variable to update
                variable_key:
                  type: string
                  description: >-
                    Accepted but ignored - the variable key is immutable and is
                    never changed
                type:
                  type: string
                  enum:
                    - string
                    - number
                    - date
                    - email
                    - phone
                    - name
                    - amount
                    - address
                    - pincode
                    - no_type
                  description: New data type
                description:
                  type: string
                  description: New description
                status:
                  type: integer
                  enum:
                    - 0
                    - 1
                    - 2
                  description: 0=inactive, 1=active, 2=deleted (soft-deletes the variable)
      responses:
        '200':
          description: Input variable updated or deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      id:
                        type: integer
        '400':
          description: >-
            Bad Request - invalid type, or variable is in use by an
            agent/audience and cannot be deleted
        '401':
          description: Unauthorized
        '404':
          description: Input variable not found
      security: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````