Env Command
The fastapi cloud env command manages environment variables for your FastAPI Cloud applications.
This command provides subcommands to list, set, and delete environment variables directly from the CLI.
fastapi cloud env [COMMAND] [OPTIONS]Available Subcommands:
list- List all environment variables for the appset- Set or update an environment variabledelete- Delete an environment variable
List Command
Section titled “List Command”List all environment variables for your application.
fastapi cloud env list [PATH]Arguments:
[PATH]- Optional. Path to the folder containing the app (defaults to current directory)
Examples
Section titled “Examples”List variables for current directory:
fastapi cloud env listList variables for specific path:
fastapi cloud env list ./my-appWhat You’ll See
Section titled “What You’ll See”When variables exist:
Environment variables:
DATABASE_URLAPI_KEYDEBUG_MODEWhen no variables exist:
No environment variables found.Set Command
Section titled “Set Command”Set a new environment variable or update an existing one.
fastapi cloud env set [NAME] [VALUE] [PATH]Arguments:
[NAME]- Optional. The name of the environment variable to set (will prompt if not provided)[VALUE]- Optional. The value of the environment variable (will prompt if not provided)[PATH]- Optional. Path to the folder containing the app (defaults to current directory)
Set Examples
Section titled “Set Examples”Set with all arguments:
fastapi cloud env set DATABASE_URL postgresql://localhost/mydbInteractive mode (prompts for name and value):
fastapi cloud env setYou’ll see:
Enter the name of the environment variable to set: API_KEYEnter the value of the environment variable to set: [hidden]Environment variable API_KEY set.Set for specific path:
fastapi cloud env set API_KEY secret123 ./my-appImportant Notes
Section titled “Important Notes”When you don’t provide the value as an argument, the CLI prompts for it with hidden input (password mode) for security.
Setting an environment variable through the CLI does not automatically redeploy your application. Changes will take effect on the next deployment.
Delete Command
Section titled “Delete Command”Delete an environment variable from your application.
fastapi cloud env delete [NAME] [PATH]Arguments:
[NAME]- Optional. The name of the environment variable to delete (will show selection menu if not provided)[PATH]- Optional. Path to the folder containing the app (defaults to current directory)
Delete Examples
Section titled “Delete Examples”Delete by name:
fastapi cloud env delete API_KEYYou’ll see:
Environment variable API_KEY deleted.Interactive selection:
fastapi cloud env deleteThis will show a menu to select which variable to delete.
Delete from specific path:
fastapi cloud env delete DEBUG_MODE ./my-appIf Variable Doesn’t Exist
Section titled “If Variable Doesn’t Exist”Environment variable not found.Managing Environment Variables from the Dashboard
Section titled “Managing Environment Variables from the Dashboard”You can also manage environment variables through the FastAPI Cloud dashboard, which provides additional features like:
- Marking variables as secrets (encrypted)
- Bulk importing from
.envfiles - Immediate redeployment after changes
See the Environment Variables documentation for more details.
Troubleshooting
Section titled “Troubleshooting”Error: No credentials found
Section titled “Error: No credentials found”You need to log in first:
fastapi loginError: No app found
Section titled “Error: No app found”Deploy your application first to create the configuration:
fastapi deployRelated Commands
Section titled “Related Commands”fastapi deploy- Deploy your app (required before using env commands)fastapi login- Authenticate with FastAPI Cloudfastapi cloud unlink- Remove local app configuration
Related Documentation
Section titled “Related Documentation”- Environment Variables - Complete guide to managing environment variables