> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpostchi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Environments

> Environments let you switch between different sets of variables — dev, staging, production — without editing your requests.

An environment is a named section of variables inside a `.cenv` file. When you select an active environment, Postchi substitutes its variables into every request you run. Switch environments from the toolbar to instantly point your requests at a different server, token, or configuration.

## The .cenv format

Environment files use the `.cenv` format: named sections marked with a `#` comment, each containing `key=value` pairs.

```ini theme={null}
# Production
base_url=https://api.example.com
api_token=prod-token-here

# Development
base_url=https://dev.api.example.com
api_token=dev-token-here
```

Each `# Section Name` header starts a new environment. You can define as many environments as you need in a single file.

## Variables and secrets

Your project contains two environment files:

<CardGroup cols={2}>
  <Card title="environments.cenv" icon="leaf">
    Non-sensitive variables like base URLs, and user IDs. Safe to commit to version control.
  </Card>

  <Card title="secrets.cenv" icon="lock">
    Sensitive values like API tokens, passwords, and private keys. Keep this out of version control.
  </Card>
</CardGroup>

<Warning>
  All environments are defined in the **environments** file, secrets can only add variables to the environments defined there, they cannot define their own environments
</Warning>

## Using variables in requests

Reference variables in your request files using `<variable_name>` placeholders. Postchi replaces them with values from the active environment section at run time.

```http theme={null}
GET /users
Authorization: bearer(<api_token>)
```

<Tip>
  Use [Folder Settings](/concepts/collections) to define a base url and define the request using a relative path.
</Tip>

Variables work in URLs, headers, and request bodies. See [Variables](/requests/variables) for the full placeholder syntax.

## Switching environments

Select the active environment from the dropdown in the toolbar or you can switch by pressing <kbd>Cmd</kbd> (or <kbd>Ctrl</kbd> on Windows/Linux) plus a number from 1 to 9.
