# Add an environment

Add an [environment](/docs/concepts/project-lifecycle.md#environments), such as QA to try a release before it goes live, and choose who can open it. A new project already has Preview, Staging and Production.

## Before you start

You need a project. See [Create a project](/docs/projects/create-project.md).

## Create an environment

**Studio**

1. In your project, open **Runtime** > **Environments**.
2. Click **Create environment**.
3. Enter `qa` in **Name**.
4. Click **Create**. You should now see **Private** on the environment's page: only people on the project can open it.
5. To open it to anyone with the URL, turn on **Public environment** under **Visibility**. This needs the Pro plan.
6. Click **Make public**. You should now see "Environment updated" and **Public** beside the name.

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Create the environment with your [API key](/docs/authentication/api-keys.md). New environments are private (`"protected": true`):

```bash
curl -X POST https://api.veryfront.com/projects/$PROJECT/environments \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "qa"}'
```

3. List the environments. You should now see `qa` there:

```bash
curl https://api.veryfront.com/projects/$PROJECT/environments \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

4. Set `ENVIRONMENT_ID` to `qa`'s `id`: `export ENVIRONMENT_ID=<id>`.
5. Make it public. This needs the Pro plan. You should now see `"protected": false` in the answer:

```bash
curl -X PATCH https://api.veryfront.com/projects/$PROJECT/environments/$ENVIRONMENT_ID \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"protected": false}'
```

## Delete an environment

**Studio**

1. On the environment's page, open the **⋯** menu at the top.
2. Click **Delete environment**.
3. Confirm with **Delete environment**. You should now see "Environment deleted" and the list without `qa`.

## With MCP

1. Call `veryfront__create_environment` with `{ "project_reference": "my-project", "name": "qa" }`.
2. Call `veryfront__list_environments` with `{ "project_reference": "my-project" }`, and take the `id` of `qa`. It is listed with `"protected": true`.
3. Call `veryfront__update_environment` with `{ "project_reference": "my-project", "environment_id": "<the id>", "protected": false }`. This needs the Pro plan.
4. Call `veryfront__list_environments` with `{ "project_reference": "my-project" }` again. It worked when `qa` is listed with `"protected": false`.

## Next steps

* [Add a domain](/docs/runtime/domains.md)
* [Set variables](/docs/runtime/environments.md)
