Update an environment variable via API

This method allows you to update an existing environment variable for a project.

URL

/projects/<permalink>/environment_variables/<id>
  • Replace <permalink> with the permalink of the project.
  • Replace <id> with the identifier of the environment variable.

HTTP Method

PATCH

Supported Parameters

  • name (optional) - The variable name. Must start with a letter and contain only letters, numbers, and underscores
  • value (optional) - The variable value. Will be encrypted at rest
  • locked (optional) - Lock the variable to prevent future changes. Once set to true, cannot be changed back to false
  • build_pipeline (optional) - Make the variable available in the Build Pipeline

Example cURL request

curl -H "Content-type: application/json" \
-H "Accept: application/json" \
--user your-email@example.com:your-api-key \
-X PATCH \
-d '{ \
  "environment_variable": { \
    "name": "API_KEY_UPDATED", \
    "build_pipeline": false \
  } \
}' \
https://your-account.deployhq.com/projects/your-project/environment_variables/125

Example response

{
  "identifier": 125,
  "name": "API_KEY_UPDATED",
  "masked_value": "••••••••",
  "locked": false,
  "build_pipeline": false,
  "created_at": "2025-01-27T12:30:00.000Z",
  "updated_at": "2025-01-27T12:35:00.000Z"
}

Important Notes

  • Locked variables cannot have their name or value changed
  • Once a variable is locked (locked: true), it cannot be unlocked
  • You can lock an unlocked variable by setting locked: true
  • Attempting to modify a locked variable's name or value will return a 422 error
  • You can still modify other attributes (like build_pipeline) on locked variables