env:set
Use env:set to create or update an environment variable for your project.
About env:set
This section describes how key creations and updates are performed.
When you run this command, it validates your key name against AWS Lambda restrictions and reserved prefixes. If the variable already exists under the target environment, the command updates its value; otherwise, it creates a new record. The command outputs the finalized variable as a JSON object directly to your terminal.
Using env:set
This section provides a repeatable workflow for creating or updating a variable.
Concept and Goal
To configure secrets or environment options for your application code, use this procedure to set an environment variable.
What you need
- You installed the CLI package.
- You set
MONOLAYER_BASE_URLor plan to pass--base-url. - You set
MONOLAYER_AUTH_TOKEN(must be a deployment token starting withdeploy_token_) or plan to pass--auth-token.
Numbered Steps
- Run the command with explicit flags to set a variable.
npx mnlyr env:set \
--base-url https://control-plane-domain \
--auth-token deploy_token_xxx \
--project-id proj-1 \
--key API_KEY \
--value some-value \
--environment production- Run the command using environment variables when you prefer session defaults.
MONOLAYER_BASE_URL="https://control-plane-domain" \
MONOLAYER_AUTH_TOKEN="deploy_token_xxx" \
npx mnlyr env:set --project-id proj-1 --key API_KEY --value some-value --environment productionExpected Result
The command returns the created or updated variable details as a JSON object on successful completion.
env:set Reference
This section lists command syntax, options, and sample output.
Command syntax
npx mnlyr env:set [options]Options
| Option | Description |
|---|---|
--base-url <url> | Sets the control plane base URL. You can also set MONOLAYER_BASE_URL. |
--auth-token <token> | Sets the project deployment auth token. You can also set MONOLAYER_AUTH_TOKEN. |
--project-id <id> | The identifier of your project. This option is required. |
--key <name> | The environment variable name. This option is required. |
--value <val> | The environment variable value. This option is required. |
--environment <env> | The target environment scope (e.g. production, preview). This is required. |
-h, --help | Shows command help. |
Output
{
"name": "API_KEY",
"value": "some-value",
"environment": "production",
"updatedAt": "2026-06-19T11:23:17.000Z"
}Troubleshooting
This section lists common command errors.
- Missing base URL:
Missing base URL. Pass --base-url explicitly or set MONOLAYER_BASE_URL. - Missing authentication token:
Missing auth token. Pass --auth-token explicitly or set MONOLAYER_AUTH_TOKEN. - Invalid token format:
auth-token must start with "deploy_token_" - Reserved Key Name:
Invalid environment(returned when trying to use reserved AWS prefixes likeAWS_or_HANDLER).