---
title: "Create an environment variable"
method: POST
path: "/project/{project-slug}/envvar"
tags: ["Project"]
---

# Create an environment variable

`POST /project/{project-slug}/envvar`

## Request

- Base URL: `https://circleci.com/api/v2`
- URL: `https://circleci.com/api/v2/project/{project-slug}/envvar`
- Auth: one of:
  - API key in header `Circle-Token`
  - HTTP bearer
  - HTTP basic
  - API key in query parameter `circle-token`

Creates a new environment variable.

## Path parameters

- `project-slug` string, required

## Request body

- object: An environment variable request requires a name and a value
  - `name` string, required: The name of the environment variable.
  - `value` string, required: The value of the environment variable.

## Response `201`

The environment variable.

- object: An environment variable is a map containing a value and an optional timestamp.
  - `name` string, required: The name of the environment variable.
  - `value` string, required: The value of the environment variable.
  - `created-at` string: The creation timestamp of the environment variable.

## Other responses

- `default`: Error response.

---

[API](https://skmtc.dev/circleci/apis/circleci-api.md) - [All operations](https://skmtc.dev/circleci/apis/circleci-api/llms.txt) - [OpenAPI document](https://skmtc.dev/circleci/apis/circleci-api/revisions/b9c0e0c24058?raw)
