Create a global environment variable via API
This method allows you to create a new global environment variable for your account. Global variables are available to all projects.
Tip: You can explore and test this endpoint interactively using our OpenAPI documentation.
URL
/global_environment_variables
HTTP Method
POST
Supported Parameters
name(required) - The variable name. Must start with a letter and contain only letters, numbers, and underscoresvalue(required) - The variable value. Will be encrypted at restlocked(optional) - Lock the variable to prevent changes. Default:false. Once locked, cannot be unlockedbuild_pipeline(optional) - Make the variable available in the Build Pipeline. Default:true
Example cURL request
curl -H "Content-type: application/json" \
-H "Accept: application/json" \
--user your-email@example.com:your-api-key \
-X POST \
-d '{ \
"environment_variable": { \
"name": "SHARED_API_KEY", \
"value": "secret_value_here", \
"locked": false, \
"build_pipeline": true \
} \
}' \
https://your-account.deployhq.com/global_environment_variables
Example response
{
"identifier": 125,
"name": "SHARED_API_KEY",
"masked_value": "••••••••",
"locked": false,
"build_pipeline": true,
"created_at": "2025-01-27T12:30:00.000Z",
"updated_at": "2025-01-27T12:30:00.000Z"
}
Notes
- Variable names can be lowercase, uppercase, or mixed case (e.g.,
database_url,DATABASE_URL,DatabaseUrl) - Values are always encrypted and never visible after creation
- Locked variables provide an extra layer of security as their values cannot be viewed or changed once locked
- Global variables apply to all projects on the account. A project-level variable with the same name will override the global value