# Write environment variable

Tool: `veryfront__write_environment_variable`

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

## Arguments

| Name                | Type                  | Required | Description                                                                                                     |
| ------------------- | --------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
| `project_reference` | string                |          | Project ID or slug                                                                                              |
| `environment_id`    | string · uuid         | Yes      | Environment ID to create the variable in.                                                                       |
| `key`               | string · min length 1 | Yes      | Variable name (e.g., API\_KEY, DATABASE\_URL). Creates the variable, or replaces the value when the key exists. |
| `value`             | string                | Yes      | Variable value. It is never returned.                                                                           |

## Responses

| Status | Description                                           |
| ------ | ----------------------------------------------------- |
| 200    | The tool ran; its output is result.structuredContent. |

## Call it

```bash
curl -X POST -N "https://api.veryfront.com/mcp" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Accept: application/json, text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "veryfront__write_environment_variable",
    "arguments": {
      "environment_id": "00000000-0000-0000-0000-000000000000",
      "key": "A",
      "value": "string"
    }
  }
}'
```

## Example response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\"id\":\"00000000-0000-0000-0000-000000000000\",\"key\":\"string\",\"value\":\"********\",\"has_value\":false}"
      }
    ],
    "structuredContent": {
      "id": "00000000-0000-0000-0000-000000000000",
      "key": "string",
      "value": "********",
      "has_value": false
    }
  }
}
```
