Skip to content

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.

Terminal window
fastapi cloud env [COMMAND] [OPTIONS]

Available Subcommands:

  • list - List all environment variables for the app
  • set - Set or update an environment variable
  • delete - Delete an environment variable

List all environment variables for your application.

Terminal window
fastapi cloud env list [PATH]

Arguments:

  • [PATH] - Optional. Path to the folder containing the app (defaults to current directory)

List variables for current directory:

Terminal window
fastapi cloud env list

List variables for specific path:

Terminal window
fastapi cloud env list ./my-app

When variables exist:

Environment variables:
DATABASE_URL
API_KEY
DEBUG_MODE

When no variables exist:

No environment variables found.

Set a new environment variable or update an existing one.

Terminal window
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 with all arguments:

Terminal window
fastapi cloud env set DATABASE_URL postgresql://localhost/mydb

Interactive mode (prompts for name and value):

Terminal window
fastapi cloud env set

You’ll see:

Enter the name of the environment variable to set: API_KEY
Enter the value of the environment variable to set: [hidden]
Environment variable API_KEY set.

Set for specific path:

Terminal window
fastapi cloud env set API_KEY secret123 ./my-app

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 an environment variable from your application.

Terminal window
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 by name:

Terminal window
fastapi cloud env delete API_KEY

You’ll see:

Environment variable API_KEY deleted.

Interactive selection:

Terminal window
fastapi cloud env delete

This will show a menu to select which variable to delete.

Delete from specific path:

Terminal window
fastapi cloud env delete DEBUG_MODE ./my-app
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 .env files
  • Immediate redeployment after changes

See the Environment Variables documentation for more details.

You need to log in first:

Terminal window
fastapi login

Deploy your application first to create the configuration:

Terminal window
fastapi deploy
  • fastapi deploy - Deploy your app (required before using env commands)
  • fastapi login - Authenticate with FastAPI Cloud
  • fastapi cloud unlink - Remove local app configuration