---
title: "Set user variable"
method: PUT
path: "/v1/users/{user-id}/variables/{variable-name}"
tags: ["Users"]
---

# Set user variable

`PUT /v1/users/{user-id}/variables/{variable-name}`

## Request

- Base URL: `http://127.0.0.1:8000`
- URL: `http://127.0.0.1:8000/v1/users/{user-id}/variables/{variable-name}`
- Auth: HTTP bearer

Create or overwrite a single variable of the user. Each variable is written
independently, so concurrent sessions of one user only overwrite the keys they both
touch. Variable names are limited to 127 characters and may contain letters, digits,
space and the characters `_ - @ ( ) . /`. A user may set their own variables; setting
another user's variables requires MANAGE_USERS access right.

## Path parameters

- `user-id` integer, required
- `variable-name` string, required

## Request body

- object
  - `value` string, required: Variable value (opaque text; serialize structured values as JSON)

## Response `200`

Variable stored successfully

- UserVariable: Single per-user variable (preference or other UI state)
  - `name` string, required: Variable name
  - `value` string, required: Variable value (opaque text)

## Other responses

- `400`: Invalid user ID, invalid variable name, or missing/non-string value
- `401`: Unauthorized
- `403`: Access denied (not self and no MANAGE_USERS right)
- `500`: Database failure

## Changes

- **2026-10-14** `2b33ef4bdb15`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/netxms/apis/netxms-api/changes/v1/users/:user-id/variables/:variable-name/put.md)

---

[API](https://skmtc.dev/netxms/apis/netxms-api.md) - [All operations](https://skmtc.dev/netxms/apis/netxms-api/llms.txt) - [OpenAPI document](https://skmtc.dev/netxms/apis/netxms-api/revisions/740d85ba6674?raw)
