Modal
Connect
Connect Modal from the terminal. Pass --help for the flags Modal accepts, plus --no-browser for headless environments.
polylane cloud connect --provider modalA token ID and token secret from Settings → Tokens in Modal.
Connect your Modal workspace with one token. A Modal token belongs to one workspace, so one token connects one workspace. Polylane encrypts the token before it stores it, and the agent never sees it.
- In Modal, go to Settings → Tokens.
- Click New token. Copy the token ID, which starts with
ak-, and the token secret, which starts withas-. - Paste both values into Polylane. Polylane checks the pair and starts the first sync.
Modal has no read-only token. A token has the permissions of the account that created it.
Connect Modal from a CI job or any other environment without a browser.
Connecting Modal needs no browser: the same endpoint the console calls fits in a CI job. One authenticated POST creates the connection and starts the first sync.
Prerequisites
- A Polylane API key with the
cloud_accounts:writeandcloud_accounts:readscopes. See API keys and OAuth. - Your workspace ID, which starts with
ws_. Read it fromGET /v1/workspaceswith the same key. - A Modal token pair from Settings → Tokens: the token ID (starts with
ak-) and the token secret (starts withas-).
Create the connection
curl -X POST https://api.polylane.com/v1/cloud_accounts \
-H "x-api-key: $POLYLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "modal",
"workspaceId": "ws_0abc123",
"tokenId": "ak-...",
"tokenSecret": "as-..."
}'
The token resolves to exactly one Modal workspace, so one call connects one workspace.
The response lists what was connected, with the first sync already running. Trimmed to the two fields the rest of the flow reads:
{
"success": true,
"result": {
"provider": "modal",
"accounts": [{ "id": "acc_34gky74ibc92h8t2efn8csrh", "status": "syncing" }],
"failures": []
}
}
An account that is already connected lands in failures instead of accounts, so repeating the call never duplicates a connection.
Wait for the first sync
Poll each returned account by its id until status reaches ready (new on registration, syncing while resources stream in):
until [ "$(curl -s "https://api.polylane.com/v1/cloud_accounts/$WORKSPACE_ID/$ACCOUNT_ID" \
-H "x-api-key: $POLYLANE_API_KEY" | jq -r '.result.status')" = "ready" ]; do
sleep 15
done
Give the loop a deadline so a failed connect fails the job instead of hanging it. Once the account is ready, its resources are in the topology and Polylane has started its first check.
Disconnect from the API
Deleting the connection stops every sync and check and deletes the credentials Polylane held. The call needs the cloud_accounts:delete scope:
curl -X DELETE "https://api.polylane.com/v1/cloud_accounts/$WORKSPACE_ID/$ACCOUNT_ID" \
-H "x-api-key: $POLYLANE_API_KEY"
Then revoke the Modal token, as described under Disconnecting.
How it works
Resources in the context graph
Polylane maps each environment of the workspace. In each environment, it maps your apps, functions with their web endpoints, classes, images, running sandboxes, volumes, secrets, queues and dicts. For a secret, Polylane stores the name only, because Modal does not expose secret values. Polylane syncs every 15 minutes.
When a sync finds a new version of an app, Polylane records a deployment with the version and the person who deployed it.
Checks and anomaly detection
Four account checks watch the whole workspace:
- stderr log lines across every recently active app
- metered spend for each hour
- the p90 time from creating a sandbox to the start of its container
- the total number of items that wait in your queues
Each app also gets its own monitor, with two series: stderr log lines and metered spend for each hour. Modal reports only point-in-time values for other resources, so functions, sandboxes and volumes have no series of their own. Polylane compares each series with its usual level, and opens an issue when a change is a real problem.
What agents can do
During an investigation, agents describe an app with its state, deploy history and functions, and read app logs, deployments, sandboxes and spend for one app or for the workspace. Agents can set a watch that wakes a thread when the next deployment of an app lands.
Polylane has no tools that change Modal. It only reads from Modal.
Troubleshooting
"Invalid token" error
- Polylane needs both the token ID and the token secret. One of them alone cannot authenticate.
- Check that the token is not revoked in the Modal settings.
- Make sure you copied the full values, with the
ak-andas-prefixes.
Missing resources
- Polylane finds functions through their app. An app that was never deployed has no functions to show.
- Polylane skips finished sandboxes. Only running sandboxes appear.
- An image appears only when a function runs on it. Modal has no image list, so a base image with nothing built on it does not appear.
- Polylane links a class to its methods by name. A method with a name that does not start with its class name appears as a separate function.
- Click Sync in the account header to sync before the next scheduled sync.
Charts look low or short
- A stderr count is a count of log lines, not of failures. One Python traceback is several lines.
- Modal keeps logs for 24 hours, so a log chart covers 24 hours at most.
- Modal reports the spend of an hour only after that hour ends, so the newest hour reads low until it is complete.
Disconnecting
Disconnecting does not change Modal. Revoke the token under Settings → Tokens in Modal.
Disconnect
Disconnecting stops every sync and check and deletes the credentials Polylane held. Everything Polylane set up in Modal is removed as well; nothing is left behind.
polylane cloud disconnect <id>Tools
5Operations agents can perform in threads.
Supported resources
10Resource types that show up in your infrastructure graph.