variables Command - Medusa Cloud CLI Reference
In this guide, you'll learn how to inspect and manage the environment variables of a Cloud environment using the CLI.
variables list#
List all environment variables for a Cloud environment.
Options#
Option | Description | Required | Default |
|---|---|---|---|
| The ID of the organization that the environment belongs to. | Yes | Falls back to the organization in the active context, if set. |
| The ID or handle of the project that the environment belongs to. | Yes | Falls back to the project in the active context, if set. |
| The handle of the environment to list variables from. | Yes | Falls back to the environment in the active context, if set. |
| The type of variables to list. Accepts | No |
|
| Print secret values in plain text instead of masking them. | No |
|
| Include system variables that Medusa auto-injects into the environment. | No |
|
| Filter variables by scope. Accepts | No | Both scopes |
| Output the variables in | No |
|
| Print the result as JSON instead of formatted text. | No |
|
variables get#
Retrieve a single variable by its ID (var_...) or by its key. Looking up by key requires --project and --environment (or the equivalent values in the active context) so the CLI knows which environment to search.
You can also fetch a variable by ID without setting the active environment:
This returns the variable's details, similar to the following:
Arguments#
Option | Description | Required |
|---|---|---|
| Variable ID ( | Yes |
Options#
Option | Description | Required | Default |
|---|---|---|---|
| The ID of the organization that the variable belongs to. | Yes | Falls back to the organization in the active context, if set. |
| The ID or handle of the project that the variable belongs to. Required when looking up by key. | Conditional | Falls back to the project in the active context, if set. |
| The handle of the environment that the variable belongs to. Required when looking up by key. | Conditional | Falls back to the environment in the active context, if set. |
| The type of variable to get. Accepts | No |
|
| Print the secret value in plain text instead of masking it. | No |
|
| Print the result as JSON instead of formatted text. | No |
|
variables set#
Create or update one or more environment variables. Pass a single variable and value as arguments, or set multiple variables at once using --var or --env-file.
The CLI updates a variable when you reference it by ID (var_...) or by an existing key, and creates a new variable when the key doesn't exist yet. Creating or looking up a variable by key requires --project and --environment (or the equivalent values in the active context).
To set multiple variables at once, use --var for each variable or point to a .env file with --env-file:
Terminal❯mcloud variables set --env-file .env
Redeploy or Rebuild to Apply Changes#
Setting a variable saves it to the environment but doesn't rebuild or redeploy your application. The running deployment keeps using the previous values until you deploy again:
- For a runtime variable (
--runtime), runmcloud environments redeployto re-run the active build with the new value. - For a build variable (
--build), runmcloud environments trigger-buildto start a new build. A redeploy reuses the existing image and won't pick up build variable changes.
Arguments#
Option | Description | Required |
|---|---|---|
| Variable ID ( | No |
| The value to set for the variable. Required when a | No |
Options#
Option | Description | Required | Default |
|---|---|---|---|
| The ID of the organization that the variable belongs to. | Yes | Falls back to the organization in the active context, if set. |
| The ID or handle of the project that the variable belongs to. Required when setting a variable by key. | Conditional | Falls back to the project in the active context, if set. |
| The handle of the environment that the variable belongs to. Required when setting a variable by key. | Conditional | Falls back to the environment in the active context, if set. |
| The type of variable to set. Accepts | No |
|
| A variable to set in the format | No | - |
| Path to a | No | - |
| Whether the variable is a secret. Pass | No |
|
| Whether the variable is available at build time. | No |
|
| Whether the variable is available at runtime. Pass | No |
|
| Print the result as JSON instead of formatted text. | No |
|
variables delete#
Delete an environment variable by its ID (var_...) or key. Looking up by key requires --project and --environment (or the equivalent values in the active context).
Without --yes, the CLI prompts you to confirm the deletion. In a non-interactive environment (such as a CI pipeline), you must pass --yes, otherwise the command errors out.
Redeploy or Rebuild to Apply Changes#
Like setting a variable, deleting one doesn't rebuild or redeploy your application. Redeploy the environment with , or start a new build with if the variable was a build variable, for the change to take effect.
Arguments#
Option | Description | Required |
|---|---|---|
| Variable ID ( | Yes |
Options#
Option | Description | Required | Default |
|---|---|---|---|
| The ID of the organization that the variable belongs to. | Yes | Falls back to the organization in the active context, if set. |
| The ID or handle of the project that the variable belongs to. Required when deleting by key. | Conditional | Falls back to the project in the active context, if set. |
| The handle of the environment that the variable belongs to. Required when deleting by key. | Conditional | Falls back to the environment in the active context, if set. |
| The type of variable to delete. Accepts | No |
|
| Skip the confirmation prompt and delete the variable. Required in non-interactive environments. | No |
|
| Print the result as JSON instead of formatted text. | No |
|
Reveal Secret Values#
By default, the CLI masks values for variables marked as secrets. Pass --reveal to print the plaintext value:
--reveal on shared terminals or in shell history. The plaintext value is printed to standard output, which is captured by terminal scrollback, log aggregators, and process listings.Export Variables to a .env File#
Use the --dotenv flag with --reveal to output the variables in .env file format, then write them to a local .env file. This is useful for replicating a Cloud environment's variables to a local development environment:
--reveal prints secret values in plain text. Avoid running this on shared terminals or storing the resulting .env file in version control.