Using Passive from an agent
How Passive behaves, for a program or an agent driving it through the API or the MCP server. For credentials and permissions see API key scopes; for failures see API errors; for safe retries see idempotency keys.
An app's status
status says what the platform has confirmed, never more.
| Status | Meaning | What to do |
|---|---|---|
deploying | A deploy was sent and has not been confirmed running. | Wait, then check again. |
queued | The deploy was accepted but no machine was free. It starts when one connects, and expires after an hour. | Wait. Do not redeploy. |
running | The container started. It does not mean the app answers correctly. | Check health. |
degraded | A deploy failed, or the machine running the app lost its connection. | Read status_reason and the timeline, then redeploy. |
expired | A queued deploy never found a machine. | Deploy again. |
stopped | An old record from before the platform tracked failures. | Redeploy. |
status_reason explains a non-running status. worker_disconnected means the machine
running the app lost its connection and recovery is usually automatic within seconds;
redeploying then moves the app to another machine and can cause the outage it is meant
to fix. Any other reason on a degraded app is a failed deploy: read the timeline and the logs.
health sits beside the status and is never a status. A running app can report
app_errors (its own 5xx responses) or platform_errors (Passive could not get a
response). Redeploying does not fix an app that returns 500s.
Deploying
A deploy from source builds an image first, which can take minutes. Send
Prefer: respond-async (the MCP tools do) and the request answers 202 as soon as the
deploy is accepted, with a deployment_id. Then poll GET /apps/{app}/deployments
(get_app_deployments) until that entry is succeeded or failed; a failure carries the
builder's error. While one deploy of an app is building, another answers 409. Without the
header the request answers only when the build is done. If a request times out anyway, send it
again with the same Idempotency-Key (the MCP tools' idempotency_key), which answers with
the first call's result instead of deploying twice. A 202 with status: "queued" means no
machine was free. Poll the app until status is running or degraded; do not infer
queued from the status code, read the body. See idempotency.
- Deploy from Git (
POST /apps/deploy-git, tooldeploy_from_git) creates an app fromowner/repoand a branch. The person who owns the API key must have connected their GitHub account in the dashboard, or the request fails. Deploying publishes the repository's code at a public URL, so the tool refuses a repository no app in the workspace deploys yet untilconfirmis set to its full name. Ask the person first. - Deploy from an image (
POST /apps, tooldeploy_image) creates an app from a Docker image and a port. - Redeploy (
POST /apps/{app}/redeploy, toolredeploy_app) rebuilds the commit the app already records. It does not pick up new commits. - Deploy latest (
POST /apps/{app}/deploy-latest, tooldeploy_latest) fetches the head of the connected branch and deploys it. It answers409if the app is already up to date or a rollout is in progress. - Change branch (
PUT /apps/{app}/branch, toolchange_branch) deploys another branch. The app moves to it only once the build is live. - Roll back (
POST /apps/{app}/rollback, toolrollback_app) redeploys an earlier successful deployment without rebuilding. Only the code goes back: the app keeps the environment variables it has now, including aPORTyou set. It answers409if that deployment's image no longer exists or its commit is not verified. Redeploy rebuilds the recorded commit instead.
Send an Idempotency-Key with a create or deploy and reuse the same key when you retry, so
a retry after a timeout cannot run it twice. A new key for each attempt is not a retry.
Finding out why something happened
- The timeline (
get_app_events) records every placement and status change with the error recorded at the time. An event whose source isworkeris the worker's own claim, not something Passive observed. A change made with an API key names the key. - Logs (
get_app_logs) include build output while a deploy runs. Each call starts a stream on the app's machine, so do not poll in a tight loop. - Deployment history (
get_app_deployments) lists each deploy's commit and outcome. A commit marked unverified was not shown to be what is running.
Databases
- Create a database. It starts
creating, thenready, orfailed. - Attach it to an app. Passive injects
DATABASE_URLinto the app's environment and redeploys it. The value is never returned to an agent. - Deleting a database is refused while any app is attached. Detach it first.
For a new app, with_database: true on POST /apps, POST /apps/deploy-git or the
POST /apps/upload form does steps 1 and 2 in one deploy: the database is named after the
app and the first deploy already has DATABASE_URL. It needs db:write as well as
apps:write, and is refused for a static site or an env that sets DATABASE_URL. A
deploy that fails before it is accepted deletes the database again; once accepted, the
database stays attached even if the build fails later. The response carries the database,
and its connection string under the same rule as creating one.
A database's connection string is returned in the response that creates the database only
to a session or to a key that also has db:credentials. A key with db:write alone gets
database_url: null and a database_url_hint. Afterwards it is returned only by
GET /databases/{id}/url, which needs a session or db:credentials. The MCP server
never uses that scope, so an agent attaches the database instead of handling it.
Custom domains
- Add the domain to an app. Listing the app's domains (
GET /apps/{app}/domains,list_app_domains) returns the DNS records to set: an A record to the platform's address, or a CNAME to<app>.passivedev.com. An A record also needs the TXT record each domain carries (txt_name,txt_value), which proves the domain is the owner's. - After the owner sets them, verify the domain. It becomes
verifiedonce DNS points at Passive and either the CNAME names this app or the TXT record is in place (failure_reason: "ownership_unverified"until then). - Removing a domain stops serving the app at it immediately.
What an agent cannot do
- Read or set an environment variable's value. Use the dashboard.
- Read a database's password or connection string.
- Create, list or revoke API keys, manage workspace members, or change billing. These need a signed-in session, not an API key.