> ## Documentation Index
> Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Write environment variable

> Set one environment variable, creating it or replacing its value.

`writeEnvironmentVariable(input: WriteEnvironmentVariableInput!): EnvironmentVariable!`

Requires project.env\_vars.write.

## Arguments

| Argument | Type | Required |
| - | - | - |
| `input` | [`WriteEnvironmentVariableInput!`](https://veryfront.com/docs/cloud/graphql/types/writeenvironmentvariableinput) | Yes |

## Input fields

### input

[`WriteEnvironmentVariableInput`](https://veryfront.com/docs/cloud/graphql/types/writeenvironmentvariableinput)

| Field | Type | Required | Description |
| - | - | - | - |
| `environmentId` | [`ID!`](https://veryfront.com/docs/cloud/graphql/types/id) | Yes | Environment UUID. |
| `key` | [`String!`](https://veryfront.com/docs/cloud/graphql/types/string) | Yes | Variable key. The variable is created when the key does not exist. |
| `value` | [`String!`](https://veryfront.com/docs/cloud/graphql/types/string) | Yes | Variable value, at least one character. It is never returned. |

## Response

Returns [`EnvironmentVariable!`](https://veryfront.com/docs/cloud/graphql/types/environmentvariable). Open the type for its fields and nested types.

| Field | Type |
| - | - |
| `id` | [`ID!`](https://veryfront.com/docs/cloud/graphql/types/id) |
| `key` | [`String!`](https://veryfront.com/docs/cloud/graphql/types/string) |
| `value` | [`String!`](https://veryfront.com/docs/cloud/graphql/types/string) |
| `hasValue` | [`Boolean!`](https://veryfront.com/docs/cloud/graphql/types/boolean) |

Types marked with `!` cannot be null. Lists use `[Type]` notation. The [type index](https://veryfront.com/docs/cloud/graphql/schema.md) lists all published input and response types.

## Example

```graphql title="query.graphql" theme={null}
mutation WriteEnvironmentVariable($input: WriteEnvironmentVariableInput!) {
  writeEnvironmentVariable(input: $input) {
    id
    hasValue
    key
    value
  }
}
```

```json title="variables.json" theme={null}
{
  "input": {
    "environmentId": "00000000-0000-4000-8000-000000000001",
    "key": "example",
    "value": "example"
  }
}
```

<details>
  <summary>Try this mutation</summary>

  Calls use `https://api.veryfront.com/graphql`. Replace sample values with resources you can access. See [Authentication](https://veryfront.com/docs/cloud/authentication.md) for credentials and permissions.

  Bearer token or API key

  Stored in this tab's session. Clear credential

  Mutation

  Variables (JSON)
</details>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.