---
title: "Create instance variable"
method: POST
path: "/api/v4/admin/ci/variables"
tags: ["ci_variables"]
---

# Create instance variable

`POST /api/v4/admin/ci/variables`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/admin/ci/variables`
- Auth: none declared

Creates a instance-level variable. The maximum number of instance-level variables can be changed.

## Request body

- PostApiV4AdminCiVariables: Create instance variable
  - `key` string, required: The key of the variable. Max 255 characters
  - `description` string: The description of the variable
  - `value` string, required: 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 a variable. Available types are: env_var (default) and file

## Response `201`

Create instance 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)
