Apps
create
apps.create
Get a Modal App by name, creating an empty one if it does not exist. Sandboxes and image builds run inside an App.
Risk: write
get
apps.get
Look up a Modal App by name and return its id. Fails with 404 if the App does not exist.
Risk: read
info
apps.info
An App’s description, lifecycle (state, deploys, who and when) and the ids of its functions and servers.
Risk: read
lifecycle full type
lifecycle full type
list
apps.list
List the live Apps in an environment (stopped and disabled Apps are left out).
Risk: read
apps full type
apps full type
sandboxStats
apps.sandboxStats
Cost in USD of an App’s sandboxes over a time range (at most 7 days, on UTC hour boundaries), optionally grouped by tag values.
Risk: read
groups full type
groups full type
stats
apps.stats
Call, request, container and sandbox counts for an App over a time window (default the last hour; at most 7 days, starting within the last 30 days).
Risk: read
sandboxes full type
sandboxes full type
lifecycle full type
lifecycle full type
stop
apps.stop
Stop an App: terminates all its running containers and sandboxes and stops it taking new inputs. A deployed App has to be deployed again to come back.
Risk: destructive · Irreversible
Classes
call
classes.call
Run a method of a deployed class and wait for its result (billed for the compute it uses).
Risk: destructive
options full type
options full type
spawn
classes.spawn
Start a method of a deployed class without waiting; returns a function call id.
Risk: destructive
options full type
options full type
Dicts
clear
dicts.clear
Remove every entry from the Dict. Cannot be undone.
Risk: destructive · Irreversible
contains
dicts.contains
Whether a key is in the Dict.
Risk: read
create
dicts.create
Get a named Dict (a key/value store shared by sandboxes and functions), creating it if it does not exist.
Risk: write
delete
dicts.delete
Delete a Dict and all its entries. Cannot be undone.
Risk: destructive · Irreversible
get
dicts.get
Read the value stored under a key. Python tuples and sets come back as arrays, bytes as { bytes: base64 }, other objects (datetimes, class instances) as { pickle: base64 }.
Risk: read
items
dicts.items
Keys and values in the Dict, decoded as in dicts.get (a tuple key comes back as an array).
Risk: read
entries full type
entries full type
len
dicts.len
Number of entries in the Dict.
Risk: read
list
dicts.list
List the named Dicts in an environment, newest first.
Risk: read
dicts full type
dicts full type
pop
dicts.pop
Remove a key and return its value.
Risk: write
put
dicts.put
Store a JSON value under a key. With skipIfExists an existing key is left alone.
Risk: write
update
dicts.update
Store several key/value pairs at once.
Risk: write
entries full type
entries full type
Environments
create
environments.create
Create an environment in the workspace.
Risk: write
delete
environments.delete
Delete an environment and every App, Volume, Secret, Queue and Dict in it. Cannot be undone.
Risk: destructive · Irreversible
get
environments.get
Look up a Modal environment by name and return its id.
Risk: read
getDefault
environments.getDefault
The environment calls run in: the account’s configured environment, else the workspace default.
Risk: read
list
environments.list
List the environments in the workspace.
Risk: read
environments full type
environments full type
Files
list
files.list
List the entries of a directory in a running sandbox.
Risk: read
entries full type
entries full type
makeDirectory
files.makeDirectory
Create a directory in a running sandbox.
Risk: write
read
files.read
Read a file from a running sandbox, as UTF-8 text or base64 for binary files.
Risk: read
remove
files.remove
Delete a file or directory in a running sandbox (recursive for non-empty directories).
Risk: destructive · Irreversible
stat
files.stat
Type, size, owner, permissions and modified time of a path in a running sandbox.
Risk: read
write
files.write
Write a file in a running sandbox, replacing it if it exists. Parent directories must exist (see files.makeDirectory).
Risk: write
Function Calls
cancel
functionCalls.cancel
Cancel a spawned call. With terminateContainers the containers running it are stopped too.
Risk: destructive · Irreversible
get
functionCalls.get
The result of a spawned call, waiting up to waitMs; status “pending” if it is still running.
Risk: read
logs
functionCalls.logs
The most recent log lines of one function call.
Risk: read
entries full type
entries full type
Functions
call
functions.call
Run a deployed function with arguments and wait for its result (billed for the compute it uses). The function must accept CBOR input (Modal 1.2+ deployments).
Risk: destructive
options full type
options full type
currentStats
functions.currentStats
Current backlog (queued inputs) and number of running containers.
Risk: read
fetchLogs
functions.fetchLogs
A function’s logs over a time range, with optional text search.
Risk: read
entries full type
entries full type
get
functions.get
Look up a deployed function by App and name (or by id) and return its id and web URL, if it has one.
Risk: read
info
functions.info
A deployed function’s configuration: CPU, memory, GPUs, image, timeouts, retries, regions, schedule, volumes, secrets, web endpoint and class methods.
Risk: read
Record<string, any>
logs
functions.logs
The most recent log lines of a function.
Risk: read
entries full type
entries full type
metrics
functions.metrics
Time series metrics for a function (see functions.metricsSchema for the available groups and names).
Risk: read
Record<string, any>
metricsSchema
functions.metricsSchema
The metric groups and definitions functions.metrics can export.
Risk: read
Record<string, any>
spawn
functions.spawn
Start a deployed function without waiting; returns a function call id for functionCalls.get or functionCalls.cancel.
Risk: destructive
options full type
options full type
stats
functions.stats
Input and container counts and latency percentiles for a function over a time window.
Risk: read
Record<string, any>
updateAutoscaler
functions.updateAutoscaler
Change min/max/buffer containers and the scale-down window of a deployed function. Warm containers (minContainers, bufferContainers) are billed while idle.
Risk: destructive
Images
build
images.build
Build an image (registry base plus optional Dockerfile commands) on Modal and return its id. The build runs on Modal compute; later sandboxes reuse the cached image.
Risk: destructive
image full type
image full type
delete
images.delete
Delete an image. Sandboxes and functions using it keep running, but it cannot be used again.
Risk: destructive · Irreversible
get
images.get
Check that an image id exists and return it.
Risk: read
getByName
images.getByName
Look up an image published with images.publish by its name.
Risk: read
publish
images.publish
Give a built image a name in the environment, so images.getByName and sandboxes.create (publishedName) can use it.
Risk: write
Proxies
get
proxies.get
Look up a Modal Proxy (static outbound IP, set up in the dashboard) by name; pass its name as proxyName to sandboxes.create.
Risk: read
Queues
clear
queues.clear
Remove every value from a Queue partition, or from all partitions with all. Cannot be undone.
Risk: destructive · Irreversible
create
queues.create
Get a named Queue, creating it if it does not exist. Values are pickled, so Python code reads them as ordinary objects.
Risk: write
delete
queues.delete
Delete a Queue and everything in it. Cannot be undone.
Risk: destructive · Irreversible
get
queues.get
Remove and return up to count values from the front of a Queue, waiting up to timeoutMs for one to arrive. Returns [] when it stays empty. Python tuples and sets come back as arrays, bytes as { bytes }, other objects as { pickle: base64 }.
Risk: write
len
queues.len
Number of values in a Queue partition, or in all partitions with total.
Risk: read
list
queues.list
List the named Queues in an environment with their partition count and size.
Risk: read
queues full type
queues full type
peek
queues.peek
Read values from a Queue in order without removing them (decoded as in queues.get).
Risk: read
put
queues.put
Add values (JSON) to the end of a Queue. { $bytes: base64 } is stored as Python bytes.
Risk: write
Sandboxes
create
sandboxes.create
Start a Modal Sandbox (a container billed per second for CPU, memory and any GPU) from a registry image, a built image or a published one. Returns its id, plus tunnel URLs when ports are exposed.
Risk: destructive
image full type
image full type
volumes full type
volumes full type
cloudBucketMounts full type
cloudBucketMounts full type
readinessProbe full type
readinessProbe full type
tunnels full type
tunnels full type
createConnectToken
sandboxes.createConnectToken
Create a URL and bearer token for HTTP requests into a sandbox port (default 8080). Treat the token as a secret.
Risk: write
exec
sandboxes.exec
Run a command in a running sandbox and wait for it: returns exit code, stdout and stderr. For a shell line pass [“sh”, “-c”, ”…”].
Risk: destructive
fetchLogs
sandboxes.fetchLogs
A sandbox’s entrypoint logs over a time range, with optional text search.
Risk: read
entries full type
entries full type
get
sandboxes.get
Whether a sandbox is still running, and its exit code once it has finished.
Risk: read
getByName
sandboxes.getByName
Find a running sandbox by the name it was created with, inside a deployed App.
Risk: read
getExitSnapshot
sandboxes.getExitSnapshot
The filesystem Image captured when a sandbox created with enableExitSnapshot exited.
Risk: read
getTags
sandboxes.getTags
The tags on a sandbox.
Risk: read
list
sandboxes.list
List running sandboxes in the environment, or in one App, optionally filtered by tags.
Risk: read
sandboxes full type
sandboxes full type
logs
sandboxes.logs
The most recent entrypoint log lines of a sandbox (not the output of sandboxes.exec commands).
Risk: read
entries full type
entries full type
mountImage
sandboxes.mountImage
Mount an Image (e.g. from sandboxes.snapshotDirectory) at a path in a running sandbox; without imageId an empty directory is mounted.
Risk: write
pause
sandboxes.pause
Stop the container of a persistent sandbox, keeping its state for sandboxes.resume. Persistent sandboxes are not enabled on every workspace yet.
Risk: write
reloadVolumes
sandboxes.reloadVolumes
Reload the Volumes mounted in a sandbox to see changes committed elsewhere.
Risk: write
restoreSnapshot
sandboxes.restoreSnapshot
Start a new sandbox from a memory snapshot (billed like any sandbox).
Risk: destructive
resume
sandboxes.resume
Start a paused persistent sandbox again from its saved state (billed while running).
Risk: destructive
setName
sandboxes.setName
Name a running V2 sandbox that has none (once only), so sandboxes.getByName can find it.
Risk: write
setTags
sandboxes.setTags
Replace all tags on a sandbox (an empty object clears them).
Risk: write
snapshotDirectory
sandboxes.snapshotDirectory
Save one directory of a running sandbox as an Image (mount it elsewhere with sandboxes.mountImage).
Risk: write
snapshotFilesystem
sandboxes.snapshotFilesystem
Save a sandbox’s filesystem as an Image; pass its id to sandboxes.create to start a copy.
Risk: write
snapshotMemory
sandboxes.snapshotMemory
Snapshot filesystem and memory of a sandbox created with enableMemorySnapshot (and no Volumes). The sandbox stops once the snapshot is taken; sandboxes.restoreSnapshot starts a copy.
Risk: write
terminate
sandboxes.terminate
Stop a sandbox and end its billing. Its filesystem is lost unless it was snapshotted.
Risk: destructive · Irreversible
tunnels
sandboxes.tunnels
Public URLs and TCP endpoints for the ports a sandbox exposes (encryptedPorts, h2Ports, unencryptedPorts).
Risk: read
tunnels full type
tunnels full type
unmountImage
sandboxes.unmountImage
Unmount an Image mounted with sandboxes.mountImage.
Risk: write
updateNetworkPolicy
sandboxes.updateNetworkPolicy
Replace the outbound allowlists of a running sandbox. Pass both lists; [] blocks that dimension, [“0.0.0.0/0”] or [""] allows all. Only works on a sandbox created with outboundCidrAllowlist/outboundDomainAllowlist (to start open, create it with [“0.0.0.0/0”] and [""]); Modal answers 409 otherwise.
Risk: write
wait
sandboxes.wait
Wait for a sandbox to finish (up to timeoutMs) and return its exit code.
Risk: read
waitUntilReady
sandboxes.waitUntilReady
Wait until a sandbox is ready: its readiness probe passes, or it has started when it has none.
Risk: read
Secrets
create
secrets.create
Create a named Secret from key/value pairs (injected into sandboxes and functions as environment variables). Fails if it exists unless overwrite is set.
Risk: write
delete
secrets.delete
Delete a Secret. Apps that use it fail on their next start. Cannot be undone.
Risk: destructive · Irreversible
get
secrets.get
Look up a Secret by name and return its id (values are never returned). With requiredKeys, fails if any key is missing.
Risk: read
list
secrets.list
List the Secrets in an environment with their key names and last use (values are never returned).
Risk: read
secrets full type
secrets full type
Volumes
create
volumes.create
Get a Volume by name, creating it if it does not exist. Volumes are persistent network file systems for sandboxes and functions (storage is billed).
Risk: write
delete
volumes.delete
Delete a Volume and all its files. Running Apps that mount it lose access. Cannot be undone.
Risk: destructive · Irreversible
get
volumes.get
Look up a Volume by name and return its id. 404 if it does not exist.
Risk: read
list
volumes.list
List the Volumes in an environment, newest first.
Risk: read
volumes full type
volumes full type
listFiles
volumes.listFiles
List files and directories in a Volume under a path.
Risk: read
entries full type
entries full type
removeFile
volumes.removeFile
Delete a file, or with recursive a directory, from a Volume. Cannot be undone.
Risk: destructive · Irreversible