Environments in Modal allow you to organize and isolate resources like functions, secrets, and volumes. Common use cases include separating development from production workloads, or creating isolated environments for different projects.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/modal-labs/modal-client/llms.txt
Use this file to discover all available pages before exploring further.
Using environments
Reference an environment
You can reference an environment by name:Setting the active environment
The active environment is used by default for all Modal operations. You can set it using: Via CLI flag:Environment-specific resources
When creating or referencing Modal resources, you can specify which environment they belong to:Managing environments
Modal provides utility functions for managing environments programmatically.Create an environment
List environments
Retrieve all environments in your workspace:Update an environment
You can rename an environment or update its web suffix:Delete an environment
Environment settings
Each environment has associated settings that control behavior:- Image builder version: Controls which version of the image builder is used
- Webhook suffix: Custom suffix for webhook URLs in this environment
Best practices
Development workflow
A common pattern is to use different environments for different stages:Environment isolation
Environments provide complete isolation between resources:- Secrets in one environment are not accessible from another
- Functions deployed to different environments are completely separate
- Volumes and other storage are environment-specific
- Separating production from development workloads
- Creating isolated test environments
- Managing multi-tenant applications
- Organizing resources by project or team
API reference
Environment.from_name()
Name of the environment to reference.
If
True, creates the environment if it doesn’t exist.Optional client with Modal credentials.
create_environment()
Name for the new environment.
Optional client with Modal credentials.
list_environments()
Optional client with Modal credentials.
list[EnvironmentListItem] - List of environment metadata objects.
update_environment()
Current name of the environment to update.
New name for the environment.
New webhook suffix for the environment.
Optional client with Modal credentials.
delete_environment()
Name of the environment to delete.
Optional client with Modal credentials.