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.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”Request Body required
Section titled “ Request Body required ” Media type application/json
object
key
required
The key of a variable
string
value
required
The value of a variable
string
protected
Whether the variable is protected
boolean
masked
Whether the variable is masked
boolean
masked_and_hidden
Whether the variable is masked and hidden
boolean
raw
Whether the variable will be expanded
boolean
variable_type
The type of the variable. Default: env_var
string
environment_scope
The environment_scope of the variable
string
description
The description of the variable
string
Responses
Section titled “ Responses ”Created
Media type application/json
object
variable_type
string
key
string
value
string
hidden
boolean
protected
boolean
masked
boolean
raw
boolean
environment_scope
string
description
string
Example
{ "variable_type": "env_var", "key": "TEST_VARIABLE_1", "value": "TEST_1", "environment_scope": "*", "description": "This variable is being used for ..."}400 Bad Request
Not Found