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

# Create a group variable

`POST /api/v4/groups/{id}/variables`

## Request

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

Creates a group variable.

## Path parameters

- `id` string, required

## Request body

- PostApiV4GroupsIdVariables: Create a group variable
  - `key` string, required: The ID of a group or URL-encoded path of the group owned by the authenticated user
  - `value` string, required: The value of a variable
  - `protected` boolean: Whether the variable is protected
  - `masked_and_hidden` boolean: Whether the variable is masked and hidden
  - `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 `201`

Create 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

---

[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)
