Skip to main content
Version: 1.89.x (Q2 26)

Managing Environment Variables

Hardcoding sensitive data—such as API keys, database passwords, or tokens—presents a security risk. To mitigate this, Environment Variables decouple the configuration from the codebase. Codesphere manages these variables via encrypted storage, injecting them into the application at runtime.

Accessing the Variables

You can manage your secrets in the Environment Variables tab of your Landscape.

  1. Open Environment Variables from the sidebar.

Environment Variables

Adding a New Variable

To add a single variable:

  1. Click the + Add New Variable button.
  2. Key: Enter the name of your variable
  3. Value: Enter the secret value.
  4. Click Save.

Note: For security, once a variable is saved, its value is masked. You can view it again by clicking the eye icon next to the value.

Bulk Uploading (.env files)

If you are migrating an existing project, you likely already have a .env file. Instead of typing them in one by one, you can upload the entire file.

  1. Click the Bulk Upload button.
  2. Drag and drop your .env file into the modal, or click to browse.
  3. Click Upload.

Example .env file

STRIPE_API_KEY=scr_12345
TWILIO_API_KEY=abcd1234

Important: This will overwrite any existing variables that share the same key.

Using Variables in Your Application

Once defined, these variables are available to your application just like any system-level environment variable.

const apiKey = process.env.KEY_NAME;

In Your CI Pipeline (ci.yml): You can also reference these environment variables in your build or run commands using standard shell syntax.

run:
steps:
- name: SERVERNAME
command: ./your-app-server --api-key=$KEYNAME

You can define service-specific environment variables directly in the ci.yml. See Configuring Your CI Pipeline for details. They can also reference workspace-level environment variables defined in the UI using templating:

run: 
my-service:
env:
KEY_NAME: {{ workspace.env.WORKSPACE_ENV_NAME }}