Automate Environment Variable Management with the CLI or API
Instead of using Runtime Admin to manage environment variables from the UI, automate the environment variable administration with the B2C CLI or the Managed Runtime API.
Also, access environment variables in Node.js by using process.env.
Use the B2C CLI to list all environment variables for an environment, update an environment variable value, and create environment variables from an environment file.
The B2C CLI examples use placeholder values for the project and the environment formatted as <placeholder-value>. Replace placeholders with the actual values for your storefront. To get the project ID, see Find a Project.
For installation instructions, see B2C CLI, MCP and Tooling SDK to install the tool and authenticate.
Use this command to list all environment variables for a specific project and environment.
Alternative command:
To unset an existing environment variable, set its value to null.
Modifying environment variables redeploys the environment. The updated values are available when the deploy completes.
The --yes argument causes the suppression of the confirmation prompt.
When you add a new environment variable, wait for the redeploy of the bundle to complete, and then deploy a new bundle that uses the new variable.
For a complete list of MRT commands, see MRT Commands in the B2C Developer Toolkit.
Use the Managed Runtime API to list all environment variables for an environment and update an environment variable value.
To make API requests, you must include an API key in the HTTP request Authorization header with the value, Bearer $API_KEY. To find your API key, log in to the Runtime Admin tool and go to the Account Settings page.
Treat your API key like a password because it allows scripts to perform operations on your behalf.
This tutorial uses sample curl requests. Before running the commands, replace any placeholders with actual values. Placeholders are formatted as $PLACEHOLDER. Replace $PROJECT_ID with your actual project ID. To get the project ID, see Find a Project.
Use projects_target_env_var_list:
Use projects_target_env_var_partial_update:
To unset an existing environment variable, set its value to null.
Modifying environment variables redeploys the environment. The updated values are available when the deploy completes.