---
title: "Update a group variable"
method: PUT
path: "/api/v4/groups/{id}/variables/{key}"
tags: ["ci_variables"]
---

# Update a group variable

`PUT /api/v4/groups/{id}/variables/{key}`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/groups/{id}/variables/{key}`
- Auth: none declared

Updates a specified group variable. If there are multiple variables with the same key, use `filter` to select the correct `environment_scope`.

## Path parameters

- `id` string, required
- `key` string, required

## Request body

- PutApiV4GroupsIdVariablesKey: Update a group variable
  - `value` string: The value of a variable
  - `protected` boolean: Whether the variable is protected
  - `masked` boolean: Whether the variable is masked
  - `raw` boolean: Whether the variable will be expanded
  - `variable_type` 'env_var' | 'file': The type of the variable. Default: env_var
  - `environment_scope` string: The environment scope of the variable
  - `description` string: The description of the variable

## Response `200`

Update a group variable

- APIEntitiesCiVariable: API_Entities_Ci_Variable model
  - `variable_type` string, required
  - `key` string, required
  - `value` string, required
  - `hidden` boolean
  - `protected` boolean
  - `masked` boolean
  - `raw` boolean
  - `environment_scope` string
  - `description` string

## Other responses

- `400`: 400 Bad Request
- `404`: Group Variable Not Found

---

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