This method allows you to update an existing global environment variable for your account.

**Tip**: You can explore and test this endpoint interactively using our [OpenAPI documentation](https://api.deployhq.com/docs).

## URL

```text
/global_environment_variables/<id>
```

* Replace `<id>` with the identifier of the environment variable.

## HTTP Method

```http
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 to `name` and `value`. Once set to `true`, cannot be changed back to `false`. Other attributes like `build_pipeline` can still be updated
* `build_pipeline` (optional) - Make the variable available in the Build Pipeline

## Example cURL request

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

## Example response

```json
{
  "identifier": 125,
  "name": "SHARED_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
