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

-o <id>, --organization <id>

The ID of the organization that the environment belongs to.

Yes

Falls back to the organization in the active context, if set.

-p <id-or-handle>, --project <id-or-handle>

The ID or handle of the project that the environment belongs to.

Yes

Falls back to the project in the active context, if set.

-e <handle>, --environment <handle>

The handle of the environment to list variables from.

Yes

Falls back to the environment in the active context, if set.

-t <type>, --type <type>

The type of variables to list. Accepts backend or storefront.

No

backend

--reveal

Print secret values in plain text instead of masking them.

No

false

--include-system

Include system variables that Medusa auto-injects into the environment.

No

false

--scope <scope>

Filter variables by scope. Accepts build or runtime, and you can pass it multiple times to include more than one scope. By default, both build and runtime variables are included.

No

Both scopes

--dotenv

Output the variables in .env file format (KEY=VALUE lines) instead of a table.

No

false

--json

Print the result as JSON instead of formatted text.

No

false


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:

Terminal
mcloud variables get var_01XYZ

This returns the variable's details, similar to the following:

Arguments#

Option

Description

Required

variable

Variable ID (var_...) or key. When passing a key, you must also provide --project and --environment (or set them in the active context).

Yes

Options#

Option

Description

Required

Default

-o <id>, --organization <id>

The ID of the organization that the variable belongs to.

Yes

Falls back to the organization in the active context, if set.

-p <id-or-handle>, --project <id-or-handle>

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.

-e <handle>, --environment <handle>

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.

-t <type>, --type <type>

The type of variable to get. Accepts backend or storefront.

No

backend

--reveal

Print the secret value in plain text instead of masking it.

No

false

--json

Print the result as JSON instead of formatted text.

No

false


variables set#

Note: This command is available since Medusa mcloud CLI v0.1.10.

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 \  -v API_KEY=pk_123 \  -v CLIENT_ID=my_app
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:

Arguments#

Option

Description

Required

variable

Variable ID (var_...) or key to set. When passing a key, you must also provide --project and --environment (or set them in the active context). Omit when using --var or --env-file.

No

value

The value to set for the variable. Required when a variable argument is passed.

No

Options#

Option

Description

Required

Default

-o <id>, --organization <id>

The ID of the organization that the variable belongs to.

Yes

Falls back to the organization in the active context, if set.

-p <id-or-handle>, --project <id-or-handle>

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.

-e <handle>, --environment <handle>

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.

-t <type>, --type <type>

The type of variable to set. Accepts backend or storefront.

No

backend

-v <var>, --var <var>

A variable to set in the format ID=VALUE or KEY=VALUE. Pass it multiple times to set more than one variable. Keys require --project and --environment.

No

-

--env-file <path>

Path to a .env file whose variables are set on the environment.

No

-

--secret, --no-secret

Whether the variable is a secret. Pass --no-secret to explicitly mark it as not secret.

No

false for new variables

--build, --no-build

Whether the variable is available at build time.

No

false for new variables

--runtime, --no-runtime

Whether the variable is available at runtime. Pass --no-runtime to disable it.

No

true for new variables

--json

Print the result as JSON instead of formatted text.

No

false


variables delete#

Note: This command is available since Medusa mcloud CLI v0.1.10.

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).

Warning: Deleting a variable is irreversible. You can't delete system variables that Medusa auto-injects into the environment.

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 mcloud environments redeploy, or start a new build with mcloud environments trigger-build if the variable was a build variable, for the change to take effect.

Arguments#

Option

Description

Required

variable

Variable ID (var_...) or key to delete. When passing a key, you must also provide --project and --environment (or set them in the active context).

Yes

Options#

Option

Description

Required

Default

-o <id>, --organization <id>

The ID of the organization that the variable belongs to.

Yes

Falls back to the organization in the active context, if set.

-p <id-or-handle>, --project <id-or-handle>

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.

-e <handle>, --environment <handle>

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.

-t <type>, --type <type>

The type of variable to delete. Accepts backend or storefront.

No

backend

-y, --yes

Skip the confirmation prompt and delete the variable. Required in non-interactive environments.

No

false

--json

Print the result as JSON instead of formatted text.

No

false


Reveal Secret Values#

By default, the CLI masks values for variables marked as secrets. Pass --reveal to print the plaintext value:

Warning: Avoid --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.
Terminal
mcloud variables get DATABASE_URL --reveal

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:

Terminal
mcloud variables list --reveal --dotenv > .env
Warning: --reveal prints secret values in plain text. Avoid running this on shared terminals or storing the resulting .env file in version control.
Was this guide helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Medusa MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break