Cloud API
The HTTP API behind sproutboat deploy on Sproutboat Cloud: authentication, errors, limits, and where the reference and the OpenAPI file are.
Sproutboat Cloud has an HTTP API. The sproutboat CLI uses it for deploy, secrets, deployments and domains, and you can call it from anything else: a CI job, a script, or a provider for an infrastructure-as-code tool.
Where to start
- Build a provider walks through a full deploy with
curl: create an app, upload the source and the assets, build, wait until it is live, set a secret and read the logs. - The changelog lists what changed in the API, by date.
- API reference has one page per route, with the grant it needs, its parameters and its answers.
- The OpenAPI 3.1 file is the same description in a form a tool can read. It is the source for the reference.
Address and key
The API and the dashboard share one address, https://dash.sproutboat.com. Every route lives under /v1.
Create a team API key in the dashboard under Settings, API keys. Pick a preset: Deploy is enough to deploy and set secrets, Read data and Deploy and data add an app’s D1 and R2 data, and Admin adds deleting any app. The key is shown once, and it can expire in 1 day to 1 year, or never. Send it on every call:
curl -sS -H "authorization: Bearer $SB_KEY" https://dash.sproutboat.com/v1/whoami
GET /v1/whoami returns the team, its slug and the grants of the key. The slug is the <team> in an app’s address, <app>.<team>.sproutboat.app. A key belongs to one team and acts only on that team’s apps. Keep it in a secret store, never in a repository.
The CLI’s login token works as a Bearer
sproutboat login stores an ordinary team API key, named CLI on <hostname>, and the API accepts it exactly as it accepts a key made in the dashboard. It is a good way to try the API without making a key first:
SB_KEY=$(jq -r '.profiles["https://dash.sproutboat.com"].token' ~/Library/Preferences/sproutboat/credentials.json)
curl -sS -H "authorization: Bearer $SB_KEY" https://dash.sproutboat.com/v1/whoami
The file is ~/Library/Preferences/sproutboat/credentials.json on macOS and ~/.config/sproutboat/credentials.json elsewhere (SPROUTBOAT_CONFIG_DIR moves it). It holds one entry per endpoint address, and token is the key of the default team; teams has the keys of the others. Things to know:
- The key holds at most the Developer grants, whether you are an owner, an admin or a developer in the team (a viewer gets the Viewer grants): apps, secrets, app data, logs, reading domains and connecting Git repositories.
GET /v1/whoamilists them. It cannot create keys or add domains. For those, or for a key that CI keeps, make a key in Settings, API keys. - It expires after a year, and
sproutboat logoutrevokes it. - It is a credential like any other: do not paste it into a chat, a ticket or a repository. For a script that runs unattended, use a key of its own that you can revoke on its own.
Errors
An error is a JSON object with a message for people in error and, for most errors, a stable reason for programs. Some add path (the field at fault), need (the grant that was missing) or a wait in retry_after_s (retry_after on the upload and data limits). Each reason has its own schema in the OpenAPI file, so a code generator can give it a type.
{ "error": "the platform verifies at most 20 new domains an hour; try again later", "reason": "verify-cap", "retry_after_s": 600 }
Branch on the status and the reason, not on the wording of error. A few errors carry no reason: a missing app is {"error": "no such app"} with status 404, a wrong method is 405, and the 403 module-upload-disabled names itself in error instead.
Limits
- A key may make 2,000 requests a minute if it holds
app:write(a deploy sends one request per new asset file, plus the polls of the rollout) and 600 if it cannot write. Over that the answer is 429 withreason: key-rate-limited,retry_after_sand aRetry-Afterheader: wait that long and send the same request again. The CLI does this itself, up to five times. - A team may have 3 builds queued or running and may start 20 new builds an hour. An identical build is answered from a cache and does not count.
- Data routes (D1 queries and R2 objects) allow 2 requests in flight per team.
- Uploads are rate-limited per team, not per key (
upload-rate), and the blobs in flight at once are bounded (busy). - A team may hold 10 custom domains.
- JSON bodies are capped at 256 KiB, or 1 MiB for specs, builds, secrets and route edits (413
too-large). - Free alpha quotas apply per team: 5 apps, 64 MiB of memory per app, ceilings on the CPU time, wall time, request rate and binding operations an app may ask for, 20 builds that compile per 24 hours, 200 MiB of new sources and 1 GiB of new static assets per 24 hours, and 1 GiB of storage, raised by hand on request.
GET /v1/limitsreturns the team’s limits and usage. Over a limit the API answers 403 (quota-apps,quota-memory,quota-storage,quota-cpu,quota-wall,quota-rate,quota-ops) or 429 (quota-builds,quota-upload, withRetry-After), and theerrortext is meant to be shown as it is. - Each user owns one team, and a team’s URL name (its slug, the
<team>in<app>.<team>.sproutboat.app) never changes.
No list route has a cursor. GET /v1/apps returns every app, and the builds list takes a limit of 1 to 100.