---
seo:
  description: >-
    Everything an integration needs to deploy and run an app on Sproutboat Cloud
    without the CLI: create and delete apps, upload a source bundle and static
    assets…
sidebar:
  label: Overview
title: Sproutboat Cloud API
---
Everything an integration needs to deploy and run an app on Sproutboat Cloud without the CLI: create and delete
apps, upload a source bundle and static assets by sha256, start and follow a build, wait until a generation is
live, set secrets, edit routes and custom domains, read build logs, app metrics and a running app's logs.

This is a **draft**. It describes what the code does today, and it is checked against the Cloud's routes whenever a
route is added or removed. Statements
marked **Uncertain** were read from the code but not exercised against a live Cloud.

## Authentication

Every route except `GET /v1/health` takes a team API key, `sbk_...`, in either header:

```
Authorization: Bearer sbk_...
x-api-key: sbk_...
```

A key belongs to one team (organization) and every call acts on that team's apps; there is no team header to set.
Create a key in the dashboard, **Settings, API keys**: pick a preset (Read only, Read data, Deploy, Deploy and
data, Admin) and an expiry (1 day to 1 year, or none). The key is shown once. A key holds *grants*, listed on each
operation as `x-sproutboat-permission`, for example `app:write`. `GET /v1/whoami` returns the grants of the key
you present. A key cannot create keys, and no route returns a secret value.

| Grant | Allows |
| --- | --- |
| `app:read` | list and read apps, builds, metrics, events |
| `app:write` | deploy: upload sources and assets, start builds, replace an app's spec, edit routes |
| `app:delete_own` | delete the apps this key created |
| `app:delete` | delete any app of the team |
| `secret:list` | read secret *names* |
| `secret:write` | set and delete secrets |
| `data:read` / `data:write` | read / change an app's D1 and R2 data |
| `logs:read` | read a running app's logs: the recent lines and the live stream |
| `domain:read` / `domain:write` | read / add, verify and remove custom domains |

## Servers

The CLI's default is `https://dash.sproutboat.com` (the API and the dashboard share one origin; the API lives under
`/v1`). Cloud apps are served on `https://<project>.<team>.sproutboat.app`, where `<team>` is
`organization_slug` from `GET /v1/whoami`.

## Errors

An error is a JSON object with a human-readable `error` string and, for most of them, a machine-readable
`reason`. Some add `path` (the field at fault), `need` (the missing grant) or a wait (`retry_after_s`; the
upload and data limits spell it `retry_after`). Branch on the HTTP status and `reason`, never on the wording of
`error`.

**Every documented `reason` has a schema of its own**, `Error<Reason>` in the components (for example
`ErrorBlobsMissing`, with its `missing` and `missing_count`), whose `reason` is a `const`. Each operation lists
the ones it can answer, per status, as a `oneOf` (with a `discriminator` on `reason` where every arm has one). The
list is checked against the Cloud's handlers whenever one is added, so a reason that is thrown is documented. A Cloud
may add reasons over time: treat an unknown `reason` like the rest of its status.

```json
{ "error": "hosts[0]: \"x.example.com\" is not a valid route (...)", "reason": "invalid", "path": "hosts[0]" }
```

Not every error has a `reason` (schema `ErrorPlain`): a missing app or build is `{"error": "no such app"}` (404), a
wrong method is 405 `{"error": "method not allowed"}`, an unknown path is 404 `{"error": "not found"}`, and an
unexpected failure is 500 `{"error": "internal error"}`. The one 403 without a `reason` is
`{"error": "module-upload-disabled", "message": "..."}` (`ErrorModuleUploadDisabled`): read `error`.
Statuses: 400 invalid input, 401 missing, invalid, expired or revoked key, 403 the key lacks a grant
(`reason: forbidden`, `need`), may not use a route (`host-not-yours`) or is over a quota, 404 not found (another
team's app is also 404), 409 conflict, 411 a chunked upload without a declared length, 413 too large (`too-large`,
on JSON bodies as well: 256 KiB, or 1 MiB for specs, builds, secrets and route edits), 422 a D1 statement over the
host's memory, 429 limited, 502 the host agent misbehaved, 503 temporarily unavailable, 504 the host timed out,
507 an app's storage on its host is full.

Free alpha quotas apply per team (one team per user, and a team's URL name, its slug, never changes): apps per team,
what an app may ask for in `limits` (memory, storage, CPU time, wall time, request rate, binding operations), builds
that compile per rolling 24 hours, bytes of new sources and of new static assets per rolling 24 hours, and storage
(`limits.storage_mb` and the team's static assets). `GET /v1/limits` returns the team's limits and usage. Over a
limit: 403 with `reason` `quota-apps`, `quota-memory`, `quota-storage`, `quota-cpu`, `quota-wall`, `quota-rate` or
`quota-ops` when an app is written (a `limits` value over its ceiling is refused, never clamped; an app already over a
ceiling keeps it and can be lowered or redeployed, not raised), 429 with `reason: quota-builds` when a build is
started, and 429 with `reason: quota-upload` when a source or a blob would pass the 24-hour byte budget. The 429s carry
`retry_after_s` and a `Retry-After` header. The `error` text is meant to be shown as it is. Treat any 403 or 429 with
an unknown `reason` the same way.

## Rate limits

- **Per key:** 2,000 requests a minute for a key that holds `app:write` (a deploy sends one request per missing asset
  file, plus the polls of the rollout), 600 for a key that cannot write. Over it: 429, `reason: key-rate-limited`,
  `retry_after_s`, and a `Retry-After` header; wait that long and send the same request again. Keys made before
  2026-11-25 that could deploy were raised to 2,000 as well.
- **Data routes** (D1 query, R2 objects): per team, 2 requests in flight and a bucket of 60 refilled at 10 a second.
  Over it: 429, `reason: rate`, `retry_after`, `Retry-After` header. Counted per API process, so treat them as approximate.
- **Uploads** (`PUT /v1/sources/...`, `PUT /v1/assets/blobs/...`, `PUT /v1/assets/manifests/...`): per team, not per key.
  Over the rate: 429, `reason: upload-rate`, `retry_after`, `Retry-After`. Blob uploads in flight at once are bounded per
  API process: 429, `reason: busy`, `Retry-After: 5`. New bytes per rolling 24 hours: 429, `reason: quota-upload`.
- **Builds:** per team, 3 builds queued or running, 20 new (not cached) builds an hour; platform-wide, a queue of
  50. See `POST /v1/apps/{project}/builds` for the reasons.
- **Domains:** 10 custom domains per team, one verification check per domain every 10 seconds, 20 new
  verifications an hour platform-wide.

## Idempotency, concurrency, pagination

There is no `Idempotency-Key` header. What is safe to repeat:

- Uploads by sha256 (`PUT /v1/sources/...`, `PUT /v1/assets/blobs/...`, `PUT /v1/assets/manifests/...`) are
  content-addressed: sending the same bytes again is a no-op (`stored: false`, and no quota is charged). What a team
  has uploaded is private to it: `POST /v1/sources/missing` and `POST /v1/assets/missing` answer for the team's own
  uploads only (bytes another team holds are reported missing until you send them), a manifest may name only blobs the
  team uploaded, and `GET /v1/assets/manifests/{sha256}` is 404 for a manifest the team neither uploaded nor uses.
- `POST /v1/apps/{project}/builds` with the same source, `build` and runtime answers from a cache (HTTP 200, a
  `ready` build with `cached: true`) instead of building again; the app still gets a new `record_generation`.
- `POST /v1/domains` for a host you already claimed returns the existing claim (200).
- Every write to an app (`PUT`, secrets, routes, a finished build) bumps its `record_generation`, even when the
  content did not change. Writes to one app are serialized; the last write wins. A newer build of a project
  cancels its older *queued* build (`superseded: true`).

No list route has a cursor. `GET /v1/apps` returns every app. `GET /v1/apps/{project}/builds` takes `limit`
(1 to 100, default 20) and returns the newest. Metrics and events are windows (a range, the last 20 events per kind).

## What is not in this file

Git push-to-deploy (`/v1/git/*`, `/v1/apps/{project}/git*`), the browser sign-in flows, and team and key management
are not part of this file. A running app's own output is read through
`GET /v1/apps/{project}/logs` (recent lines) and `GET /v1/apps/{project}/tail` (live), or grouped one run per request through
`GET /v1/apps/{project}/invocations` and `.../invocations/tail`; build logs stream over
`GET /v1/builds/{id}/events`, and `GET /v1/apps/{project}/events` returns only the last exceptions and triggers (a
counter ring, not a log). There is no rollback route either; see *Deploy flow* for how a previous version is redeployed.

## Deploy flow

This is the order the CLI calls the routes for `sproutboat deploy` (source build, the default):

1. `GET /v1/whoami` for the team slug, once, to name the route `<project>.<slug>.sproutboat.app`.
2. `GET /v1/apps` (only when the app binds other apps as services) and `GET /v1/apps/{project}` (404 means a new app).
3. If the app has static assets: `POST /v1/assets/missing`, `PUT /v1/assets/blobs/{sha256}` for each missing one,
   `PUT /v1/assets/manifests/{sha256}`. The manifest's digest is its `assets_manifest_ref` (`assets/<sha256>`).
4. `POST /v1/sources/missing`, then `PUT /v1/sources/{sha256}` if the source is missing. The source is the app's
   **generated JavaScript**, a single UTF-8 file of at most 8 MiB that the CLI produces (`sproutboat build
   --standalone --emit-only` prints its path). The API has no way to build from your own TypeScript.
5. `POST /v1/apps/{project}/builds` with `{source_sha256, kind: "generated", build, spec}`. The `spec` carries the
   routes (`hosts_patch`), `assets_manifest_ref`, `bindings`, `crons`, `queue_consumers` and `services`.
   **This is how a team creates or updates an app**; there is no separate create call. Secrets are not allowed in
   a build's `spec` (it is stored in plain text).
6. Follow `GET /v1/builds/{id}/events` (Server-Sent Events) until `done`, or poll `GET /v1/builds/{id}` until
   `state` is `ready`, `failed` or `canceled`. `record_generation` appears on the build when it is `ready`.
7. If there are secrets: `PATCH /v1/apps/{project}/secrets`; it returns a newer `record_generation`.
8. **Is it live?** Poll `GET /v1/apps/{project}` until `apply.state` is `applied` and `apply.applied_generation` is at
   least the `record_generation` you are waiting for. The CLI treats `failed` and `fenced` as terminal (`apply.error` says
   why) and otherwise waits up to 120 s, polling every 2 s. `apply` is null until the first apply was attempted.

**Redeploying an earlier version.** A finished build names its `module_sha256`. `PUT /v1/apps/{project}` accepts a
module your own team's builds produced, so a spec with `module.sha256` set to an earlier build's value moves the app
back to it (**Uncertain**: this follows from the rule on `PUT /v1/apps/{project}`, and was not exercised against a live Cloud). Building the same
source again is a cache hit and takes no build time.

Version 1.0.0-draft.1

Base URL: `https://dash.sproutboat.com`

## Meta

Health, the identity of a key, and the team's limits.

- [`GET /v1/health`](/docs/api/reference/meta/get-health) — Liveness.
- [`GET /v1/whoami`](/docs/api/reference/meta/get-whoami) — Who a key is.
- [`DELETE /v1/keys/self`](/docs/api/reference/meta/revoke-self) — Revoke this key.
- [`GET /v1/limits`](/docs/api/reference/meta/get-limits) — Get the team's limits and usage.

## Apps

Create, read, replace and delete apps.

- [`GET /v1/apps`](/docs/api/reference/apps/list-apps) — List the team's apps.
- [`GET /v1/apps/{project}`](/docs/api/reference/apps/get-app) — Read an app.
- [`PUT /v1/apps/{project}`](/docs/api/reference/apps/put-app) — Replace an app's spec.
- [`DELETE /v1/apps/{project}`](/docs/api/reference/apps/delete-app) — Delete an app.

## Uploads

Source bundles and static assets, uploaded by sha256.

- [`POST /v1/sources/missing`](/docs/api/reference/uploads/sources-missing) — Missing sources.
- [`PUT /v1/sources/{sha256}`](/docs/api/reference/uploads/put-source) — Upload a source bundle.
- [`POST /v1/assets/missing`](/docs/api/reference/uploads/assets-missing) — Missing asset blobs.
- [`PUT /v1/assets/blobs/{sha256}`](/docs/api/reference/uploads/put-asset-blob) — Upload one asset file.
- [`GET /v1/assets/manifests/{sha256}`](/docs/api/reference/uploads/get-asset-manifest) — Read an assets manifest.
- [`PUT /v1/assets/manifests/{sha256}`](/docs/api/reference/uploads/put-asset-manifest) — Upload an assets manifest.

## Builds

Start a build, follow its log, cancel it.

- [`GET /v1/apps/{project}/builds`](/docs/api/reference/builds/list-builds) — List an app's builds.
- [`POST /v1/apps/{project}/builds`](/docs/api/reference/builds/create-build) — Start a build.
- [`GET /v1/builds/{id}`](/docs/api/reference/builds/get-build) — Build status.
- [`DELETE /v1/builds/{id}`](/docs/api/reference/builds/cancel-build) — Cancel a build.
- [`GET /v1/builds/{id}/events`](/docs/api/reference/builds/stream-build-events) — Stream a build's log.

## Secrets

Per-app secrets. Names can be listed, values never come back.

- [`GET /v1/apps/{project}/secrets`](/docs/api/reference/secrets/list-secrets) — List secret names.
- [`PATCH /v1/apps/{project}/secrets`](/docs/api/reference/secrets/patch-secrets) — Patch secrets.
- [`PUT /v1/apps/{project}/secrets/{name}`](/docs/api/reference/secrets/put-secret) — Set one secret.
- [`DELETE /v1/apps/{project}/secrets/{name}`](/docs/api/reference/secrets/delete-secret) — Delete one secret.

## Routes and domains

Routes of an app, and custom domains a team proves it owns.

- [`PATCH /v1/apps/{project}/routes`](/docs/api/reference/routes-and-domains/patch-routes) — Add and remove routes.
- [`GET /v1/domains`](/docs/api/reference/routes-and-domains/list-domains) — List the team's custom domains.
- [`POST /v1/domains`](/docs/api/reference/routes-and-domains/add-domain) — Claim a custom domain.
- [`DELETE /v1/domains/{host}`](/docs/api/reference/routes-and-domains/delete-domain) — Release a custom domain.
- [`POST /v1/domains/{host}/verify`](/docs/api/reference/routes-and-domains/verify-domain) — Check the DNS proof.
- [`GET /v1/domains/{host}/status`](/docs/api/reference/routes-and-domains/get-domain-status) — Domain status.

## Data

SQL on an app's D1 databases and objects in its R2 buckets.

- [`POST /v1/apps/{project}/d1/{binding}/query`](/docs/api/reference/data/query-d1) — Query D1.
- [`GET /v1/apps/{project}/r2/{bucket}/objects/{key}`](/docs/api/reference/data/get-r2-object) — Read an object.
- [`PUT /v1/apps/{project}/r2/{bucket}/objects/{key}`](/docs/api/reference/data/put-r2-object) — Write an object.
- [`DELETE /v1/apps/{project}/r2/{bucket}/objects/{key}`](/docs/api/reference/data/delete-r2-object) — Delete an object.

## Observability

Metrics, recent events and notices.

- [`GET /v1/apps/{project}/metrics`](/docs/api/reference/observability/get-app-metrics) — App metrics.
- [`GET /v1/apps/{project}/events`](/docs/api/reference/observability/get-app-events) — Recent exceptions and triggers.
- [`GET /v1/apps/{project}/logs`](/docs/api/reference/observability/get-app-logs) — Recent log lines of a running app.
- [`GET /v1/apps/{project}/tail`](/docs/api/reference/observability/tail-app) — Stream a running app's events live.
- [`GET /v1/apps/{project}/invocations`](/docs/api/reference/observability/list-app-invocations) — Recent runs of a running app, one per request.
- [`GET /v1/apps/{project}/invocations/tail`](/docs/api/reference/observability/tail-app-invocations) — Stream a running app's runs live, one per request.
- [`GET /v1/notices`](/docs/api/reference/observability/list-notices) — List notices.
