---
title: "PATCH /accounts/{account_id}/env/{key}"
method: PATCH
path: "/accounts/{account_id}/env/{key}"
tags: ["environmentVariables"]
---

# PATCH /accounts/{account_id}/env/{key}

`PATCH /accounts/{account_id}/env/{key}`

Updates or creates a new value for an existing environment variable.

## Path parameters

- `account_id` string, required
- `key` string, required

## Query parameters

- `site_id` string

## Request body

- object
  - `context` 'all' | 'dev' | 'dev-server' | 'branch-deploy' | 'deploy-preview' | 'production' | 'branch' — The deploy context in which this value will be used. `dev` refers to local development when running `netlify dev`. `branch` must be provided with a value in `context_parameter`.
  - `context_parameter` string — An additional parameter for custom branches. Currently, this is used for providing a branch name when `context=branch`.
  - `value` string — The environment variable's unencrypted value

## Response `201`

Created (success)

- EnvVar — Environment variable model definition
  - `key` string — The environment variable key, like ALGOLIA_ID (case-sensitive)
  - `scopes` string[] — The scopes that this environment variable is set to
  - `values` EnvVarValue[] — An array of Value objects containing values and metadata
    - `id` string — The environment variable value's universally unique ID
    - `value` string — The environment variable's unencrypted value
    - `context` 'all' | 'dev' | 'dev-server' | 'branch-deploy' | 'deploy-preview' | 'production' | 'branch' — The deploy context in which this value will be used. `dev` refers to local development when running `netlify dev`.
    - `context_parameter` string — An additional parameter for custom branches. Currently, this is used for specifying a branch name when `context=branch`.
  - `is_secret` boolean — Secret values are only readable by code running on Netlify's systems. With secrets, only the local development context values are readable from the UI, API, and CLI. By default, environment variable values are not secret.
  - `updated_at` string, date-time — The timestamp of when the value was last updated
  - `updated_by` EnvVarUser
    - `id` string — The user's unique identifier
    - `full_name` string — The user's full name (first and last)
    - `email` string — The user's email address
    - `avatar_url` string — A URL pointing to the user's avatar

## Other responses

- `default` — error

---

[API](https://skmtc.net/netlify/apis/netlify-s-api-documentation.md) · [All operations](https://skmtc.net/netlify/apis/netlify-s-api-documentation/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/netlify/netlify-s-api-documentation/revisions/71540d1b5d9d/schema)
