Manage Environment Variables
In this guide, you'll learn how to manage environment variables of long-lived and preview environments in Cloud.
Environment variables are key-value pairs of sensitive information, such as API keys and credentials. Instead of hardcoding these variables in your codebase, you should store them as environment variables.
You can manage an environment's variables in its "Settings" tab.
Restricted Environment Variable Names#
The following environment variable names are reserved by Cloud and you can't use them in your environment:
NODE_ENVEXECUTION_CONTEXTDATABASE_URLREDIS_URLMEDUSA_WORKER_MODEPORTK_SERVICEK_CONFIGURATIONK_REVISIONK_CONTAINER_NAMEK_INTERNAL_POD_NAMEK_INTERNAL_POD_NAMESPACEK_LOCAL_ADDRK_PROTOCOLSESSION_STOREDYNAMO_DB_SESSIONS_TABLEDYNAMO_DB_SESSIONS_HASH_KEYDYNAMO_DB_SESSIONS_PREFIXAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGION
Add Environment Variables on Cloud#
To add environment variables to an environment:
- In the environment's dashboard, click on the "Settings" tab.
- Choose the "Environment Variables" tab from the sidebar.
- In the "Add new environment variables" section, there are different ways you can add environment variables:
- Manually:
- Enter the key and value of the environment variable in the respective fields.
- Click the "Add another" button to add another variable.
- Paste
.envformat:- If you copied environment variables in a
.envfile format, you can paste them directly into the "Key" field. The environment variables will be pre-filled for you.
- If you copied environment variables in a
- Import
.envfile:- If you have a
.envfile that defines your environment variables, click the "Import .env" button to upload the file. The environment variables will be automatically extracted and added to the list.
- If you have a
- Manually:
- Once you're done, click the "Save" button to save the environment variables.

Edit Environment Variables on Cloud#
To edit an environment variable:
- In the environment's dashboard, click on the "Settings" tab.
- Choose the "Environment Variables" tab from the sidebar.
- In the "Environment variables" section, find the variable you want to edit.
- Click the icon at the variable's right side.
- Choose "Edit" from the dropdown menu.

- In the side window that opens, you can edit the variable's key, value, and whether it's sensitive.
- Once you're done, click the "Save" button.

Delete Environment Variables on Cloud#
To delete an environment variable:
- In the environment's dashboard, click on the "Settings" tab.
- Choose the "Environment Variables" tab from the sidebar.
- In the "Environment variables" section, find the variable you want to delete.
- Click the icon at the variable's right side.
- Choose "Delete" from the dropdown menu.

Export Environment Variables on Cloud#
You can export an environment's variables as a .env file. This is useful for debugging issues that require you to have the same environment variables.
To export an environment's variables:
- In the environment's dashboard, click on the "Settings" tab.
- Choose the "Environment Variables" tab from the sidebar.
- In the "Environment variables" section, click on the "Export .env" button at the top right of the section.
A file download will start with the name env.txt, which contains the environment variables in .env format.
You can rename the file to .env and use it in your local development.
