Everything the CLI and web UI do goes through the Catchment's HTTP API. This page covers authentication, shared conventions and the available routes. For request and response bodies, every Catchment serves its own schema:
| Path | Contents |
|---|
/openapi.json | The OpenAPI schema. |
/docs | Interactive documentation (Swagger UI). |
/redoc | Reference documentation (ReDoc). |
All routes below are under /api, apart from /metrics.
Authentication
A Catchment is either open, or protected by API keys. An open Catchment treats every request as having full access. This is also the right setting when a hosting platform authenticates requests before they reach the Catchment.
With keys configured, send one as a bearer token:
curl -H "Authorization: Bearer $DUCKSTRING_KEY" http://127.0.0.1:7474/api/status
Keys come in three levels, each including the ones before it:
| Level | Allows |
|---|
read | Status, run history, lineage, data and catalog queries. |
demand | Also Refreshes: refreshing now, and adding and removing recurring Refreshes. |
full | Everything else: deploying, control actions, windows, Spouts, secrets, alerts, ducts, compute and Catchment settings. |
A missing or unrecognised key gets 401; a key below the route's level gets 403. Tracebacks in run history are only returned to full keys; lower levels get the error message alone.
A Tap's key is a fourth kind, outside the levels. It is accepted only by /api/query, /api/serve/query, /api/serve and its own Pond's /freshness, where it reads the Pond's exposed tables (as a read-level key does) and its queries may send the Pond a Refresh, and gets 403 everywhere else. It works on an open Catchment too.
Conventions
Targeting a major line. Routes that act on one Pond take the Pond name in the path and two optional query parameters:
| Parameter | Description |
|---|
major | The major line. Defaults to the highest deployed. |
version | A full version such as 1.2.0. Must be the major line's currently deployed version, otherwise 422. |
Status codes.
| Code | Meaning |
|---|
401, 403 | Authentication, as above. |
404 | Unknown Pond, table, Object, Spout, window or channel. |
409 | The operation needs the Pond idle, or conflicts with its current state. |
422 | Invalid input, including a deployment that breaks a version pin, and a failed confirmation for irreversible operations. |
A connection test (/spouts/test, /alerts/{name}/test) that fails returns 200 with {"ok": false, "error": ...}, since the request itself succeeded.
Routes
Catchment
| Method | Path | Level | Description |
|---|
| GET | /api/health | none | Liveness check. |
| GET | /api/catchment/identity | read | The Catchment's name and id. |
| GET | /api/catchment/settings | read | Data root and cloud status. |
| PUT | /api/catchment/settings | full | Set the data root. |
| GET | /api/catchment/duck-pools | read | Built-in and defined pools. |
| POST | /api/catchment/duck-pools | full | Create or update a pool. |
| DELETE | /api/catchment/duck-pools/{name} | full | Remove a pool. |
| GET | /api/catchment/compute-defaults | read | Catchment-wide compute defaults. |
| GET | /api/catchment/instance-types | full | Machine types available on the Catchment's cloud: EC2 instance types, Azure VM sizes or Compute Engine machine types. |
| POST | /api/catchment/cloud/verify | full | Check the cloud configuration. |
| POST | /api/catchment/keys/rotate | full | Replace API keys. |
| POST | /api/catchment/reset | full | Reset every Pond. |
| GET | /api/catchment/usage | full | Size of the state directory. |
| GET | /api/catchment/archive | full | Download the state directory as a tar stream. |
| GET | /api/catchment/records | read | Where Apps' Records live, and the managed PostgreSQL's state. |
| PUT | /api/catchment/records | full | Change it. Body: any of target, memory, listen, host, tls_cert, tls_key. |
| GET | /api/catchment/records/reader | full | A read-only connection URL for a client on another machine. |
| GET | /api/catchment/media | read | Where Apps' Media lives. |
| PUT | /api/catchment/media | full | Change it. Body: target. |
| POST | /api/catchment/records/move | full | Move Records. Body: target, postgres_version, confirm (the Catchment's name). Runs in the background. |
| POST | /api/catchment/media/move | full | Move Media. Body: target, confirm. |
| GET | /api/catchment/move | read | A move's progress: state (ending done or failed), detail, error. |
Deploying and removing
| Method | Path | Level | Description |
|---|
| POST | /api/deploy | full | Deploy a Pond (a packaged upload or a git reference). Redeploying the version a line runs is a 409 unless force is set or the Pond is an App. A Puddle of the line is a 409 unless replace_puddle is set. |
| GET | /api/ponds/{name}/versions/{version} | read | Whether a version is deployed. |
| DELETE | /api/ponds/{name} | full | Remove a major line. |
Status and history
| Method | Path | Level | Description |
|---|
| GET | /api/status | read | Every Pond's state, freshness, recurring Refreshes and failures, the edges between Ponds, and the caller's access level. |
| GET | /api/runs | read | Run history, newest first. Parameters: pond, lineage (include upstream Ponds), ripples (include Ripple Runs), limit (up to 1000). |
| GET | /api/view | read | The Pond graph, including Ponds in upstream Catchments reached through ducts. |
| GET | /api/lineage | read | Observed table lineage. Parameters: pond, major, table, columns. |
| GET | /api/ponds/{name}/trace | read | The run that produced some rows. Parameters: table, where. |
| GET | /api/ponds/{name}/freshness | read, Tap | How fresh the Pond's data is: freshness (the point in time it reflects), changed (when its output last changed), refreshing, and when each table and Object last changed. Read-level keys see exposed tables only; a Tap's key, its own Pond's, without Objects. |
| GET | /api/ponds/{name}/reports | read | The Pond's Run reports from pond.report(): its own, newest Run first (limit, default 50); with f, that Run's own report and the upstream reports it read. |
Refreshes and windows
| Method | Path | Level | Description |
|---|
| POST | /api/ponds/{name}/refresh | demand | Refresh now. Parameters (at most one): at, an ISO freshness to ask for instead of now; fresh_within_ms, to ask for data no older than this. Refused (422) when it reaches a Puddle. (Before Refresh, this route marked a Pond for a rebuild; that is now /rebuild.) |
| GET | /api/ponds/{name}/refreshes | read | List the recurring Refreshes, with when each next asks. |
| POST | /api/ponds/{name}/refreshes | demand | Add a recurring Refresh. Body: every_seconds (0 is continuous), continuous, start, days, until, name. |
| POST | /api/ponds/{name}/refreshes/{refresh_name}/remove | demand | Remove a recurring Refresh. |
| GET | /api/puddles | read | The Puddles on this Catchment. |
| POST | /api/puddles | full | Deploy Puddles. Multipart: bundle (a Pond project, zipped) and spec (JSON: sources, set, live, as_at, origin with name, url and headers, and force). A Puddle already there is a 409 listing them in detail.replace, unless force. |
| POST | /api/ponds/{name}/puddles/hydrate | full | Build the Puddles the Pond reaches again and run from the new baseline. Body: as_at, and origin to read another Catchment. |
| POST | /api/ponds/{name}/puddles/rewind | full | Go back to the Puddle baseline and run from it. |
| POST | /api/ponds/{name}/puddles/refresh | demand | Move the Puddles to a target and refresh at it. Body: target (next-change, next-run or most-recent) or to. |
| GET | /api/ponds/{name}/windows | read | List windows. |
| POST | /api/ponds/{name}/windows | full | Add a window. |
| POST | /api/ponds/{name}/windows/{window_name}/remove | full | Remove a window. |
Control
| Method | Path | Level | Description |
|---|
| POST | /api/ponds/{name}/wake | full | Wake. |
| POST | /api/ponds/{name}/force | full | Force. |
| POST | /api/ponds/{name}/rebuild | full | Mark for a rebuild on the next run. Parameter: clear. |
| POST | /api/repair | full | Repair a connected set of Ponds. |
| POST | /api/ponds/{name}/sleep | full | Sleep. |
| POST | /api/ponds/{name}/kill | full | Kill. |
| POST | /api/ponds/{name}/clear | full | Clear a failure. |
| POST | /api/ponds/{name}/reset | full | Reset to the freshly deployed state. |
| POST | /api/ponds/{name}/reset-contract | full | Forget the recorded output schema. |
| POST | /api/ponds/{name}/wipe-history | full | Delete run history. |
| POST | /api/ponds/batch | full | Apply operations to many Ponds, as the web UI's Pond Actions do. |
| GET | /api/ponds/{name}/budget | read | Retry budgets. |
| POST | /api/ponds/{name}/budget | full | Set retry budgets. |
| GET | /api/ponds/{name}/duck | read | Effective compute settings. |
| POST | /api/ponds/{name}/duck | full | Set or clear the compute override. |
Data
| Method | Path | Level | Description |
|---|
| POST | /api/query | read, Tap | Run SQL against one Pond's tables. Body: pond, sql, optional major, version, format (json, csv or parquet), at and since (ISO 8601 times, as duckstring query --at; not with a Tap's key). With a Tap's key, pond can be left out. A warning about the read comes back in an X-Duckstring-Warning header. |
| GET | /api/ponds/{name}/changes | read | The times a Pond line's published tables changed, oldest first, as far back as it keeps. Query: optional major, version, after, upto (ISO 8601). |
| POST | /api/query/page, /api/query/count, /api/query/history | read | Paged reads used by the web UI's data viewer. A page or count may carry a query_id. |
| POST | /api/query/cancel | read | Stop the data viewer's query query_id: interrupt it where it runs, and refuse it if it hasn't started yet. |
| GET | /api/ponds/{name}/tables/{table}/runs | read | The run freshnesses of a Trickle table, used by the data viewer's window selector. |
| GET | /api/ponds/{name}/tables | read | List published tables. |
| GET | /api/ponds/{name}/ripples/{table} | read | Download a table's published files as a zip. |
| DELETE | /api/ponds/{name}/tables/{table} | full | Delete a table. |
| GET | /api/ponds/{name}/objects | read | List Objects. |
| GET | /api/ponds/{name}/objects/{obj} | read | Download an Object. |
| DELETE | /api/ponds/{name}/objects/{obj} | full | Delete an Object. |
Catalog
| Method | Path | Level | Description |
|---|
| GET | /api/serve | read, Tap | Served majors and exposed tables. A Tap's key sees its own Pond. |
| POST | /api/serve/query | read, Tap | Run SQL across the catalog. Read-level keys see only exposed tables; a Tap's key, only its own Pond's. |
| POST | /api/ponds/{name}/serve/promote | full | Change the served major. |
| POST | /api/ponds/{name}/serve/expose | full | Expose or hide a table. |
Spouts
| Method | Path | Level | Description |
|---|
| GET | /api/ponds/{name}/spouts | full | List Spouts. |
| POST | /api/ponds/{name}/spouts | full | Add a Spout. |
| POST | /api/ponds/{name}/spouts/test | full | Test a destination without writing data. |
| POST | /api/ponds/{name}/spouts/{spout}/remove | full | Remove a Spout. |
| POST | /api/ponds/{name}/spouts/{spout}/{action} | full | wake, force, sleep, kill, clear or resync. |
Taps
| Method | Path | Level | Description |
|---|
| GET | /api/ponds/{name}/taps | full | List Taps, with their counts. Never keys. |
| POST | /api/ponds/{name}/taps | full | Add a Tap. Body: name, optional fresh_within_ms. The response holds the key, once. |
| POST | /api/ponds/{name}/taps/{tap}/rotate | full | A new key for a Tap, returned once. |
| POST | /api/ponds/{name}/taps/{tap}/remove | full | Remove a Tap. |
Apps
| Method | Path | Level | Description |
|---|
| GET | /api/ponds/{name}/app/instances | read | An App's recent instances, newest first. limit (default 20). |
| GET | /api/ponds/{name}/app/logs | full | An instance's output as text. instance (default the newest), tail (bytes from the end, default 65536) or offset (bytes from there on). The x-log-offset header is where the next read starts. |
| POST | /api/ponds/{name}/app/restart | full | Stop an App's instances and start a fresh one, clearing a failure or a Kill first. Returns once the restart has begun. |
| GET | /api/ponds/{name}/app/scale | read | Scaling settings and where each comes from, running instances, and recent decisions. |
| POST | /api/ponds/{name}/app/scale | full | Override settings or set the count, as app scale. Body: any of min_instances, max_instances, concurrency, connections, requests, cpu, memory, load, to, hold_s, release, clear. |
| POST | /api/ponds/{name}/app/instances/{instance}/drain | full | Send no new sessions to an instance; it stops once its work is done. |
| POST | /api/ponds/{name}/app/migrate | full | Migrate a trial major again from the live one. major names the trial. |
| GET | /api/app-data | read | Every App line holding Records or Media: its state, Records tables, and Media file count and size. |
| GET | /api/app-data/{name}/{major}/media | read | A line's Media files. prefix narrows to a folder. |
| GET | /api/app-data/{name}/{major}/media/file | read | Download a file. path names it. |
| POST | /api/app-data/{name}/{major}/media/file | full | Upload a file to path, as the request body or a multipart file, replacing one there. Refused on a retired line. |
| DELETE | /api/app-data/{name}/{major}/media/file | full | Delete the file at path. Refused on a retired line. |
| POST | /api/app-data/{name}/{major}/purge | full | Delete a line's Records and Media for good. Body: confirm (the Catchment's name). |
Requests to an App itself go to /apps/{name}/v{major}/... on the Catchment's port, outside /api; see [app]. A Tap added to an App has no key ("key": null): requests to the App run it.
Secrets and alerts
| Method | Path | Level | Description |
|---|
| GET | /api/secrets | full | Secret names and when each was set. Never values. |
| POST | /api/secrets | full | Set a secret. Body: name, value. |
| DELETE | /api/secrets/{name} | full | Delete a secret. |
| GET | /api/alerts | full | List channels. |
| POST | /api/alerts | full | Add a channel. |
| DELETE | /api/alerts/{name} | full | Remove a channel. |
| POST | /api/alerts/{name}/test | full | Send a test message. |
| GET | /api/alerts/deliveries | full | Recent deliveries. |
Ducts
| Method | Path | Level | Description |
|---|
| GET | /api/duct | full | List ducts. |
| POST | /api/duct | full | Create a duct. |
| DELETE | /api/duct/{origin} | full | Destroy a duct. |
| POST | /api/duct/{origin}/ponds | full | Draw a Pond. |
| DELETE | /api/duct/{origin}/ponds/{pond} | full | Stop drawing a Pond. |
| POST | /api/duct/{origin}/sync | full | Draw every exposed Pond. |
| POST | /api/ponds/{name}/open | full | Open a Pond to demand from other Catchments. |
| POST | /api/ponds/{name}/close | full | Close it. |
The /api/draw/* routes that ducts use to transfer data, and the /api/duck/* and /api/pool/* routes that Ducks use to talk to the Catchment, are internal and not covered here.
Metrics
GET /metrics serves Prometheus metrics without authentication, following exporter convention. Restrict network access to it if Pond names are sensitive.
| Metric | Type | Description |
|---|
duckstring_up | gauge | 1 while the Catchment is serving. |
duckstring_pond_freshness_lag_seconds | gauge | Seconds since each Pond's freshness. |
duckstring_pond_failed, duckstring_pond_blocked, duckstring_pond_killed | gauge | 1 when the Pond is in that state. |
duckstring_pond_runs_completed_total | counter | Completed Pond Runs. |
duckstring_pond_failures_total | counter | Failed Pond Runs. |
duckstring_pond_run_seconds_total | counter | Total Duck execution time, summed over Ripple Runs. |
duckstring_pond_duck_target | gauge | 1 for the compute target each Pond runs on. |
duckstring_pond_flock | gauge | 1 for each Pond's effective Flock mode and engine. |
duckstring_spout_delivery_lag_seconds | gauge | Seconds since each Spout last delivered. |
duckstring_spout_failed | gauge | 1 when the Spout's latest delivery failed. |
duckstring_alert_deliveries_total | counter | Alert deliveries, by status. |
duckstring_flock_dispatched_total | counter | Computations sent to the Flock, per Pond. |
duckstring_flock_dispatch_failures_total | counter | Flock dispatches that failed and ran in the Duck instead. The only sign that a Flock is misconfigured. |
duckstring_app_instances | gauge | Running instances of each App, labelled place (catchment or elsewhere). |
duckstring_app_active | gauge | Active requests and WebSockets across an App's instances. |
duckstring_app_cpu_share, duckstring_app_memory_share | gauge | Mean CPU and memory of an App's instances, as shares of their cores and limit. |
duckstring_app_reported_load | gauge | Mean load an App's instances report themselves. |
duckstring_app_at_maximum | gauge | 1 while an App is held at its maximum instances under pressure. |
duckstring_app_instance_starts_total | counter | App instances started, by place. |
duckstring_app_instance_stops_total | counter | App instances stopped, by reason. |
duckstring_tap_queries_total | counter | Queries through each Tap, labelled pond, major and tap. |
duckstring_tap_refreshes_total | counter | Refreshes sent by each Tap's queries. |
Other interfaces
The catalog can also be queried over the Postgres wire protocol and Arrow Flight, each enabled by setting a port (DUCKSTRING_SERVE_PG_PORT, DUCKSTRING_SERVE_FLIGHT_PORT; see Environment Variables). Both use an API key as the password and apply the same access levels. A Tap's key works on both, except that a Catchment without keys never asks a Postgres client for a password, so there a connection can't be recognised as a Tap's.