# Environment variables

Before you can develop and deploy apps, you need to configure environment variables with your organization's specific settings and access tokens.

## Basic setup[​](#basic-setup "Direct link to Basic setup")

### Step 1: Copy the sample environment file[​](#step-1-copy-the-sample-environment-file "Direct link to Step 1: Copy the sample environment file")

Create your development environment file from the provided template:

```
cp .config/dev.env.sample .config/dev.env
```

### Step 2: Configure your environment variables[​](#step-2-configure-your-environment-variables "Direct link to Step 2: Configure your environment variables")

Open `.config/dev.env` and update the following variables:

1. **Get your access token**: Request the `COMIND_SECRET_AUTH_CODE_MANAGEMENT` token from your admin

   Security

   This is a secret token - never commit it to version control or share it publicly

2. **Set your organization URL**: Replace `YOUR-ORG` with your actual organization name

.config/dev.env

```
# (!) Do not commit or expose this secret code:
COMIND_SECRET_AUTH_CODE_MANAGEMENT=COPY-CODE-HERE--GET-FROM-ADMIN

# URLs - replace YOUR-ORG with your actual organization name
COMIND_BASE_URL=https://YOUR-ORG.comindwork.com
COMIND_API_V1_URL=https://api.comindwork.com
```

### Step 3: Verify your setup[​](#step-3-verify-your-setup "Direct link to Step 3: Verify your setup")

Test your configuration by installing an existing app from your repository:

```
npx comind install app-your-task
```

If this command succeeds, your environment variables are configured correctly.

## Working with multiple environments[​](#working-with-multiple-environments "Direct link to Working with multiple environments")

Most teams maintain at least two environments - a development site for testing and a production site for live users. The recommended workflow:

1. **Develop and test on dev** - make all changes with `COMIND_ENV=dev`
2. **Verify the result** - check the app on the dev site before proceeding
3. **Switch to prod and deploy** - change `COMIND_ENV=prod`, run the install command, verify on the live site
4. **Switch back to dev immediately** - do not leave your environment pointed at production

Always switch back to dev

Leaving `COMIND_ENV=prod` active risks accidental deployments to production. Make switching back to `dev` the last step of every production deploy.

If you need to work with multiple sites (development, UAT, production), you can create separate environment files:

* `.config/dev.env` - Development environment
* `.config/uat.env` - User Acceptance Testing environment
* `.config/prod.env` - Production environment

### Switching between environments[​](#switching-between-environments "Direct link to Switching between environments")

1. Copy the sample environment switcher:

   ```
   cp .env-sample .env
   ```

2. Edit the root `.env` file to specify which environment to use. Comment/uncomment the line you need:

   .env

   ```
   COMIND_ENV=dev
   # COMIND_ENV=uat
   # COMIND_ENV=prod
   ```

The system will automatically load the corresponding `.config/{environment}.env` file based on your selection.

## Multi-environment configuration[​](#multi-environment-configuration "Direct link to Multi-environment configuration")

The `COMIND_ENV` variable controls which environment file the CLI loads at runtime. Set it in the root `.env` file to one of three values: `dev`, `uat`, or `prod`. The CLI then reads the matching `.config/{env}.env` file - for example, `COMIND_ENV=prod` loads `.config/prod.env`.

If you omit `COMIND_ENV` or leave it empty, the system defaults to `dev`.

### Setting up production[​](#setting-up-production "Direct link to Setting up production")

Follow these steps to configure a production environment:

1. **Copy the dev config as a starting point:**

   ```
   cp .config/dev.env .config/prod.env
   ```

2. **Update production values** in `.config/prod.env` - set the API key and base URL to your production organization:

   .config/prod.env

   ```
   COMIND_SECRET_AUTH_CODE_MANAGEMENT=YOUR-PRODUCTION-TOKEN
   COMIND_BASE_URL=https://your-org.comindwork.com
   COMIND_API_V1_URL=https://api.comindwork.com
   ```

3. **Activate the production environment** by commenting out `dev` and uncommenting `prod` in the root `.env` file:

   .env

   ```
   # COMIND_ENV=dev
   COMIND_ENV=prod
   ```

4. **Verify the configuration** by running a small install command to confirm it targets the production site:

   ```
   npx comind install app-your-task
   ```

5. **Switch back to development** when you are done - comment out `prod` and uncomment `dev`:

   .env

   ```
   COMIND_ENV=dev
   # COMIND_ENV=prod
   ```

Never commit env files with secrets

The `.config/*.env` files contain access tokens and other secrets. They are listed in `.gitignore` by default - do not remove them from `.gitignore` or commit them to version control. If you need to share credentials with a teammate, use a secure channel like a password manager or encrypted message.

## Related[​](#related "Direct link to Related")

* [Production deployment](/developer-guide/how-to/advanced/production-deployment.md) - multi-environment configuration and deploy user setup for production
* [CLI reference](/developer-guide/reference/cli-reference.md) - the `install`, `push`, and `pull` commands that consume these environment variables
