API Reference

The Potions API finds your apps, deploys commits and reports how deployments went. It also shows your servers' resources, creates servers, and asks you to confirm deleting apps and servers. The Potions plugin for Claude Code and Codex uses it, and so can your own scripts and CI.

Basics

  • Base URL: https://potions.io/api/v1
  • Send an API token on every request: Authorization: Bearer pot_...
  • Requests and responses are JSON. A request with a body needs Content-Type: application/json.
  • IDs are strings. Times are ISO 8601 in UTC, such as 2026-11-01T18:02:11Z.
  • One object comes back as {"data": {...}}, a list as {"data": [...], "next_cursor": null}.
  • The machine-readable description is at /api/v1/openapi.json.
  • The API only grows: new fields, new values and new endpoints can appear, so ignore anything you don't recognize.

Errors

Every error has the same shape:

{
  "error": {
    "code": "commit_not_found",
    "message": "That commit isn't on acme/shop on GitHub. Push it first, then deploy again.",
    "next": "Push the commit to GitHub (git push), then retry with the same sha.",
    "details": {"ref": "4f2c9a0e1b7d3c5a8f6e2d1c0b9a8f7e6d5c4b3a", "ref_type": "sha", "repo": "acme/shop"}
  }
}

code never changes for a given problem, message is written for people, and next says what to do about it. url (a page to open) and details appear when they help.

Code HTTP Meaning What to do
unauthorized 401 No token, an unknown token, or a revoked one Create a token and set it as POTIONS_TOKEN
token_expired 401 The token has expired Create a new token
bad_request 400 The body isn't valid JSON Send valid JSON
insufficient_ability 403 The token's access doesn't allow this (details.required) Create a token with Agent access
not_found 404 No such resource, or the token can't see it Check the id, or find the app by repository
validation_failed 422 A parameter is wrong (details.errors) Fix the request
subscription_inactive 402 The account's subscription isn't active Update billing, then retry
rate_limited 429 Too many requests Wait for Retry-After seconds
idempotency_key_reuse 422 The Idempotency-Key was used for a different request Use a new key
idempotency_key_in_use 409 A request with the same key is still running Retry shortly with the same key
commit_not_found 422 GitHub doesn't have that commit or branch Push it, then retry
repo_not_accessible 422 The Potions GitHub App can't see the repository Grant access under Manage repos on the account page
github_unavailable 502 GitHub returned an error Retry in a minute
app_ambiguous 409 More than one app deploys the repository (details.candidates) Choose an app, or pass root_dir
choose_server 409 More than one server can host a new app (details.candidates) Ask which server, then retry with server_id
no_eligible_server 422 No server can host apps yet Create a server with POST /servers, or connect one in the dashboard
no_cloud_credential 422 No account is connected for that cloud provider Connect it at url; Potions never takes cloud tokens from an agent
choose_credential 409 More than one account is connected for the provider (details.candidates) Ask which one, then retry with credential_id
credential_invalid 422 Potions can no longer use the cloud account's token Reconnect the account at url
server_limit_reached 402 The plan's servers are all in use (details.servers_used, details.server_limit) Change plans at url, or delete a server you don't need
price_mismatch 409 expected_monthly_price isn't the size's current price (details.monthly_price) Ask the person again with the current price
rollback_unavailable 409 Nothing to roll back to, a deploy is running, or the id isn't the rollback target (details.reason, details.rollback_target_id) Use details.rollback_target_id, or tell the user
needs_env 422 config/runtime.exs needs variables the app doesn't have (details.missing_env_vars); nothing was deployed Have the user add them at url, then deploy again
secret_value_refused 422 The value looks like a secret, or the variable is a secret (details.reason) Have the user add it at url; never ask for it in chat
internal_error 500 Something went wrong in Potions Retry once, then contact us with the request id in message
http_error varies Any other HTTP error Read message

Rate limits

Each token can make 120 requests a minute. Responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (a Unix time). Over the limit, you get 429 rate_limited with a Retry-After header in seconds.

After 30 failed authentications in a minute from one address, requests from that address get 429 until the minute is over.

Idempotency

Any POST can carry an Idempotency-Key header: 1 to 255 printable ASCII characters that you choose, such as <sha>-1. Potions keeps the key, per token, for 24 hours:

  • The same key and the same request returns the first response again, with Idempotent-Replayed: true, instead of deploying twice.
  • The same key with a different request is idempotency_key_reuse.
  • Only successful responses are kept. If a request fails, retrying with the same key runs it again.

Use it to retry safely after a timeout or a dropped connection.

Endpoints

GET /me

The token's account and access. Use it to check that a token works.

curl -sS -H "Authorization: Bearer $POTIONS_TOKEN" https://potions.io/api/v1/me
{"data": {
  "id": "42",
  "email": "you@example.com",
  "subscription_status": "active",
  "abilities": ["read", "deploy"],
  "token": {"name": "Claude laptop", "prefix": "pot_AbCdEfGh", "expires_at": "2027-01-30T18:00:00Z", "app_id": null, "created_via": "settings"},
  "urls": {"dashboard": "https://potions.io/dashboard", "api_tokens": "https://potions.io/account/api-tokens", "docs": "https://potions.io/docs/deploy-with-your-agent"}
}}

GET /servers

Your servers, newest first. A token limited to one app can't list servers. Add ?eligible=true for only the servers a new app can go on: active app servers, including servers you brought.

curl -sS -H "Authorization: Bearer $POTIONS_TOKEN" "https://potions.io/api/v1/servers?eligible=true"
{"data": [
  {"id": "b2a0...", "name": "web-1", "provider": "hetzner", "region": "fsn1", "status": "active",
   "role": "app", "app_count": 2, "dashboard_url": "https://potions.io/servers/b2a0...",
   "eligible_for_apps": true, "database_engine": "postgres",
   "supported_databases": ["postgres", "sqlite", "none"], "bring_your_own": false,
   "size": "cx23", "vcpus": 2, "memory_mb": 4096, "disk_gb": 40, "created_at": "2026-10-02T09:12:00Z",
   "capacity": {"verdict": "room", "confidence": "high", "memory_free_mb": 2210, "disk_free_gb": 51.3,
                "projected_memory_percent": 52.1, "reasons": ["..."], "assumptions": "..."}}
], "next_cursor": null}

role is app, database or load_balancer. provider is null for a server you brought. supported_databases lists the database values you can create an app with on that server. capacity is explained under GET /servers/:id.

POST /servers

Creates an app server: on a connected DigitalOcean or Hetzner account, which bills that account every month, or a server you already have ("provider": "custom"). Needs servers:create; a token limited to one app can't create servers. Each token can create 5 servers an hour, and your plan's server limit applies.

curl -sS -X POST -H "Authorization: Bearer $POTIONS_TOKEN" -H "Content-Type: application/json" \
  -d '{"name": "web-2", "provider": "hetzner", "region": "fsn1", "size": "cx23", "expected_monthly_price": "6.49"}' \
  https://potions.io/api/v1/servers
Field
name Required. Letters, digits and hyphens, unique among your servers. It's also the server's hostname.
provider Required. digital_ocean, hetzner or custom
region, size Cloud servers: from GET /server_options
expected_monthly_price Cloud servers: the monthly_price the person agreed to. If the price has changed, nothing is created and you get 409 price_mismatch. Optional here, required in the MCP tool.
credential_id Cloud servers, when more than one account is connected for the provider
database_engine postgres (the default) installs PostgreSQL. sqlite leaves it out, for SQLite apps and apps without a database.
postgres_version 16, 17 or 18 (the default)
ip_address, ssh_port custom only: the server's public IPv4 address, and its SSH port (default 22)

The response is the server as in GET /servers/:id, with 201 and meta.created: true. The name is the idempotency key: a server you already have with that name comes back with 200, meta.created: false and meta.differences, and nothing is created.

Setup takes 5 to 10 minutes. Follow it with GET /servers/:id?wait=50 until status is active, then create apps on it with POST /apps and server_id.

A server you bring waits for its connect command, which runs as root on the server and holds a one-time token, so the API never returns it. meta.connect_url is the server's page, where you copy it. See Bring your own server.

Potions emails the account owner about every server a token creates, with its size, region and monthly price, and the server's page names the token. If no app has run on a cloud server 48 hours later, Potions emails the owner once more. It never deletes the server.

GET /servers/:id

One server with its resources, to decide whether a new app should go on it or on a new server. Needs read; a token limited to one app can't use it.

curl -sS -H "Authorization: Bearer $POTIONS_TOKEN" https://potions.io/api/v1/servers/b2a0...
{"data": {
  "id": "b2a0...", "name": "web-1", "status": "active", "...": "the Server fields above",
  "capacity": {
    "verdict": "tight", "confidence": "high",
    "memory_total_mb": 3910, "memory_peak_mb": 2840, "memory_free_mb": 1070,
    "projected_memory_percent": 79.0, "disk_free_gb": 51.3,
    "reasons": [
      "Memory peaked at 2840 MB of 3910 MB in the last 24 hours; with about 250 MB for another app that is 79%.",
      "Disk is 34% full (51.3 GB free).",
      "The 95th-percentile one-minute load was 0.32 per vCPU (2 vCPUs)."
    ],
    "assumptions": "About 250 MB for one more Phoenix app. Swap is never counted. CPU percent overstates load on BEAM hosts, so memory and disk decide."
  },
  "resources": {
    "specs": {"size": "cx23", "vcpus": 2, "memory_mb": 4096, "disk_gb": 40, "swap_mb": 1024, "monthly_price": "6.49", "currency": "USD"},
    "usage": {"as_of": "2026-11-27T10:05:00Z", "cpu_percent": 6.2, "memory_used_mb": 2410, "memory_total_mb": 3910, "memory_percent": 61.6,
              "disk_used_gb": 26.4, "disk_total_gb": 77.7, "disk_percent": 34.0, "load_average_1": 0.31, "load_average_5": 0.28, "load_average_15": 0.25},
    "window_24h": {"hours": 24, "samples": 288, "covers_hours": 24.0,
                   "cpu_percent": {"avg": 5.1, "p95": 14.3, "max": 62.0},
                   "memory_used_mb": {"avg": 2380, "p95": 2610, "max": 2840},
                   "load_average_1": {"avg": 0.22, "p95": 0.63, "max": 1.9},
                   "disk_percent_max": 34.0},
    "apps": [{"id": "9c1e...", "name": "shop", "status": "active", "database_kind": "postgres"}]
  },
  "provisioning": null
}, "meta": {}}

capacity.verdict is about one more app:

Verdict Meaning
room The 24-hour memory peak plus about 250 MB stays at or under 75% of RAM, and the disk is at most 80% full with 2 GB free
tight It fits, but with little headroom (up to 90% memory or disk), or the load is high
full Another app would likely run the server out of memory or disk
unknown Potions has no metrics from this server yet
unavailable The server isn't active
not_app_server A database server or load balancer

confidence is low when there are fewer than about 20 hours of metrics (servers report every 5 minutes). The verdict is a guide, not a promise: show the reasons and let the person decide.

While a server is being set up, provisioning has the current step, completed_steps and total_steps; after a failed setup it has the error. A server you brought that's waiting for its connect command has waiting_for_connect: true. Add ?wait=50 to wait up to 50 seconds for setup to finish: the response comes back as soon as the server is active or error.

Lists take ?limit= (1 to 100, default 20). When next_cursor isn't null, pass it as ?after= for the next page.

GET /server_options

What servers you can create: how many servers your plan allows and uses, each cloud provider with your connected accounts and its regions, and bringing your own server. Needs read; a token limited to one app can't use it. Cloud tokens never appear.

curl -sS -H "Authorization: Bearer $POTIONS_TOKEN" https://potions.io/api/v1/server_options
{"data": {
  "plan": {"servers_used": 1, "server_limit": 3, "can_create": true},
  "providers": [
    {"provider": "digital_ocean", "name": "DigitalOcean", "connected": true,
     "credentials": [{"id": "5d1c...", "provider": "digital_ocean", "label": "you@example.com", "status": "active"}],
     "default_region": "nyc3", "regions": [{"slug": "nyc3", "name": "New York 3"}],
     "connect_url": "https://potions.io/auth/digitalocean"},
    {"provider": "hetzner", "name": "Hetzner Cloud", "connected": false, "credentials": [],
     "default_region": "fsn1", "regions": [{"slug": "fsn1", "name": "Falkenstein"}],
     "connect_url": "https://potions.io/account"}
  ],
  "bring_your_own": {"available": true, "requirements": "A fresh Ubuntu 24.04 server ...", "docs_url": "https://potions.io/docs/bring-your-own-server"}
}}

Add ?provider=digital_ocean&region=nyc3 for that region's sizes, cheapest family first, with the monthly price your cloud account is billed (Hetzner's prices exclude VAT). When more than one account is connected for the provider, add &credential_id=; without it you get 409 choose_credential.

{"data": {
  "plan": {...}, "providers": [...], "bring_your_own": {...},
  "sizes_for": {"provider": "digital_ocean", "region": "nyc3", "credential_id": "5d1c..."},
  "sizes": [
    {"slug": "s-1vcpu-2gb-intel", "family": "premium_intel", "family_name": "Premium Intel (NVMe)",
     "vcpus": 1, "memory_mb": 2048, "disk_gb": 50, "monthly_price": "14", "currency": "USD"}
  ]
}}

GET /apps?repo=owner/name

Finds the app that deploys a GitHub repository. Pass repo as owner/name (not a URL, no .git). Matching ignores case.

root_dir narrows monorepos: leave it out to match any directory, pass it empty (or .) for the repository root, or pass the app's directory, such as apps/web.

curl -sS -G -H "Authorization: Bearer $POTIONS_TOKEN" \
  --data-urlencode "repo=acme/shop" \
  https://potions.io/api/v1/apps

No match returns {"data": [], "next_cursor": null}. One match returns a list with one App. More than one is 409 app_ambiguous, with the choices in details.candidates.

An App looks like this:

{
  "id": "6f1c...", "name": "shop", "server_id": "b2a0...", "server_name": "web-1",
  "repo": "acme/shop", "root_dir": null, "branch": "main",
  "database_kind": "postgres", "auto_deploy": false, "status": "running",
  "url": "https://shop.example.com",
  "dashboard_url": "https://potions.io/servers/b2a0.../apps/6f1c...",
  "latest_deployment": {"id": "9d3e...", "status": "succeeded", "commit_sha": "4f2c...", "branch": "main", "trigger": "push", "created_at": "...", "finished_at": "...", "dashboard_url": "..."},
  "created_at": "2026-10-01T12:00:00Z"
}

database_kind is postgres, sqlite, external or none. url is null until the app has a domain or subdomain.

elixir_version, otp_version, node_version, health_check_path and database_ready (false while a new app's database is being created) are on every App too.

POST /apps

Finds or creates the app for a repository. Needs a token with Agent access that isn't limited to one app. Only repo and database are required:

curl -sS -X POST -H "Authorization: Bearer $POTIONS_TOKEN" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \
  -d '{"repo": "acme/shop", "database": "postgres", "elixir_version": "1.18.3", "otp_version": "27.2"}' \
  https://potions.io/api/v1/apps
Field Meaning
repo owner/name on GitHub
database postgres, sqlite or none. An app with an external database is added in the dashboard, because its URL is a secret.
root_dir The folder with the app's mix.exs in a monorepo. Leave it out for the repository root.
branch The branch to deploy. Defaults to the repository's default branch.
server_id Which server, from GET /servers. Needed when more than one server can host the app.
name Defaults to the repository's name (plus the folder's name for a monorepo app).
elixir_version, otp_version, node_version As in .tool-versions. Potions builds the newest patch of each line it offers, and meta.versions.notes says what changed.
health_check_path Defaults to /

Any other field is refused. Running the same request again never makes a second app:

  • 201 with meta.created: true: a new app. meta.env_check lists any variables config/runtime.exs needs that aren't set yet, with a link (env_url) to add them.
  • 200 with meta.created: false: the app for that repository and folder already existed, and nothing changed. meta.differences lists what you asked for that it has differently.

Creating an app never deploys it. Deploy with POST /apps/:id/deployments; the first deploy waits for the database. A token can create 20 apps an hour.

Error When
choose_server (409) More than one server can host the app; details.candidates lists them. Retry with server_id.
no_eligible_server (422) No active app server yet; details.servers says why for each server.
repo_not_accessible (422) The Potions GitHub App can't see the repository. details.reason is no_github_connection, app_not_installed_on_owner or repo_not_selected, and url opens the page that fixes it.
validation_failed (422) A bad field, a missing branch, no mix.exs in root_dir, or versions Potions doesn't build (details.supported)

GET /apps

Without repo, every app the token can see, newest first. A token limited to one app sees that app. Paginated like other lists (limit, after).

GET /apps/:id

One App, as above.

DELETE /apps/:id

Asks to delete an app. This deletes nothing by itself. It returns 202 with a link to the app's danger zone in Potions, where you sign in, type the app's name and tick each consequence, exactly as when you delete from the dashboard. An agent can't take that step for you. Needs the apps:delete ability. An agent should send it only when your own message asks to delete that app; deleting an app never fixes a failed deploy.

{"data": {
  "kind": "app", "id": "9c1e...", "name": "shop", "status": "confirmation_required",
  "confirm_url": "https://potions.io/servers/b2a0.../apps/9c1e.../settings?delete_request=...#danger-zone",
  "expires_at": "2026-11-27T11:05:00Z",
  "impact": [
    "Deletes the app shop on web-1 with its deployments, environment variables, domains and scheduled tasks; its URL stops working.",
    "Drops the shop_prod database on web-1.",
    "Its backups are kept on web-1 and are deleted with the database; they can't be downloaded.",
    "API tokens limited to this app are deleted too."
  ],
  "app": {"id": "9c1e...", "name": "shop", "...": "the App summary"}
}}

impact says in plain words what the confirmation page lists, so an agent can tell you before you open it. The link works for an hour and only for the account that asked. Potions also emails the owner, and the request shows on the app's Settings page for that hour, so the owner can open Potions directly instead of the link. After you confirm, GET /apps/:id shows status: "deleting", then 404 once the app is gone. Asking again while the app is being deleted returns status: "deleting" and no link.

Deleting servers

There's no endpoint for deleting a server: agents can create servers but never delete them. You delete a server from its page in Potions (dashboard_url on every server), under Settings, Danger zone.

GET /apps/:id/env

The app's environment variable names. Never values.

{"data": [
  {"name": "PHX_HOST", "kind": "config", "generated": true, "locked": false, "updated_at": "..."},
  {"name": "PORT", "kind": "config", "generated": true, "locked": true, "updated_at": "..."},
  {"name": "SECRET_KEY_BASE", "kind": "secret", "generated": true, "locked": false, "updated_at": "..."}
], "next_cursor": null}

kind is config (a setting that isn't secret) or secret. generated means Potions created the value, and locked means only Potions can change it. Pass ?limit=100 to get every variable at once on most apps.

PUT /apps/:id/env/:name

Sets a config value, such as POOL_SIZE or LOG_LEVEL. Needs a token with Agent access. The body is {"value": "12"}: one line, at most 4,096 bytes. It answers 201 for a new variable and 200 for a change, with meta.applies_on_next_deploy: true.

Potions refuses, with 422 secret_value_refused and a url where the user can add it, any value that looks like a secret: a name with a word like SECRET, TOKEN, KEY or PASSWORD in it, a known key format, a URL with a password, or a long random string. It never repeats the value back. Agents can't overwrite a secret, a variable Potions manages, or a name that changes how the app is built (such as anything starting with MIX_, HEX_, NODE_ or GIT_).

POST /apps/:id/env/:name/generate

Has Potions generate a random secret for a value that only needs to be random and private to the app, such as a signing salt. The body is optional: {"length": 64} (32 to 128, default 64). It answers 201 with meta.created: true. If the name is already set, it changes nothing and answers 200 with meta.created: false: rotating a secret stays a dashboard action.

POST /apps/:id/deployments

Deploys a commit. Needs a token with deploy access. The body is optional:

Body Deploys
none, or {} The head of the app's branch
{"branch": "hotfix"} The head of hotfix
{"sha": "<40 characters>"} That commit
{"sha": "...", "branch": "main"} That commit, recorded as from main

sha must be the full 40-character lowercase SHA (git rev-parse HEAD), and the commit must already be on GitHub. Any other body key is validation_failed.

curl -sS -X POST \
  -H "Authorization: Bearer $POTIONS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 4f2c9a0e1b7d3c5a8f6e2d1c0b9a8f7e6d5c4b3a-1" \
  -d '{"sha": "4f2c9a0e1b7d3c5a8f6e2d1c0b9a8f7e6d5c4b3a", "branch": "main"}' \
  https://potions.io/api/v1/apps/6f1c.../deployments

A new deployment returns 201 with the Deployment and "meta": {"deduplicated": false}. If the same commit is already queued or building, for example because your push started it, you get 200 with that deployment and "meta": {"deduplicated": true}. Follow it the same way.

Before anything is queued, Potions reads config/runtime.exs at that commit. If the code requires variables the app doesn't have, the answer is 422 needs_env and no deployment is created:

{"error": {
  "code": "needs_env",
  "message": "2 environment variables are missing: MAILGUN_API_KEY, STRIPE_SECRET_KEY.",
  "next": "Ask the user to open the url and add the values (never ask for them in chat)...",
  "url": "https://potions.io/servers/b2a0.../apps/6f1c.../environment?add=MAILGUN_API_KEY,STRIPE_SECRET_KEY&sha=4f2c...",
  "details": {"missing_env_vars": ["MAILGUN_API_KEY", "STRIPE_SECRET_KEY"], "source": "config/runtime.exs", "commit_sha": "4f2c..."}
}}

The link opens the app's Environment tab with those names filled in and a Save and deploy button that deploys the same commit. See Missing Variables for what the check reads.

GET /apps/:id/deployments

The app's deployments, newest first, as summaries (id, status, commit_sha, branch, trigger, created_at, finished_at, dashboard_url) plus rollback_target. At most one deployment has rollback_target: true: the previous release, the one a rollback restores.

POST /deployments/:id/rollback

Rolls the app back to deployment :id, which must be the one with rollback_target: true. Needs a token with deploy access, and no body. It answers 201 with the new deployment (trigger: "rollback"); follow it with GET /deployments/:id?wait=50.

Potions keeps the previous release on the server, so a rollback switches back to it in seconds without a build. Any other id is 409 rollback_unavailable with details.rollback_target_id, the id that would work. details.reason is not_rollback_target, never_deployed, no_previous_deployment or deploy_in_progress.

GET /deployments/:id?wait=50

One Deployment. With wait (0 to 50 seconds), the request returns as soon as the deployment finishes, or when the time is up, whichever comes first. After a failure it waits up to 20 more seconds (within wait) for the AI summary. To follow a deploy, repeat the request while status is queued or building.

curl -sS -H "Authorization: Bearer $POTIONS_TOKEN" \
  "https://potions.io/api/v1/deployments/9d3e...?wait=50"
{"data": {
  "id": "9d3e...", "app_id": "6f1c...",
  "status": "failed", "phase": null, "failed_phase": "migrate",
  "commit_sha": "4f2c...", "commit_message": "Add billing", "branch": "main",
  "source": {"type": "git", "repo": "acme/shop", "sha": "4f2c..."},
  "trigger": "api", "error": "Build failed with exit code 1",
  "created_at": "...", "started_at": "...", "finished_at": "...",
  "log_tail": "[potions] 18:02:11 Running database migrations...\nERROR! Config provider Config.Reader failed with:\n** (RuntimeError) environment variable STRIPE_SECRET_KEY is missing.",
  "failure_summary": "The release could not start because STRIPE_SECRET_KEY is not set...",
  "missing_env_vars": ["STRIPE_SECRET_KEY"],
  "urls": {
    "dashboard": "https://potions.io/servers/b2a0.../apps/6f1c.../deployments",
    "env": "https://potions.io/servers/b2a0.../apps/6f1c.../environment?add=STRIPE_SECRET_KEY",
    "app": "https://shop.example.com"
  }
}}

log_tail is the last 50 lines of the build log, with your environment variable values replaced by [REDACTED]. failure_summary is Potions' AI summary of a failure, or null. phase and log_tail can be up to 10 seconds behind a running build.

GET /deployments/:id/logs

The deployment's log as NDJSON: one JSON event per line, with your environment variable values removed.

curl -sS -N -H "Authorization: Bearer $POTIONS_TOKEN" \
  "https://potions.io/api/v1/deployments/9d3e.../logs?follow=1"
{"type":"start","deployment":{...}}
{"type":"line","text":"==> Compiling 42 files (.ex)"}
{"type":"status","status":"building","phase":"compile"}
{"type":"heartbeat","at":"2026-11-01T18:02:15Z"}
{"type":"end","reason":"finished","deployment":{...}}

Without follow you get the stored log and an end event (reason is snapshot while the deploy is still running). With follow=1 the stream stays open and sends lines as they happen, a status event when the step changes, and a heartbeat every 15 seconds while it's quiet. If you connect while a build is running, the first new lines can take up to 15 seconds while Potions matches the live output to the saved log, so no line is missed or sent twice. It ends with reason: "finished" when the deployment ends (after a failure it waits up to 20 seconds for the AI summary), or timeout after 30 minutes. tail=N (1 to 10000) keeps only the last N stored lines. Each token can keep 5 streams open; a sixth gets 429 rate_limited.

POST /client_events

Tools that stop before reaching Potions report it here, so Potions can count how often deploys get stuck locally. The body is {"name": "no_git_remote"}, head_not_pushed or dirty_tree_skipped, and nothing else: no paths, repository names or code. It answers 204, at most 60 times an hour per token. The Potions CLI and plugin send it; you never need to.

Deployment statuses

Status Meaning
queued Waiting to start, or waiting for the app's new database
building Running: building, shipping, migrating or health-checking
succeeded Live
failed Stopped; the previous release keeps serving
rolled_back Succeeded, and later rolled back in the dashboard
canceled Reserved for later; treat it as finished

succeeded, failed, rolled_back and canceled are final.

Deployment phases

While a deployment is building, phase says which step it is on. When it has failed, failed_phase says where it stopped.

Phase What happens, and what a failure here usually means
database Only as failed_phase: the app's new database never finished setting up. Check the app's Database tab
preflight Only as failed_phase: a cluster server was unreachable before anything was built
env_check Only as failed_phase: a push or dashboard deploy stopped before the build because variables were missing
prepare The build machine is set up. Rarely caused by your code
fetch_source Your commit is cloned and checked out. Check repository access and the SHA
pre_build_hook Your pre-build hook runs
deps mix deps.get. Private dependencies or mix.lock
compile MIX_ENV=prod mix compile. Reproduce it locally
assets mix assets.deploy
release mix release
post_build_hook Your post-build hook runs
upload The release is shipped to your server. Often disk space or SSH
pre_deploy_hook Your pre-deploy hook runs on the server
migrate Migrations run. A failing migration, or a variable your config/runtime.exs reads is missing
start The new release starts
health_check Potions checks the new release answers. It crashed on boot, or the health check path didn't return 2xx or 3xx
start_worker The worker node starts, for apps with one
finalize Potions-side bookkeeping on the server
post_deploy_hook Your post-deploy hook runs on the server
switch_traffic The new release is healthy and traffic moves to it. If this fails, the previous release keeps serving

Missing environment variables

When a deployment fails because the app needed environment variables it didn't have, missing_env_vars lists their names and urls.env links to the app's Environment page with those names. Usually the check before the build catches them (failed_phase is env_check, and urls.env carries the commit). When it can't, Potions recognizes the boot failure from Phoenix's generated config/runtime.exs (environment variable X is missing), System.fetch_env!/1 and Dotenvy. Custom messages aren't detected; the AI summary usually explains them.

The list leaves out names you have added since and names Potions manages, so reading the failed deployment again after you save values shows whether anything is still missing. Saved values apply on the next deploy.