Skip to content

Environment Variables

Environment variables allow you to configure your application with app-specific settings and secrets that can be accessed from your code at runtime.

You can manage environment variables through the CLI or the dashboard.

When you first deploy your app, you can set environment variables using the FastAPI Cloud CLI. This is useful for setting up your app’s configuration before deployment. But you can also update them later.

To add environment variables through the web dashboard follow these steps:

  1. Navigate to your App Details view
  2. Click Environment Variables option
  3. Click Add Environment Variable
  4. Enter the variable name and the value
  5. If you want to convert it to a secret and encrypt sensitive values, toggle the Secret switch
  6. Click Add Environment Variable again to add more variables if needed
  7. To remove a variable, just click the trash icon next to it
  8. Choose how to save your changes:
    • Save Only - Saves changes that will apply on the next deployment
    • Save and Redeploy - Saves and immediately redeploys your app with the new variables

Secrets are encrypted environment variables designed for sensitive data like API keys, database passwords, and authentication tokens.

When you mark a variable as a secret the value will be encrypted immediately after saving. This value won’t be visible in the dashboard for security reasons but your application can still access it at runtime.

If you need to update a secret value, you can do so by entering a new value and saving the changes. The new value will be encrypted and replace the old one.

You can also identify secrets by the lock icon in the input field.

  • Always use secrets for sensitive data: Mark API keys, database passwords, and other sensitive information as secrets to ensure they’re encrypted.
  • Use UPPERCASE_WITH_UNDERSCORES: Follow the standard convention (e.g., DATABASE_URL, API_KEY).
  • Secrets are immutable type: Variables can only be marked as secrets during creation. You cannot convert existing regular variables to secrets or vice versa.
  • No secret visibility: Secret values cannot be viewed after creation for security reasons.
  • Lost secrets must be replaced: If you lose a secret value, you must delete the variable and create a new one with the correct value.