Snapwake

DocsReference

HTTP API

The CLI and the console use this API, and you can call it from your own scripts and CI. It is a beta API and may change before the public launch.

Basics

  • Address: the FLARE_API value in ~/.flare/api.env after snapwake login.
  • Authentication: Authorization: Bearer <token>, with a token from snapwake login (FLARE_TOKEN in the same file). A token can see and change only its organization's apps.
  • Format: JSON request and response bodies, except uploads.
  • Errors: an HTTP status and {"error": "what went wrong"}.
Status Meaning
400 the request is malformed or a value is out of range
401 no token, or the token is unknown or revoked
402 the change doesn't fit your plan, or your organization is paused (the message says which)
403 not your app, or your organization is suspended
404 no such app, version or job
409 the change conflicts with the current state (for example, the app has no server yet, or there is no previous version)

Who am I

Output
GET /v1/whoami
→ {"who": "person", "user": 12345, "login": "ada", "org": "ada"}

Apps

List

Output
GET /v1/apps
→ {"rev": 1834, "apps": [ <app>, ... ]}

Get one

Output
GET /v1/apps/shop
JSON
{
  "name": "shop",
  "org": "ada",
  "processes": {
    "web": {"kind": "web", "port": 3000, "mem_mb": 512, "min": 0, "max": 4,
            "concurrency": 10, "health_path": "/healthz", "health_every_s": 10}
  },
  "volumes": [{"name": "data", "path": "/data", "size_mb": 1024}],
  "versions": [
    {"id": "v1764158400123", "source": "upload:9f2c…", "state": "ready", "node": "n2", "at": 1764158400123}
  ],
  "current": "v1764158400123",
  "previous": "v1764151100456",
  "home": "n2",
  "spare": "n1",
  "status": {"state": "awake", "instances": 1, "health": "ok", "fails": 0, "failure": null,
             "version": "v1764158400123", "seen_ms_ago": 420}
}

status is what the home server reported last; it is missing until the app has been placed. The response also carries internal fields (volume_epoch, volumes_degraded, and secrets, an encrypted blob only Snapwake's servers can open); don't depend on them.

Create or change

Output
PUT /v1/apps/shop
{"processes": {"web": {"kind": "web", "port": 3000, "mem_mb": 512, "min": 0, "max": 1}},
 "volumes": [{"name": "data", "path": "/data", "size_mb": 1024}]}

Creates the app or replaces its settings. Without processes, a default web process (512 MB, 0 to 1 VMs) is used. Without volumes, the app keeps the volumes it has.

Process field Values
kind web or worker (an app has exactly one process for now)
port the port the app listens on
command start command
mem_mb 64 to 65536, within your plan
min, max 0 ≤ min ≤ max, 1 ≤ max ≤ 64, within your plan; max must be 1 with volumes
concurrency 1 to 1000; omit for the default (4)
health_path, health_every_s health check path (starts with /, at most 200 bytes) and interval (0 for the default 10, at most 3600)
queue workers only: {"url": "REDIS_URL", "lists": ["rq:queue:default"], "busy": ["rq:wip:default"]}; url is the name of the secret holding the Redis URL

Volumes: at most 4, each with its own name and absolute path, size_mb from 64 to 1048576; a volume can grow but not shrink.

Delete

Output
DELETE /v1/apps/shop

Versions

Upload a folder

Output
POST /v1/uploads
Content-Type: application/octet-stream
<a tar archive of the folder, at most 512 MB>
→ {"upload": "<sha256 of the archive>"}

Build a version

Output
POST /v1/apps/shop/versions
{"source": "image:ghcr.io/acme/shop:1.4"}
{"source": "upload:<sha256>", "dockerfile": "Dockerfile.prod", "build_args": ["NODE_VERSION=22"]}
→ {"version": "v1764158400123", "rev": 1835}

The version starts as building. Poll GET /v1/apps/shop until its state is ready (it then becomes current) or failed (see its note).

Switch versions

Output
POST /v1/apps/shop/rollback
→ {"current": "v1764151100456", "rev": 1836}

POST /v1/apps/shop/current
{"version": "v1764158400123"}

Only a ready version can become current.

Secrets

Output
POST /v1/apps/shop/secrets?wait=30
{"set": {"DATABASE_URL": "postgres://…"}, "unset": ["OLD_FLAG"]}
→ {"job": "3f9a…", "app": "shop", "state": "done", "names": ["DATABASE_URL", "STRIPE_KEY"]}

Secrets are handed to the app's home server, which encrypts and stores them, so the call creates a job. With ?wait=S (up to 30) the response comes when the job is done or the time is up. If state is still queued or taken, poll GET /v1/jobs/<job>. A finished job lists the app's secret names; send {} to just list them. Values are never returned.

Limits per call: 1000 names and 256 KB. The app must have been placed on a server (409 otherwise).

Logs

Output
GET /v1/apps/shop/logs?n=100
→ {"offset": 52311, "text": "…"}

GET /v1/apps/shop/logs?after=52311
→ {"offset": 52480, "text": "…new lines…"}

n is the number of last lines (default 200, at most 5000). after continues from an earlier offset.

Usage

Output
GET /v1/billing                  plan, this month's usage and cost by resource and by app, what's left, limits, whether paused and why, invoice draft
GET /v1/billing/ledger?after=N   the account's entries: monthly allowance, usage slices, credits
PUT /v1/billing/cap              {"spend_cap_usd": 100}   your spend limit (Pro and Team)

CLI tokens

Output
GET    /v1/tokens          your CLI tokens in this organization
DELETE /v1/tokens/<id>     revoke one

Health

Output
GET /v1/health   → {"rev": 1836}   no token needed