Skip to main content
New to Corsair? See API access, authentication, and error handling.

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
Input Output

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
Input Output

info

apps.info An App’s description, lifecycle (state, deploys, who and when) and the ids of its functions and servers. Risk: read
Input Output

list

apps.list List the live Apps in an environment (stopped and disabled Apps are left out). Risk: read
Input Output

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
Input Output

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
Input Output

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
Input Output

Classes

call

classes.call Run a method of a deployed class and wait for its result (billed for the compute it uses). Risk: destructive
Input
Output

spawn

classes.spawn Start a method of a deployed class without waiting; returns a function call id. Risk: destructive
Input
Output

Dicts

clear

dicts.clear Remove every entry from the Dict. Cannot be undone. Risk: destructive · Irreversible
Input Output

contains

dicts.contains Whether a key is in the Dict. Risk: read
Input Output

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
Input Output

delete

dicts.delete Delete a Dict and all its entries. Cannot be undone. Risk: destructive · Irreversible
Input Output

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
Input Output

items

dicts.items Keys and values in the Dict, decoded as in dicts.get (a tuple key comes back as an array). Risk: read
Input Output

len

dicts.len Number of entries in the Dict. Risk: read
Input Output

list

dicts.list List the named Dicts in an environment, newest first. Risk: read
Input Output

pop

dicts.pop Remove a key and return its value. Risk: write
Input Output

put

dicts.put Store a JSON value under a key. With skipIfExists an existing key is left alone. Risk: write
Input Output

update

dicts.update Store several key/value pairs at once. Risk: write
Input
Output

Environments

create

environments.create Create an environment in the workspace. Risk: write
Input Output

delete

environments.delete Delete an environment and every App, Volume, Secret, Queue and Dict in it. Cannot be undone. Risk: destructive · Irreversible
Input Output

get

environments.get Look up a Modal environment by name and return its id. Risk: read
Input Output

getDefault

environments.getDefault The environment calls run in: the account’s configured environment, else the workspace default. Risk: read
Input: empty object Output

list

environments.list List the environments in the workspace. Risk: read
Input Output

Files

list

files.list List the entries of a directory in a running sandbox. Risk: read
Input Output

makeDirectory

files.makeDirectory Create a directory in a running sandbox. Risk: write
Input Output

read

files.read Read a file from a running sandbox, as UTF-8 text or base64 for binary files. Risk: read
Input Output

remove

files.remove Delete a file or directory in a running sandbox (recursive for non-empty directories). Risk: destructive · Irreversible
Input Output

stat

files.stat Type, size, owner, permissions and modified time of a path in a running sandbox. Risk: read
Input Output

write

files.write Write a file in a running sandbox, replacing it if it exists. Parent directories must exist (see files.makeDirectory). Risk: write
Input Output

Function Calls

cancel

functionCalls.cancel Cancel a spawned call. With terminateContainers the containers running it are stopped too. Risk: destructive · Irreversible
Input Output

get

functionCalls.get The result of a spawned call, waiting up to waitMs; status “pending” if it is still running. Risk: read
Input Output

logs

functionCalls.logs The most recent log lines of one function call. Risk: read
Input Output

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
Input
Output

currentStats

functions.currentStats Current backlog (queued inputs) and number of running containers. Risk: read
Input Output

fetchLogs

functions.fetchLogs A function’s logs over a time range, with optional text search. Risk: read
Input Output

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
Input Output

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
Input Output: Record<string, any>

logs

functions.logs The most recent log lines of a function. Risk: read
Input Output

metrics

functions.metrics Time series metrics for a function (see functions.metricsSchema for the available groups and names). Risk: read
Input Output: Record<string, any>

metricsSchema

functions.metricsSchema The metric groups and definitions functions.metrics can export. Risk: read
Input Output: 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
Input
Output

stats

functions.stats Input and container counts and latency percentiles for a function over a time window. Risk: read
Input Output: 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
Input Output

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
Input
Output

delete

images.delete Delete an image. Sandboxes and functions using it keep running, but it cannot be used again. Risk: destructive · Irreversible
Input Output

get

images.get Check that an image id exists and return it. Risk: read
Input Output

getByName

images.getByName Look up an image published with images.publish by its name. Risk: read
Input Output

publish

images.publish Give a built image a name in the environment, so images.getByName and sandboxes.create (publishedName) can use it. Risk: write
Input Output

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
Input Output

Queues

clear

queues.clear Remove every value from a Queue partition, or from all partitions with all. Cannot be undone. Risk: destructive · Irreversible
Input Output

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
Input Output

delete

queues.delete Delete a Queue and everything in it. Cannot be undone. Risk: destructive · Irreversible
Input Output

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 &#125;, other objects as &#123; pickle: base64 }. Risk: write
Input Output

len

queues.len Number of values in a Queue partition, or in all partitions with total. Risk: read
Input Output

list

queues.list List the named Queues in an environment with their partition count and size. Risk: read
Input Output

peek

queues.peek Read values from a Queue in order without removing them (decoded as in queues.get). Risk: read
Input Output

put

queues.put Add values (JSON) to the end of a Queue. { $bytes: base64 } is stored as Python bytes. Risk: write
Input Output

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
Input
Output

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
Input Output

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
Input Output

fetchLogs

sandboxes.fetchLogs A sandbox’s entrypoint logs over a time range, with optional text search. Risk: read
Input Output

get

sandboxes.get Whether a sandbox is still running, and its exit code once it has finished. Risk: read
Input Output

getByName

sandboxes.getByName Find a running sandbox by the name it was created with, inside a deployed App. Risk: read
Input Output

getExitSnapshot

sandboxes.getExitSnapshot The filesystem Image captured when a sandbox created with enableExitSnapshot exited. Risk: read
Input Output

getTags

sandboxes.getTags The tags on a sandbox. Risk: read
Input Output

list

sandboxes.list List running sandboxes in the environment, or in one App, optionally filtered by tags. Risk: read
Input Output

logs

sandboxes.logs The most recent entrypoint log lines of a sandbox (not the output of sandboxes.exec commands). Risk: read
Input Output

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
Input Output

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
Input Output

reloadVolumes

sandboxes.reloadVolumes Reload the Volumes mounted in a sandbox to see changes committed elsewhere. Risk: write
Input Output

restoreSnapshot

sandboxes.restoreSnapshot Start a new sandbox from a memory snapshot (billed like any sandbox). Risk: destructive
Input Output

resume

sandboxes.resume Start a paused persistent sandbox again from its saved state (billed while running). Risk: destructive
Input Output

setName

sandboxes.setName Name a running V2 sandbox that has none (once only), so sandboxes.getByName can find it. Risk: write
Input Output

setTags

sandboxes.setTags Replace all tags on a sandbox (an empty object clears them). Risk: write
Input Output

snapshotDirectory

sandboxes.snapshotDirectory Save one directory of a running sandbox as an Image (mount it elsewhere with sandboxes.mountImage). Risk: write
Input Output

snapshotFilesystem

sandboxes.snapshotFilesystem Save a sandbox’s filesystem as an Image; pass its id to sandboxes.create to start a copy. Risk: write
Input Output

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
Input Output

terminate

sandboxes.terminate Stop a sandbox and end its billing. Its filesystem is lost unless it was snapshotted. Risk: destructive · Irreversible
Input Output

tunnels

sandboxes.tunnels Public URLs and TCP endpoints for the ports a sandbox exposes (encryptedPorts, h2Ports, unencryptedPorts). Risk: read
Input Output

unmountImage

sandboxes.unmountImage Unmount an Image mounted with sandboxes.mountImage. Risk: write
Input Output

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
Input Output

wait

sandboxes.wait Wait for a sandbox to finish (up to timeoutMs) and return its exit code. Risk: read
Input Output

waitUntilReady

sandboxes.waitUntilReady Wait until a sandbox is ready: its readiness probe passes, or it has started when it has none. Risk: read
Input Output

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
Input Output

delete

secrets.delete Delete a Secret. Apps that use it fail on their next start. Cannot be undone. Risk: destructive · Irreversible
Input Output

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
Input Output

list

secrets.list List the Secrets in an environment with their key names and last use (values are never returned). Risk: read
Input Output

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
Input Output

delete

volumes.delete Delete a Volume and all its files. Running Apps that mount it lose access. Cannot be undone. Risk: destructive · Irreversible
Input Output

get

volumes.get Look up a Volume by name and return its id. 404 if it does not exist. Risk: read
Input Output

list

volumes.list List the Volumes in an environment, newest first. Risk: read
Input Output

listFiles

volumes.listFiles List files and directories in a Volume under a path. Risk: read
Input Output

removeFile

volumes.removeFile Delete a file, or with recursive a directory, from a Volume. Cannot be undone. Risk: destructive · Irreversible
Input Output