# writeEnvironmentVariable

```graphql
mutation WriteEnvironmentVariable($input: WriteEnvironmentVariableInput!) {
  writeEnvironmentVariable(input: $input) {
    id
    key
    value
    hasValue
  }
}
```

Set one environment variable, creating it or replacing its value. Requires project.env\_vars.write.

## Arguments

| Name                  | Type                           | Required | Description                                                        |
| --------------------- | ------------------------------ | -------- | ------------------------------------------------------------------ |
| `input`               | WriteEnvironmentVariableInput! | Yes      |                                                                    |
| `input.environmentId` | ID!                            | Yes      | Environment UUID.                                                  |
| `input.key`           | String!                        | Yes      | Variable key. The variable is created when the key does not exist. |
| `input.value`         | String!                        | Yes      | Variable value, at least one character. It is never returned.      |

## Variables

```json
{
  "input": {
    "environmentId": "string",
    "key": "string",
    "value": "string"
  }
}
```

## Responses

| Status | Description                                                |
| ------ | ---------------------------------------------------------- |
| 200    | The EnvironmentVariable! in data.writeEnvironmentVariable. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation WriteEnvironmentVariable($input: WriteEnvironmentVariableInput!) {\n  writeEnvironmentVariable(input: $input) {\n    id\n    key\n    value\n    hasValue\n  }\n}",
  "variables": {
    "input": {
      "environmentId": "string",
      "key": "string",
      "value": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "writeEnvironmentVariable": {
      "id": "string",
      "key": "string",
      "value": "string",
      "hasValue": false
    }
  }
}
```
