{"components":{"responses":{},"schemas":{"App":{"properties":{"auto_deploy":{"description":"Deploys on every push to branch","type":"boolean"},"branch":{"nullable":true,"type":"string"},"created_at":{"format":"date-time","type":"string"},"dashboard_url":{"format":"uri","type":"string"},"database_kind":{"enum":["postgres","sqlite","external","none"],"type":"string"},"database_ready":{"description":"False while the app's database is being created; deploys wait for it","type":"boolean"},"elixir_version":{"type":"string"},"health_check_path":{"type":"string"},"id":{"type":"string"},"latest_deployment":{"allOf":[{"$ref":"#/components/schemas/DeploymentSummary"}],"nullable":true},"name":{"type":"string"},"node_version":{"nullable":true,"type":"string"},"otp_version":{"type":"string"},"repo":{"description":"owner/name on GitHub","nullable":true,"type":"string"},"root_dir":{"description":"The app's directory in a monorepo; null is the repo root","nullable":true,"type":"string"},"server_id":{"type":"string"},"server_name":{"type":"string"},"status":{"type":"string"},"url":{"format":"uri","nullable":true,"type":"string"}},"required":["id","name","server_id","server_name","repo","root_dir","branch","database_kind","auto_deploy","status","url","dashboard_url","latest_deployment","created_at","elixir_version","otp_version","node_version","health_check_path","database_ready"],"title":"App","type":"object"},"AppList":{"properties":{"data":{"items":{"$ref":"#/components/schemas/App"},"type":"array"},"next_cursor":{"nullable":true,"type":"string"}},"required":["data","next_cursor"],"title":"AppList","type":"object"},"AppResponse":{"properties":{"data":{"$ref":"#/components/schemas/App"}},"required":["data"],"title":"AppResponse","type":"object"},"Capacity":{"description":"Room for one more app: a heuristic from the last 24 hours of metrics, with the reasons. Memory and disk decide; load can only turn room into tight.","properties":{"assumptions":{"nullable":true,"type":"string"},"confidence":{"description":"low: less than about 20 hours of metrics","enum":["high","low","none"],"type":"string"},"disk_free_gb":{"nullable":true,"type":"number"},"memory_free_mb":{"nullable":true,"type":"integer"},"memory_peak_mb":{"nullable":true,"type":"integer"},"memory_total_mb":{"nullable":true,"type":"integer"},"projected_memory_percent":{"description":"The peak plus about 250 MB for one more app, as a percent of RAM","nullable":true,"type":"number"},"reasons":{"items":{"type":"string"},"type":"array"},"verdict":{"enum":["room","tight","full","unknown","unavailable","not_app_server"],"type":"string"}},"required":["verdict","confidence","reasons"],"title":"Capacity","type":"object"},"ClientEventRequest":{"additionalProperties":false,"properties":{"name":{"enum":["no_git_remote","head_not_pushed","dirty_tree_skipped"],"type":"string"}},"required":["name"],"title":"ClientEventRequest","type":"object"},"CreateAppRequest":{"additionalProperties":false,"properties":{"branch":{"description":"Defaults to the repository's default branch","type":"string"},"database":{"description":"postgres if mix.exs depends on :postgrex, sqlite for :ecto_sqlite3, none for neither. External databases are added in the dashboard.","enum":["postgres","sqlite","none"],"type":"string"},"elixir_version":{"description":"As in .tool-versions (1.18, 1.18.3, 1.18.3-otp-27); snapped to Potions' patch","type":"string"},"health_check_path":{"description":"Defaults to /","type":"string"},"name":{"description":"Derived from the repository when omitted","type":"string"},"node_version":{"description":"Only when assets need npm install","type":"string"},"otp_version":{"description":"27, 27.2 or 27.2.4","type":"string"},"repo":{"description":"owner/name on GitHub, not a URL","type":"string"},"root_dir":{"description":"The folder that holds the app's mix.exs in a monorepo; omit for the root","type":"string"},"server_id":{"description":"Required when more than one server can host the app","type":"string"}},"required":["repo","database"],"title":"CreateAppRequest","type":"object"},"CreateAppResponse":{"properties":{"data":{"$ref":"#/components/schemas/App"},"meta":{"properties":{"created":{"type":"boolean"},"differences":{"description":"When created is false: requested fields the existing app has differently, as {requested, existing}","type":"object"},"env_check":{"description":"When created is true: status (ok, missing or skipped), missing_env_vars and env_url","type":"object"},"next":{"type":"string"},"versions":{"description":"When created is true: the requested and resolved versions, with notes","type":"object"}},"required":["created","next"],"type":"object"}},"required":["data","meta"],"title":"CreateAppResponse","type":"object"},"CreateDeploymentRequest":{"additionalProperties":false,"description":"Both optional. Neither: the head of the app's branch. branch only: that branch's head. sha: that commit, with branch recorded when given.","example":{"branch":"main","sha":"4f2c9a0e1b7d3c5a8f6e2d1c0b9a8f7e6d5c4b3a"},"properties":{"branch":{"maxLength":255,"minLength":1,"type":"string"},"sha":{"description":"The full lowercase SHA from git rev-parse HEAD","pattern":"^[0-9a-f]{40}$","type":"string"}},"title":"CreateDeploymentRequest","type":"object"},"CreateServerRequest":{"additionalProperties":false,"properties":{"credential_id":{"description":"Cloud only: needed when more than one account is connected for the provider","type":"string"},"database_engine":{"description":"postgres (default) installs PostgreSQL; sqlite skips it, for SQLite apps and apps without a database","enum":["postgres","sqlite"],"type":"string"},"expected_monthly_price":{"description":"Cloud only: the monthly_price the user agreed to; a different current price is 409 price_mismatch","type":"string"},"ip_address":{"description":"custom only: the server's public IPv4 address","type":"string"},"name":{"description":"Letters, digits and hyphens; unique among your servers. Also the server's hostname.","maxLength":63,"type":"string"},"postgres_version":{"description":"Default 18","enum":["16","17","18"],"type":"string"},"provider":{"enum":["digital_ocean","hetzner","custom"],"type":"string"},"region":{"description":"Cloud only: a region from GET /server_options","type":"string"},"size":{"description":"Cloud only: a size slug from GET /server_options?provider=&region=","type":"string"},"ssh_port":{"description":"custom only: default 22","type":"integer"}},"required":["name","provider"],"title":"CreateServerRequest","type":"object"},"CreateServerResponse":{"properties":{"data":{"$ref":"#/components/schemas/ServerDetail"},"meta":{"properties":{"connect_url":{"description":"A server you bring: the page where the user copies its connect command","format":"uri","type":"string"},"created":{"type":"boolean"},"currency":{"nullable":true,"type":"string"},"differences":{"description":"When created is false: requested values that differ from the server","type":"object"},"monthly_price":{"nullable":true,"type":"string"},"next":{"type":"string"}},"required":["created","next"],"type":"object"}},"required":["data","meta"],"title":"CreateServerResponse","type":"object"},"DeletionRequest":{"description":"Agents never delete anything themselves. confirmation_required: the owner opens confirm_url (signed in), types the name and ticks each consequence. deleting: the owner confirmed and Potions is removing it.","properties":{"app":{"description":"The App summary","type":"object"},"confirm_url":{"description":"Show it to the owner as is; it works for an hour and needs their login","format":"uri","nullable":true,"type":"string"},"expires_at":{"format":"date-time","nullable":true,"type":"string"},"id":{"type":"string"},"impact":{"description":"What deleting does, one sentence per consequence","items":{"type":"string"},"type":"array"},"kind":{"enum":["app"],"type":"string"},"name":{"type":"string"},"status":{"enum":["confirmation_required","deleting","deleted"],"type":"string"}},"required":["kind","id","name","status","impact"],"title":"DeletionRequest","type":"object"},"DeletionRequestResponse":{"properties":{"data":{"$ref":"#/components/schemas/DeletionRequest"}},"required":["data"],"title":"DeletionRequestResponse","type":"object"},"Deployment":{"properties":{"app_id":{"type":"string"},"branch":{"nullable":true,"type":"string"},"commit_message":{"nullable":true,"type":"string"},"commit_sha":{"nullable":true,"type":"string"},"created_at":{"format":"date-time","type":"string"},"error":{"description":"A short reason Potions wrote","nullable":true,"type":"string"},"failed_phase":{"description":"Where a failed deployment failed","enum":["prepare","fetch_source","pre_build_hook","deps","compile","assets","release","post_build_hook","upload","pre_deploy_hook","migrate","start","health_check","start_worker","finalize","post_deploy_hook","switch_traffic","database","preflight","env_check"],"nullable":true,"type":"string"},"failure_summary":{"description":"AI summary of a failure","nullable":true,"type":"string"},"finished_at":{"format":"date-time","nullable":true,"type":"string"},"id":{"type":"string"},"log_tail":{"description":"The last 50 log lines, secrets redacted","type":"string"},"missing_env_vars":{"description":"Variables the failed build needed and the app still lacks","items":{"type":"string"},"type":"array"},"phase":{"description":"The current step while building, up to 10 seconds behind","enum":["prepare","fetch_source","pre_build_hook","deps","compile","assets","release","post_build_hook","upload","pre_deploy_hook","migrate","start","health_check","start_worker","finalize","post_deploy_hook","switch_traffic"],"nullable":true,"type":"string"},"source":{"properties":{"repo":{"nullable":true,"type":"string"},"sha":{"nullable":true,"type":"string"},"type":{"enum":["git"],"type":"string"}},"required":["type","repo","sha"],"type":"object"},"started_at":{"format":"date-time","nullable":true,"type":"string"},"status":{"description":"succeeded, failed, rolled_back and canceled are terminal","enum":["queued","building","succeeded","failed","rolled_back","canceled"],"type":"string"},"trigger":{"enum":["push","manual","rollback","api"],"nullable":true,"type":"string"},"urls":{"properties":{"app":{"format":"uri","nullable":true,"type":"string"},"dashboard":{"format":"uri","type":"string"},"env":{"description":"The app's Environment page, with ?add= naming missing variables","format":"uri","type":"string"}},"required":["dashboard","env","app"],"type":"object"}},"required":["id","app_id","status","phase","failed_phase","commit_sha","commit_message","branch","source","trigger","error","created_at","started_at","finished_at","log_tail","failure_summary","missing_env_vars","urls"],"title":"Deployment","type":"object"},"DeploymentList":{"properties":{"data":{"items":{"allOf":[{"$ref":"#/components/schemas/DeploymentSummary"},{"properties":{"rollback_target":{"description":"The deployment POST /deployments/{id}/rollback restores","type":"boolean"}},"required":["rollback_target"],"type":"object"}]},"type":"array"},"next_cursor":{"nullable":true,"type":"string"}},"required":["data","next_cursor"],"title":"DeploymentList","type":"object"},"DeploymentResponse":{"properties":{"data":{"$ref":"#/components/schemas/Deployment"},"meta":{"description":"deduplicated is true when an in-flight deployment of the same commit was returned","properties":{"deduplicated":{"type":"boolean"}},"type":"object"}},"required":["data"],"title":"DeploymentResponse","type":"object"},"DeploymentSummary":{"properties":{"branch":{"nullable":true,"type":"string"},"commit_sha":{"nullable":true,"type":"string"},"created_at":{"format":"date-time","type":"string"},"dashboard_url":{"format":"uri","type":"string"},"finished_at":{"format":"date-time","nullable":true,"type":"string"},"id":{"type":"string"},"status":{"enum":["queued","building","succeeded","failed","rolled_back","canceled"],"type":"string"},"trigger":{"enum":["push","manual","rollback","api"],"nullable":true,"type":"string"}},"required":["id","status","commit_sha","branch","trigger","created_at","finished_at","dashboard_url"],"title":"DeploymentSummary","type":"object"},"EnvVar":{"additionalProperties":false,"description":"An environment variable's name and flags. Values are never returned.","properties":{"generated":{"description":"Potions created the value","type":"boolean"},"kind":{"description":"Agents may write config values; secrets are entered in the dashboard","enum":["config","secret"],"type":"string"},"locked":{"description":"Managed by Potions; can't be changed","type":"boolean"},"name":{"type":"string"},"updated_at":{"format":"date-time","type":"string"}},"required":["name","kind","generated","locked","updated_at"],"title":"EnvVar","type":"object"},"EnvVarList":{"properties":{"data":{"items":{"$ref":"#/components/schemas/EnvVar"},"type":"array"},"next_cursor":{"nullable":true,"type":"string"}},"required":["data","next_cursor"],"title":"EnvVarList","type":"object"},"EnvVarResponse":{"properties":{"data":{"$ref":"#/components/schemas/EnvVar"},"meta":{"properties":{"applies_on_next_deploy":{"type":"boolean"},"created":{"description":"generate only: false when it was already set","type":"boolean"}},"type":"object"}},"required":["data","meta"],"title":"EnvVarResponse","type":"object"},"Error":{"description":"Every /api/v1 error. Keys that would be null are left out.","example":{"error":{"code":"commit_not_found","details":{"ref":"4f2c9a0e1b7d3c5a8f6e2d1c0b9a8f7e6d5c4b3a","ref_type":"sha","repo":"acme/shop"},"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."}},"properties":{"error":{"properties":{"code":{"description":"Stable, machine-readable code","type":"string"},"details":{"additionalProperties":true,"type":"object"},"message":{"description":"For humans","type":"string"},"next":{"description":"What an agent should do next","type":"string"},"url":{"description":"A page the user can open","format":"uri","type":"string"}},"required":["code","message"],"type":"object"}},"required":["error"],"title":"Error","type":"object"},"GenerateSecretRequest":{"additionalProperties":false,"properties":{"length":{"description":"Default 64","maximum":128,"minimum":32,"type":"integer"}},"title":"GenerateSecretRequest","type":"object"},"LogEvent":{"description":"One line of the NDJSON log stream.","properties":{"at":{"description":"heartbeat","format":"date-time","type":"string"},"deployment":{"allOf":[{"$ref":"#/components/schemas/Deployment"}],"description":"start and end"},"phase":{"description":"status: the build phase","nullable":true,"type":"string"},"reason":{"description":"end","enum":["finished","snapshot","timeout"],"type":"string"},"status":{"description":"status: the API status","type":"string"},"text":{"description":"line: one redacted log line","type":"string"},"type":{"enum":["start","line","status","heartbeat","end"],"type":"string"}},"required":["type"],"title":"LogEvent","type":"object"},"Me":{"description":"The token's user and the token itself.","properties":{"abilities":{"items":{"type":"string"},"type":"array"},"email":{"type":"string"},"id":{"description":"The user's id","type":"string"},"subscription_status":{"description":"The subscription's status, or none","type":"string"},"token":{"properties":{"app_id":{"description":"Set when the token is limited to one app","nullable":true,"type":"string"},"client":{"description":"For OAuth tokens (phase 4b): the connected app; null otherwise.","nullable":true,"properties":{"name":{"type":"string"},"verified":{"type":"boolean"}},"type":"object"},"created_via":{"enum":["settings","cli_device","oauth"],"type":"string"},"expires_at":{"format":"date-time","nullable":true,"type":"string"},"name":{"type":"string"},"prefix":{"description":"pot_ plus the first 8 characters","type":"string"}},"required":["name","prefix","expires_at","app_id","created_via"],"type":"object"},"urls":{"properties":{"api_tokens":{"format":"uri","type":"string"},"dashboard":{"format":"uri","type":"string"},"docs":{"format":"uri","type":"string"}},"required":["dashboard","api_tokens","docs"],"type":"object"}},"required":["id","email","subscription_status","abilities","token","urls"],"title":"Me","type":"object"},"MeResponse":{"properties":{"data":{"$ref":"#/components/schemas/Me"}},"required":["data"],"title":"MeResponse","type":"object"},"PutEnvVarRequest":{"additionalProperties":false,"properties":{"kind":{"description":"Default config; secret needs the env:secret ability","enum":["config","secret"],"type":"string"},"value":{"description":"One line, at most 4,096 bytes","type":"string"}},"required":["value"],"title":"PutEnvVarRequest","type":"object"},"Server":{"properties":{"app_count":{"type":"integer"},"bring_your_own":{"type":"boolean"},"capacity":{"$ref":"#/components/schemas/Capacity"},"created_at":{"format":"date-time","type":"string"},"dashboard_url":{"format":"uri","type":"string"},"database_engine":{"enum":["postgres","sqlite"],"type":"string"},"disk_gb":{"nullable":true,"type":"integer"},"eligible_for_apps":{"description":"An active app server: new apps can be created on it","type":"boolean"},"id":{"type":"string"},"memory_mb":{"nullable":true,"type":"integer"},"name":{"type":"string"},"provider":{"description":"null for a server you brought (bring your own)","enum":["hetzner","digital_ocean"],"nullable":true,"type":"string"},"region":{"nullable":true,"type":"string"},"role":{"enum":["app","database","load_balancer"],"type":"string"},"size":{"description":"The provider's size slug","nullable":true,"type":"string"},"status":{"enum":["creating","provisioning","active","error","deleting"],"type":"string"},"supported_databases":{"description":"The database values POST /apps accepts for this server","items":{"enum":["postgres","sqlite","none"],"type":"string"},"type":"array"},"vcpus":{"nullable":true,"type":"integer"}},"required":["id","name","provider","region","status","role","app_count","dashboard_url","eligible_for_apps","database_engine","supported_databases","bring_your_own"],"title":"Server","type":"object"},"ServerDetail":{"allOf":[{"$ref":"#/components/schemas/Server"},{"properties":{"provisioning":{"description":"While the server is being set up, or after setup failed","nullable":true,"properties":{"completed_steps":{"type":"integer"},"error":{"nullable":true,"type":"string"},"started_at":{"format":"date-time","nullable":true,"type":"string"},"step":{"nullable":true,"type":"string"},"total_steps":{"nullable":true,"type":"integer"},"waiting_for_connect":{"description":"A server you brought that is waiting for its connect command","type":"boolean"}},"type":"object"},"resources":{"properties":{"apps":{"items":{"properties":{"database_kind":{"type":"string"},"id":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"}},"type":"object"},"type":"array"},"specs":{"properties":{"currency":{"nullable":true,"type":"string"},"disk_gb":{"nullable":true,"type":"integer"},"memory_mb":{"nullable":true,"type":"integer"},"monthly_price":{"nullable":true,"type":"string"},"size":{"nullable":true,"type":"string"},"swap_mb":{"nullable":true,"type":"integer"},"vcpus":{"nullable":true,"type":"integer"}},"type":"object"},"usage":{"description":"The latest sample (every 5 minutes); null before the first","nullable":true,"properties":{"as_of":{"format":"date-time","type":"string"},"cpu_percent":{"nullable":true,"type":"number"},"disk_percent":{"nullable":true,"type":"number"},"disk_total_gb":{"nullable":true,"type":"number"},"disk_used_gb":{"nullable":true,"type":"number"},"load_average_1":{"nullable":true,"type":"number"},"load_average_15":{"nullable":true,"type":"number"},"load_average_5":{"nullable":true,"type":"number"},"memory_percent":{"nullable":true,"type":"number"},"memory_total_mb":{"nullable":true,"type":"integer"},"memory_used_mb":{"nullable":true,"type":"integer"}},"type":"object"},"window_24h":{"nullable":true,"properties":{"covers_hours":{"type":"number"},"cpu_percent":{"properties":{"avg":{"nullable":true,"type":"number"},"max":{"nullable":true,"type":"number"},"p95":{"nullable":true,"type":"number"}},"type":"object"},"disk_percent_max":{"nullable":true,"type":"number"},"hours":{"type":"integer"},"load_average_1":{"properties":{"avg":{"nullable":true,"type":"number"},"max":{"nullable":true,"type":"number"},"p95":{"nullable":true,"type":"number"}},"type":"object"},"memory_used_mb":{"properties":{"avg":{"nullable":true,"type":"number"},"max":{"nullable":true,"type":"number"},"p95":{"nullable":true,"type":"number"}},"type":"object"},"samples":{"type":"integer"}},"type":"object"}},"required":["specs","apps"],"type":"object"}},"required":["resources"],"type":"object"}],"title":"ServerDetail"},"ServerList":{"properties":{"data":{"items":{"$ref":"#/components/schemas/Server"},"type":"array"},"next_cursor":{"nullable":true,"type":"string"}},"required":["data","next_cursor"],"title":"ServerList","type":"object"},"ServerOptions":{"properties":{"bring_your_own":{"properties":{"available":{"type":"boolean"},"docs_url":{"format":"uri","type":"string"},"requirements":{"type":"string"}},"type":"object"},"plan":{"properties":{"can_create":{"type":"boolean"},"server_limit":{"type":"integer"},"servers_used":{"type":"integer"}},"required":["servers_used","server_limit","can_create"],"type":"object"},"providers":{"items":{"properties":{"connect_url":{"format":"uri","type":"string"},"connected":{"type":"boolean"},"credentials":{"items":{"properties":{"id":{"type":"string"},"label":{"type":"string"},"provider":{"enum":["digital_ocean","hetzner"],"type":"string"},"status":{"description":"invalid: Potions can no longer use its token; the user reconnects it","enum":["active","invalid"],"type":"string"}},"required":["id","provider","label","status"],"type":"object"},"type":"array"},"default_region":{"nullable":true,"type":"string"},"name":{"type":"string"},"provider":{"enum":["digital_ocean","hetzner"],"type":"string"},"regions":{"items":{"properties":{"name":{"type":"string"},"slug":{"type":"string"}},"required":["slug","name"],"type":"object"},"type":"array"}},"required":["provider","name","connected","credentials","regions","connect_url"],"type":"object"},"type":"array"},"sizes":{"description":"Only with provider and region, cheapest family first","items":{"properties":{"currency":{"type":"string"},"disk_gb":{"type":"integer"},"family":{"type":"string"},"family_name":{"type":"string"},"memory_mb":{"type":"integer"},"monthly_price":{"description":"Decimal string billed by the provider (Hetzner's excludes VAT); null if unknown","nullable":true,"type":"string"},"slug":{"type":"string"},"vcpus":{"type":"integer"}},"required":["slug","family","vcpus","memory_mb","disk_gb","monthly_price","currency"],"type":"object"},"type":"array"},"sizes_for":{"description":"Only with provider and region","properties":{"credential_id":{"type":"string"},"provider":{"type":"string"},"region":{"type":"string"}},"type":"object"}},"required":["plan","providers","bring_your_own"],"title":"ServerOptions","type":"object"},"ServerOptionsResponse":{"properties":{"data":{"$ref":"#/components/schemas/ServerOptions"}},"required":["data"],"title":"ServerOptionsResponse","type":"object"},"ServerResponse":{"properties":{"data":{"$ref":"#/components/schemas/ServerDetail"},"meta":{"type":"object"}},"required":["data"],"title":"ServerResponse","type":"object"}},"securitySchemes":{"bearer":{"scheme":"bearer","type":"http"}}},"info":{"description":"Find and deploy Potions apps. Authenticate with an API token from Account, API tokens.","title":"Potions API","version":"1.0.0"},"openapi":"3.0.0","paths":{"/api/v1/apps":{"get":{"callbacks":{},"description":"With repo: 0 or 1 apps; more than one match is a 409 app_ambiguous with details.candidates (pass root_dir to narrow monorepo apps). Without repo: every app the token can see, newest first, paginated with limit and after.","operationId":"PotionsWeb.API.V1.AppController.index","parameters":[{"description":"owner/name","in":"query","name":"repo","required":false,"schema":{"type":"string"}},{"description":"Without repo: 1 to 100","in":"query","name":"limit","required":false,"schema":{"type":"integer"}},{"description":"Without repo: next_cursor","in":"query","name":"after","required":false,"schema":{"type":"string"}},{"description":"Omit for any directory; empty or . for the repo root","in":"query","name":"root_dir","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppList"}}},"description":"Apps"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"app_ambiguous"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"}},"summary":"Find the app for a repository, or list your apps","tags":["Apps"]},"post":{"callbacks":{},"description":"Idempotent on repo + root_dir: returns 201 with meta.created true for a new app, or 200 with meta.created false (and meta.differences) for the existing one, changing nothing. Never starts a deploy: deploy with POST /apps/{id}/deployments next. With more than one eligible server and no server_id, 409 choose_server lists the candidates.","operationId":"PotionsWeb.API.V1.AppController.create","parameters":[{"description":"Retries with the same key replay the first success for 24 hours","in":"header","name":"Idempotency-Key","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAppRequest"}}},"description":"The app","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAppResponse"}}},"description":"Already existed"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAppResponse"}}},"description":"Created"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"subscription_inactive"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found (server_id)"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"choose_server or app_ambiguous"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed, repo_not_accessible or no_eligible_server"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"rate_limited"},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"github_unavailable"}},"summary":"Find or create the app for a repository","tags":["Apps"]}},"/api/v1/apps/{id}":{"delete":{"callbacks":{},"description":"Deletes nothing. Returns 202 with a DeletionRequest: the owner opens confirm_url (signed in to Potions), types the app's name and ticks each consequence, as for any deletion. impact lists what deleting does. Follow it with GET /apps/{id}: status deleting, then 404 once it's gone. Needs the apps:delete ability. Agents: send it only when the user's own message asks to delete this app and names it; deleting an app never fixes a failed deploy, build or configuration. Servers can't be deleted through the API: the owner deletes them from the server's dashboard_url.","operationId":"PotionsWeb.API.V1.AppController.delete","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"202":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeletionRequestResponse"}}},"description":"Deletion request"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"}},"summary":"Ask to delete an app","tags":["Apps"]},"get":{"callbacks":{},"operationId":"PotionsWeb.API.V1.AppController.show","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppResponse"}}},"description":"App"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"}},"summary":"Get an app","tags":["Apps"]}},"/api/v1/apps/{id}/deployments":{"get":{"callbacks":{},"description":"Deployment summaries, newest first. At most one has rollback_target: true, the deployment POST /deployments/{id}/rollback accepts (the previous release).","operationId":"PotionsWeb.API.V1.DeploymentController.index","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"1 to 100, default 20","in":"query","name":"limit","required":false,"schema":{"type":"integer"}},{"description":"next_cursor of the previous page","in":"query","name":"after","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentList"}}},"description":"Deployments"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"}},"summary":"List an app's deployments","tags":["Deployments"]},"post":{"callbacks":{},"description":"Deploys the full sha (with or without branch), the head of branch, or with no body the head of the app's branch. The commit must be on GitHub. Returns 201 with the new deployment, or 200 with meta.deduplicated when the same commit is already queued or building (for example because a push started it).","operationId":"PotionsWeb.API.V1.DeploymentController.create","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"1 to 255 printable ASCII characters; retries with the same key replay the first success for 24 hours","in":"header","name":"Idempotency-Key","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDeploymentRequest"}}},"description":"What to deploy","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentResponse"}}},"description":"Deduplicated deployment"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentResponse"}}},"description":"Deployment"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"subscription_inactive"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"needs_env, validation_failed, commit_not_found or repo_not_accessible"},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"github_unavailable"}},"summary":"Deploy a commit of an app","tags":["Deployments"]}},"/api/v1/apps/{id}/env":{"get":{"callbacks":{},"description":"Names, kind (config or secret), generated and locked. Never values.","operationId":"PotionsWeb.API.V1.EnvVarController.index","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"1 to 100, default 20","in":"query","name":"limit","required":false,"schema":{"type":"integer"}},{"description":"next_cursor of the previous page","in":"query","name":"after","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvVarList"}}},"description":"Variables"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"}},"summary":"List an app's environment variable names","tags":["Environment variables"]}},"/api/v1/apps/{id}/env/{name}":{"put":{"callbacks":{},"description":"kind config (the default, ability env:config) writes a non-secret value and refuses values that look like secrets (secret_value_refused), existing secrets, Potions-managed names and names that change the build. kind secret needs the env:secret ability (the CLI's hidden prompt or CI's --stdin; never agents). Applies on the next deploy. The value is never returned.","operationId":"PotionsWeb.API.V1.EnvVarController.update","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"Variable name","in":"path","name":"name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutEnvVarRequest"}}},"description":"The value","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvVarResponse"}}},"description":"Updated"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvVarResponse"}}},"description":"Created"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"secret_value_refused or validation_failed"}},"summary":"Set a variable","tags":["Environment variables"]}},"/api/v1/apps/{id}/env/{name}/generate":{"post":{"callbacks":{},"description":"Creates a secret-kind variable with a random URL-safe value (64 characters, or length 32 to 128). Never overwrites: an existing name returns 200 with meta.created false and nothing changes.","operationId":"PotionsWeb.API.V1.EnvVarController.generate","parameters":[{"description":"App id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"Variable name","in":"path","name":"name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateSecretRequest"}}},"description":"Options","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvVarResponse"}}},"description":"Already set"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnvVarResponse"}}},"description":"Generated"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"}},"summary":"Have Potions generate a random secret","tags":["Environment variables"]}},"/api/v1/client_events":{"post":{"callbacks":{},"description":"name is no_git_remote, head_not_pushed or dirty_tree_skipped. Answers 204. Used only to count how often deploys stop locally.","operationId":"PotionsWeb.API.V1.ClientEventController.create","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientEventRequest"}}},"description":"The event","required":true},"responses":{"204":{"description":"Recorded"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"rate_limited"}},"summary":"Report where a client stopped before deploying","tags":["Client events"]}},"/api/v1/deployments/{id}":{"get":{"callbacks":{},"description":"With wait, returns as soon as the deployment reaches a terminal status (succeeded, failed, rolled_back) or after wait seconds, whichever is first. After a failure it waits up to 20 more seconds (within wait) for failure_summary.","operationId":"PotionsWeb.API.V1.DeploymentController.show","parameters":[{"description":"Deployment id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"Seconds to wait, 0 to 50 (default 0)","in":"query","name":"wait","required":false,"schema":{"maximum":50,"minimum":0,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentResponse"}}},"description":"Deployment"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"}},"summary":"Get a deployment, optionally waiting for it to finish","tags":["Deployments"]}},"/api/v1/deployments/{id}/logs":{"get":{"callbacks":{},"description":"Redacted NDJSON, one LogEvent per line: start, line, status, heartbeat (every 15 seconds while following), end. Without follow it sends the stored log and ends; with follow=1 it streams live lines until the deployment finishes (end.reason finished) or 30 minutes pass (timeout). A token may hold 5 open streams.","operationId":"PotionsWeb.API.V1.DeploymentLogController.show","parameters":[{"description":"Deployment id","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"1 to stream live","in":"query","name":"follow","required":false,"schema":{"type":"integer"}},{"description":"Only the last N stored lines (1 to 10000)","in":"query","name":"tail","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"content":{"application/x-ndjson":{"schema":{"$ref":"#/components/schemas/LogEvent"}}},"description":"Log events"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"rate_limited"}},"summary":"Read or follow a deployment's log","tags":["Deployments"]}},"/api/v1/deployments/{id}/rollback":{"post":{"callbacks":{},"description":"The id is the deployment to restore, and it must be the app's rollback target (rollback_target: true in GET /apps/{id}/deployments). Otherwise 409 rollback_unavailable, with details.rollback_target_id when there is a valid one. Returns 201 with the new rollback deployment; wait on it with GET /deployments/{id}?wait=50.","operationId":"PotionsWeb.API.V1.DeploymentController.rollback","parameters":[{"description":"The deployment to restore","in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentResponse"}}},"description":"Rollback deployment"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"subscription_inactive"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"rollback_unavailable"}},"summary":"Roll back to a previous deployment","tags":["Deployments"]}},"/api/v1/me":{"get":{"callbacks":{},"operationId":"PotionsWeb.API.V1.MeController.show","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}},"description":"Me"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Error"}},"summary":"The token's user, abilities and links","tags":["Account"]}},"/api/v1/server_options":{"get":{"callbacks":{},"description":"The plan's server room, each cloud provider with your connected accounts and regions, and bring your own. With provider and region: that region's sizes with monthly prices, for POST /servers. Tokens limited to one app can't use it.","operationId":"PotionsWeb.API.V1.ServerOptionsController.show","parameters":[{"description":"digital_ocean or hetzner; with region, lists sizes","in":"query","name":"provider","required":false,"schema":{"type":"string"}},{"description":"A region slug","in":"query","name":"region","required":false,"schema":{"type":"string"}},{"description":"The cloud account, when more than one is connected for the provider","in":"query","name":"credential_id","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerOptionsResponse"}}},"description":"Server options"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"choose_credential"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed, no_cloud_credential or credential_invalid"}},"summary":"What servers you can create","tags":["Servers"]}},"/api/v1/servers":{"get":{"callbacks":{},"description":"Servers that can host new apps have eligible_for_apps: true. Tokens limited to one app can't list servers.","operationId":"PotionsWeb.API.V1.ServerController.index","parameters":[{"description":"true: only servers that can host new apps","in":"query","name":"eligible","required":false,"schema":{"type":"boolean"}},{"description":"1 to 100, default 20","in":"query","name":"limit","required":false,"schema":{"type":"integer"}},{"description":"next_cursor of the previous page","in":"query","name":"after","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerList"}}},"description":"Servers"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"}},"summary":"List your servers","tags":["Servers"]},"post":{"callbacks":{},"description":"Creates an app server on a connected DigitalOcean or Hetzner account (it bills that account), or adds a server you bring (provider custom). Idempotent on name: an existing server with that name comes back with 200 and meta.created false, changing nothing. Send expected_monthly_price (from GET /server_options) to have Potions refuse with 409 price_mismatch if the price isn't what the user agreed to. Setup takes 5 to 10 minutes: follow it with GET /servers/{id}?wait=50. A server you bring waits for its connect command, which the user copies from meta.connect_url; it is never returned here.","operationId":"PotionsWeb.API.V1.ServerController.create","parameters":[{"description":"Retries with the same key replay the first success for 24 hours","in":"header","name":"Idempotency-Key","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateServerRequest"}}},"description":"The server","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateServerResponse"}}},"description":"Already existed"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateServerResponse"}}},"description":"Created"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"subscription_inactive or server_limit_reached"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"insufficient_ability"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found (credential_id)"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"choose_credential or price_mismatch"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed, no_cloud_credential or credential_invalid"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"rate_limited"}},"summary":"Find or create an app server","tags":["Servers"]}},"/api/v1/servers/{id}":{"get":{"callbacks":{},"description":"The server with resources (specs and monthly price, the latest metrics, the last 24 hours as avg, p95 and max, the apps on it) and capacity: a verdict on room for one more app (room, tight, full, unknown, unavailable, not_app_server) with reasons. While it is being set up, provisioning shows the step. With wait, returns once the server is active or failed, or after wait seconds.","operationId":"PotionsWeb.API.V1.ServerController.show","parameters":[{"description":"","in":"path","name":"id","required":true,"schema":{"type":"string"}},{"description":"Seconds to wait for setup to finish, 0 to 50 (default 0)","in":"query","name":"wait","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerResponse"}}},"description":"Server"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"not_found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"validation_failed"}},"summary":"Get a server with its resources, optionally waiting for setup","tags":["Servers"]}}},"security":[{"bearer":[]}],"servers":[{"url":"https://potions.io","variables":{}}],"tags":[]}