Reference
HTTP API
Everything the SDKs do is plain HTTP and JSON. Call the API from any language with an environment API key.
Base URL#
| Control plane | URL |
|---|---|
| Hosted alpha | https://api.bokjoy.dev |
| On your computer | http://127.0.0.1:19847 |
The API reference on these pages is generated from the control plane's OpenAPI 3.1 document. Every control plane also serves it without a token at GET /v1/openapi.json, less the routes only the operator token can call. Its tests check every route, method, credential and answer against the running server.
Authentication#
Send a bearer token in the Authorization header:
curl "$BOKJOY_API_URL/v1/tasks" -H "Authorization: Bearer $BOKJOY_API_KEY"| Credential | Looks like | Opens |
|---|---|---|
| Environment API key | bjk_prod_... | GET /v1/tasks, and the /v1/runs, /v1/schedules and /v1/queues routes, in its own environment only. |
| Operator token | Set when the control plane starts | Every route except the worker routes, in every environment. |
| Worker token | Returned once by POST /v1/workers | Only the /v1/agent routes a worker uses. |
| Public access token | bjp_..., from POST /v1/public-tokens | GET /v1/runs/{id} and GET /v1/runs/{id}/stream for the runs it names and their descendants, until it expires. Safe to give a browser. See Realtime in the browser. |
/health, /ready and /v1/openapi.json need no token. A run, schedule, queue or environment outside an API key's own answers 404, exactly like one that does not exist. A route the credential may not use answers 403.
Requests and answers#
- Bodies are JSON, sent with
Content-Type: application/json. A body is at most 4 MiB forPOST /v1/runs, 16 MiB forPOST /v1/runs/batchand 1 MiB for any other route. - A run's payload is at most 3 MiB of JSON and its output at most 10 MiB. Reading one run returns both whole. A run list carries no payload or output. Its
input_reforoutput_refnames one stored out of line, over 512 KiB: read the run to get it. - Run IDs are UUIDs. Times are RFC 3339 strings in UTC.
- An error is a JSON object with one field,
{"error": "..."}, that says why. Malformed JSON, a bad UUID or a bad query value answers with plain text instead.
| Status | Meaning |
|---|---|
200, 202 | Done, or accepted. A new run answers 202. |
400 | Invalid request, including a run larger than its environment allows (the reason says asks for more CPU or memory than). |
401 | No token, or a wrong or revoked one. |
403 | The credential may not use this route. |
404 | No such resource, or one outside an API key's environment. |
409 | A conflict: an idempotency key reused with a different request, an event ID reused with a different event, an event for a finished run, or an archived environment. |
413 | The body is over its route's limit. |
The SDKs never follow a redirect, since it would carry the key elsewhere. Call the control plane at the address it serves on.
Retrying safely#
POST /v1/runs and POST /v1/runs/batch require an idempotency key, so retrying either is always safe: the same request returns the runs it already started. POST /v1/runs/{id}/events deduplicates by event_id. See Idempotency.
Reference#
- Runs: start, list, read, cancel and follow runs, and send them events. API keys can use all of these.
- Schedules API: create, list, read, change, pause and delete recurring schedules. API keys can use all of these.
- Queues API: list queues and read one, with its limit and how many of its runs are running and waiting. API keys can use both.
- Tasks and status: the environment's tasks, health checks and this document.
- Operator routes: environments, variables, API keys and workers. Operator token only.
The worker protocol under /v1/agent is in the OpenAPI document too. It is internal and can change between releases.