This method allows you to create a new environment variable for a project.

**Tip**: You can explore and test this endpoint interactively using our [OpenAPI documentation](https://api.deployhq.com/docs).

## URL

```
/projects/<permalink>/environment_variables
```

* Replace `<permalink>` with the permalink of the project.

## HTTP Method

```
POST
```

## Supported Parameters

* `name` (required) - The variable name. Must start with a letter and contain only letters, numbers, and underscores
* `value` (required) - The variable value. Will be encrypted at rest
* `locked` (optional) - Lock the variable to prevent changes. Default: `false`. Once locked, cannot be unlocked
* `build_pipeline` (optional) - Make the variable available in the Build Pipeline. Default: `true`

## Example cURL request

```bash
curl -H "Content-type: application/json" \
-H "Accept: application/json" \
--user your-email@example.com:your-api-key \
-X POST \
-d '{ \
  "environment_variable": { \
    "name": "API_KEY", \
    "value": "secret_value_here", \
    "locked": false, \
    "build_pipeline": true \
  } \
}' \
https://your-account.deployhq.com/projects/your-project/environment_variables
```

## Example response

```json
{
  "identifier": 125,
  "name": "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",
  "url": "https://test.deployhq.com/projects/my-project/environment_variables/125"
}
```

## 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
