---
title: "Update Variable (by ID)"
description: "Update a knowledge-base or folder variable's name, content, or tags by ID. Includes example request, response, and error handling."
url: "https://docs.turbodocx.com/docs/API/update-variable-by-id"
---

# Update Variable (by ID)

> Update a knowledge-base or folder variable's name, content, or tags by ID. Includes example request, response, and error handling.

The Update Variable (by ID) endpoint replaces a knowledge-base or template-folder variable's content and metadata. Unlike [Edit Template Metadata](https://docs.turbodocx.com/docs/API/edit-template-metadata.md), this is a full replace, not a partial patch: `mimeType` and `text` are required on every call. `isGlobal` and `templateFolderId` are both optional; at most one may be set.

## When to use it

Use this endpoint to edit a reusable variable you found with [Read Variables (Folder)](https://docs.turbodocx.com/docs/API/read-variables-folder.md), for example correcting its text, changing its name, or replacing its tag list.

## Example request

```bash
curl -X PUT "https://api.turbodocx.com/Variable/e4f5a6b7-8c9d-4e0f-a1b2-3c4d5e6f7a8b" \
  -H "Authorization: Bearer $TURBODOCX_API_KEY" \
  -H "x-rapiddocx-org-id: $TURBODOCX_ORG_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Company Address",
    "placeholder": "{CompanyAddress}",
    "mimeType": "text",
    "text": "123 Main St, Suite 400, Austin, TX 78701",
    "allowRichTextInjection": true,
    "isGlobal": true,
    "tags": []
  }'
```

`{VariableId}` in the path is the `variableMapId` returned by [Read Variables (Folder)](https://docs.turbodocx.com/docs/API/read-variables-folder.md), not the underlying `Variable.id`. Optionally send `isGlobal: true` or `templateFolderId`, but not both; sending both is rejected. For an image variable, set `mimeType` to `"image"` and `text` to a base64 data string.

## Example response

On success the endpoint returns `200 OK` with the updated variable wrapped in a `variable` key (not the `data` envelope most other TurboDocx endpoints use):

```json
{
  "variable": {
    "id": "e4f5a6b7-8c9d-4e0f-a1b2-3c4d5e6f7a8b",
    "name": "Company Address",
    "placeholder": "{CompanyAddress}",
    "mimeType": "text",
    "text": "123 Main St, Suite 400, Austin, TX 78701",
    "isGlobal": true,
    "templateFolderId": null,
    "updatedOn": "2026-05-02T09:00:00.000Z"
  }
}
```

## Common errors

| Status | When | Response body |
| ------ | ---- | ------------- |
| 401 | Missing or invalid API key/token, or the organization cannot be resolved | Empty (status only) |
| 403 | The key's role is not administrator, contributor, or user. For `isGlobal: true` updates (as in the example above), only administrator and contributor are allowed; the `user` role is also rejected with `403`. | Empty (status only) |
| 400 | `mimeType` or `text` is missing, or both `isGlobal` and `templateFolderId` are set | `{ "message", "type": "ValidationError", "data": { "errors": [...] } }` |
| 409 | The variable was deleted or modified by someone else before this update landed | `{ "error", "data": { "explanation" } }` |

## Related endpoints

- [Read Variables (Folder)](https://docs.turbodocx.com/docs/API/read-variables-folder.md) to find the `variableMapId` to update
- [Delete Variables (by IDs)](https://docs.turbodocx.com/docs/API/delete-variables-by-i-ds.md) to remove variables instead of editing them
