Use this API to manage CI/CD variables for a project, a group, or an instance.
Managing project variables requires the Maintainer role for the project. Managing group variables requires the Owner role for the group. Managing instance variables requires administrator access.
List all instance variables
GET /api/v4/admin/ci/variables
Lists all instance-level variables. Use the page and per_page pagination parameters to control the pagination of results.
Parameters
| Name | Type | Description |
|---|---|---|
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
Create a new instance-level variable
POST /api/v4/admin/ci/variables
FE version
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
keyRequired | String | The key of the variable. |
masked | Boolean | Whether the variable is masked |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
valueRequired | String | The value of a variable |
variable_ | String | The type of a variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | 400 Bad Request | — |
Retrieve instance variable details
GET /api/v4/admin/ci/variables/{key}
Retrieves details of a specified instance-level variable.
Parameters
| Name | Type | Description |
|---|---|---|
keyPath, | String | The key of a variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Instance Variable Not Found | — |
Update an instance-level variable
PUT /api/v4/admin/ci/variables/{key}
FE version
Parameters
| Name | Type | Description |
|---|---|---|
keyPath, | String | The key of a variable |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
masked | Boolean | Whether the variable is masked |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
value | String | The value of a variable |
variable_ | String | The type of a variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Instance Variable Not Found | — |
Delete an existing instance-level variable
DELETE /api/v4/admin/ci/variables/{key}
FE version
Parameters
| Name | Type | Description |
|---|---|---|
keyPath, | String | The key of a variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Instance Variable Not Found | — |
List all group variables
GET /api/v4/groups/{id}/variables
Lists all variables for a specified group. Use the page and per_page pagination parameters to control the pagination of results.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String | The ID of a group or URL- |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Create a group variable
POST /api/v4/groups/{id}/variables
Creates a group variable.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String | The ID of a group or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
environment_ | String | The environment scope of a variable |
keyRequired | String | The ID of a group or URL- |
masked | Boolean | Whether the variable is masked |
masked_ | Boolean | Whether the variable is masked and hidden |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
valueRequired | String | The value of a variable |
variable_ | String | The type of the variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | 400 Bad Request | — |
404 | Not Found | — |
Retrieve details of a group variable
GET /api/v4/groups/{id}/variables/{key}
Retrieves details of a specified group variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String | The ID of a group or URL- |
keyPath, | String | The key of the variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Group Variable Not Found | — |
Update a group variable
PUT /api/v4/groups/{id}/variables/{key}
Updates a specified group variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String | The ID of a group or URL- |
keyPath, | String | The key of a variable |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
environment_ | String | The environment scope of a variable |
masked | Boolean | Whether the variable is masked |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
value | String | The value of a variable |
variable_ | String | The type of the variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | 400 Bad Request | — |
404 | Group Variable Not Found | — |
Delete a group variable
DELETE /api/v4/groups/{id}/variables/{key}
Deletes a specified group variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String | The ID of a group or URL- |
keyPath, | String | The key of a variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Group Variable Not Found | — |
List all project variables
GET /api/v4/projects/{id}/variables
Lists all variables for a project. Use the page and per_page pagination parameters to control the pagination of results.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID of a project or URL- |
pageQuery | Integer | Current page number Default: 1Example: 1 |
per_Query | Integer | Number of items per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Create a variable
POST /api/v4/projects/{id}/variables
Creates a variable. If a variable with the same key already exists, the variable must have a different environment_scope. Otherwise, GitLab returns a message similar to: VARIABLE_NAME has already been taken.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID of a project or URL- |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
environment_ | String | The environment_ |
keyRequired | String | The key of a variable |
masked | Boolean | Whether the variable is masked |
masked_ | Boolean | Whether the variable is masked and hidden |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
valueRequired | String | The value of a variable |
variable_ | String | The type of the variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | 400 Bad Request | — |
404 | Not Found | — |
Retrieve a single variable
GET /api/v4/projects/{id}/variables/{key}
Retrieves details of a specified variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID of a project or URL- |
keyPath, | String | The key of a variable |
filterQuery | Object | Available filters: |
filter[environment_Query | String | The environment scope of a variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Variable Not Found | — |
Update a variable
PUT /api/v4/projects/{id}/variables/{key}
Updates a project variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID of a project or URL- |
keyPath, | String | The key of a variable |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
description | String | The description of the variable |
environment_ | String | The environment_ |
filter | Object | Available filters: |
filter. | String | The environment scope of a variable |
masked | Boolean | Whether the variable is masked |
protected | Boolean | Whether the variable is protected |
raw | Boolean | Whether the variable will be expanded |
value | String | The value of a variable |
variable_ | String | The type of the variable. Allowed values: env_,file |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Variable Not Found | — |
Delete a variable
DELETE /api/v4/projects/{id}/variables/{key}
Deletes a project variable. If there are multiple variables with the same key, use filter to select the correct environment_scope.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | The ID of a project or URL- |
keyPath, | String | The key of a variable |
filterQuery | Object | Available filters: |
filter[environment_Query | String | The environment scope of the variable |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Variable Not Found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesCiVariable
| Property | Type | Description |
|---|---|---|
description | String | Example:This variable is being used for . |
environment_ | String | Example:* |
hidden | Boolean | — |
key | String | Example:TEST_ |
masked | Boolean | — |
protected | Boolean | — |
raw | Boolean | — |
value | String | Example:TEST_ |
variable_ | String | Example:env_ |