---
title: "Add or update an environment variable"
method: PUT
path: "/context/{context_id}/environment-variable/{env_var_name}"
tags: ["Context"]
---

# Add or update an environment variable

`PUT /context/{context_id}/environment-variable/{env_var_name}`

Create or update an environment variable within a context. Returns information about the environment variable, not including its value.

## Path parameters

- `context_id` string, uuid, required
- `env_var_name` string, required

## Request body

- object
  - `value` string, required — The value of the environment variable

## Response `200`

The new environment variable

- union
  - object
    - `variable` string, required — The name of the environment variable
    - `created_at` string, date-time, required — The date and time the environment variable was created.
    - `updated_at` string, date-time, required — The date and time the environment variable was updated
    - `context_id` string, uuid, required — ID of the context (UUID)
  - object — message response
    - `message` string, required — A human-readable message

## Other responses

- `401` — Credentials provided are invalid.
- `404` — Entity not found.
- `429` — API rate limits exceeded.
- `500` — Internal server error.

---

[API](https://skmtc.net/circleci/apis/api-v2.md) · [All operations](https://skmtc.net/circleci/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/circleci/api-v2/versions/b9c0e0c24058/schema)
