API and MCP
Everything the portal does, from code or from an AI agent. Same rules, same checks, same jobs.
API keys
One credential for both the REST API and the MCP server.
Sign in, then create a key on the Account page. A key acts as the customer who created it and cannot create or revoke other keys. Send it on every request:
Authorization: Bearer lathe_…
MCP server
Streamable HTTP · https://app.lathe.computer/mcp
Give an agent the endpoint and a key. Claude Code:
claude mcp add --transport http lathe https://app.lathe.computer/mcp --header "Authorization: Bearer lathe_…"
Claude Desktop, Cursor and most other clients take a JSON entry of this shape:
{
"mcpServers": {
"lathe": {
"type": "http",
"url": "https://app.lathe.computer/mcp",
"headers": { "Authorization": "Bearer lathe_…" }
}
}
}Tools
| Tool | What it does |
|---|---|
list_plans read | Plans with prices (USD per month), hardware, price per GB, and the locations an instance can be created in. |
get_account read | The account behind this key: email, profile (name, company, tax id, address), card on file, and whether another instance can be created now (new accounts run one instance until their first renewal). |
update_account | Update the profile that goes on receipts. Omitted fields keep their value; the name is required before the first purchase. |
get_billing read | Subscriptions (status, tier, next charge) and the charge history. |
list_instances read | The customer's instances with status, tier, location, tags, billing status and any job in progress. No secrets: use get_connection_urls for those. |
get_instance read | One instance in full: status (awaiting_payment / pending / creating / running / …), billing, disk and connection usage, 24h monitoring (load, memory, disk, database size, TPS, cache hit, long queries), backups, recent activity, upgrade options and the pending job if any. |
get_connection_urls read | Connection strings for an instance, password included: direct (5432) and pooled (6432, transaction pooling). Handle as a secret. |
create_instance | Create a Postgres instance on a plan (starter | plus | pro). This costs money: a paid plan returns checkout_url, which the person must open in a browser and pay — the instance is created when the payment page returns, and the returned instance_id is valid from the start (poll get_instance). A coupon that covers the whole first month creates it immediately. Optional: name (a label), tags (lowercase tokens), location (from list_plans), coupon. |
update_instance | Rename or retag an instance. Omitted fields keep their value; an empty name or an empty tag list clears it. Allowed while a job is running. |
set_allowlist | Replace the IP allowlist for ports 5432 and 6432 with a list of CIDRs. An empty list opens the instance to the internet (TLS and password still required). Takes effect within a minute. |
rotate_password | Issue a new database password. The old connection URLs stop working immediately; the new ones come from get_connection_urls once the job is done. |
set_sql_console | Turn the browser SQL console (pgweb on the VM, reachable only through the portal) off, read-only (ro) or read-write (rw). |
upgrade_instance | Move an instance to a higher plan. The prorated difference for the rest of the billing period is charged to the card on file now; expect 5–10 minutes of downtime. Plans move up only. |
list_backups read | Daily backups (newest first) and undo snapshots that can be restored in place. |
restore_backup destructive | Restore a backup or undo snapshot in place: the current data is replaced (a snapshot of it is kept 7 days). Same address, so connection strings keep working. confirm must be the instance id. |
reset_instance destructive | Wipe the database and start empty (a snapshot is kept 7 days). confirm must be the instance id. |
delete_instance destructive | Delete an instance: billing stops, the VM and its backups are destroyed, a final snapshot is kept 7 days. confirm must be the instance id. |
get_job read | A queued, running or finished operation on one of the customer's instances: kind, status (queued / running / done / error) and the error's first line if it failed. |
Creating an instance costs money: for a paid plan the tool returns a checkout URL that a person opens and pays; the instance is provisioned when the payment page returns. Destructive tools take confirm, the instance id typed exactly, like the portal.
REST API
Base URL https://app.lathe.computer/api/v1 · interactive docs · OpenAPI
curl -H "Authorization: Bearer lathe_…" https://app.lathe.computer/api/v1/instances
curl -H "Authorization: Bearer lathe_…" https://app.lathe.computer/api/v1/instances/ID/connection
curl -X POST -H "Authorization: Bearer lathe_…" -H "Content-Type: application/json" \
-d '{"tier": "starter", "name": "acme-prod", "tags": ["prod"]}' https://app.lathe.computer/api/v1/instances| Method and path | Purpose |
|---|---|
GET /me · PATCH /me | The account and its profile (what goes on receipts). |
GET /plans · GET /locations | Plans, prices, hardware, locations. |
GET /instances · POST /instances | List; create (returns checkout_url for a paid plan). |
GET /instances/{id} · PATCH · DELETE ?confirm= | Status, usage, monitoring, backups, activity; rename and retag; delete. |
GET /instances/{id}/connection | Connection strings, password included. |
GET /instances/{id}/backups | Daily backups and undo snapshots. |
PUT /instances/{id}/allowlist · PUT …/sql-console | IP allowlist; SQL console off / ro / rw. |
POST /instances/{id}/actions/rotate | resize | reset | restore | Queue an operation; answers 202 with a job id. |
GET /jobs/{id} · GET /billing | A job's progress; subscriptions and charges. |
Errors are JSON: {"detail": "…", "code": "…"}. One job runs per instance at a time; a busy instance answers 409. Reset, restore and delete need confirm = the instance id.