Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HTTP API

SheetBot exposes an HTTP API for tasks, agents, sheets, artefacts, scripts, and events. The full machine-readable specification is served at:

GET /openapi.yaml

It is also in the repository as openapi.yaml. This page is a practical map of the endpoints; use the OpenAPI file for exact schemas.

Base URL and authentication

Use the same URL you open in the browser, for example http://localhost:3000 or https://sheetbot.example.com.

Authenticate with a JWT:

TOKEN=$(curl -sS -X POST "$SHEETBOT_BASEURL/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"your_username","password":"your_password"}' \
  | jq -r .token)

Or exchange an API key:

TOKEN=$(curl -sS -X POST "$SHEETBOT_BASEURL/login" \
  -H "Content-Type: application/json" \
  -d "{\"apiKey\":\"$SHEETBOT_AUTH_APIKEY\"}" \
  | jq -r .token)

Send Authorization: Bearer $TOKEN on authenticated requests. Most endpoints enforce a permission; see Configure permissions.

Common status codes

CodeMeaning
200Success with a JSON or text body.
204Success with no body (updates and deletes).
400Invalid input, missing task, or malformed JSON.
401Missing or invalid credentials.
403Authenticated but missing a permission.
404Resource not found.
409Conflict, such as a duplicate key.
500Server error. Check the server log.

Authentication and metadata

MethodPathPurpose
POST/loginExchange username/password or API key for a JWT.
GET/Web UI.
GET/openapi.yamlOpenAPI specification.
GET/widgets.jsonDiscovered widget module URLs.

Tasks

MethodPathPermissionPurpose
GET/tasksviewTasksList tasks.
POST/taskscreateTasksCreate a task.
GET/tasks/{id}viewTasksGet a task.
PATCH/tasks/{id}updateTasksUpdate status or fields.
DELETE/tasks/{id}deleteTasksDelete a task.
POST/tasks/getperformTasksPoll for a matching task (agents).
POST/tasks/{id}/acceptperformTasksMark the task RUNNING.
POST/tasks/{id}/completeperformTasksComplete with { "data": ... }.
POST/tasks/{id}/failedperformTasksMark the task FAILED.
POST/tasks/{id}/dataperformTasksMerge data into the task.
POST/tasks/{id}/clonecreateTasksClone a task and its artefacts.
POST/tasks/{id}/artefactsperformTasksUpload a file (multipart/form-data, field file).
GET/tasks/{id}/artefacts/{filename}noneRedirect to an artefact; the direct URL needs viewArtefacts.
DELETE/tasks/{id}/artefacts/{filename}deleteTasksDelete an artefact.

Create a task:

curl -X POST "$SHEETBOT_BASEURL/tasks" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "hello",
    "script": "console.log(\"hello\")",
    "type": "node",
    "data": {},
    "transitions": []
  }'

Poll as an agent:

curl -X POST "$SHEETBOT_BASEURL/tasks/get" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type":"node","capabilities":{"os":"linux","arch":"x86_64"}}'

Status values: 0 awaiting, 1 running, 2 completed, 3 failed, 4 paused, 5 deleted.

Scripts and library

MethodPathPurpose
GET/libraryLibrary metadata: name, data, capabilities, comments, transitions.
GET/scripts/agent.tsDeno agent template.
GET/scripts/agent.jsNode.js agent template.
GET/scripts/agent.pyPython agent template.
GET/scripts/agent.shBash agent template.
GET/scripts/{id}.{ext}Task script with dependency injection.
GET/scripts/{uuid}Task script.

The agent template endpoints replace ${req.protocol} and ${req.get('host')} with the request origin, so a downloaded agent points back at the server that served it.

Sheets

MethodPathPermissionPurpose
GET/sheetsoptional loginAnonymous callers see public sheets; logged-in callers see all.
GET/sheets/{id}public or loginRead columns and rows.
POST/sheets/{id}/dataputSheetDataUpsert a row by key.
DELETE/sheets/{id}/data/{key}putSheetDataDelete a row.
GET/sheets/{id}/publicmanageSheetPermissionsRead the public grant.
PUT/sheets/{id}/publicmanageSheetPermissionsSet { "public": true/false }.

Upsert a row:

curl -X POST "$SHEETBOT_BASEURL/sheets/build-status/data" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"key":"linux-x64","name":"Linux x64","status":2,"progress":100}'

The sheet is created on the first write. See Sheet database and Working with sheets.

Artefacts and buckets

MethodPathPermissionPurpose
POST/artefacts-credentialsloginIssue temporary AWS-compatible credentials.
POST/artefacts/{bucket}/{prefix}createArtefactsStart a multipart upload.
PUT/artefacts/{bucket}/{prefix}createArtefactsUpload raw bytes.
GET/artefacts/{bucket}viewArtefactsList a bucket.
GET/artefacts/{bucket}/{prefix}viewArtefactsList a prefix or read a file.
DELETE/artefacts/{path}deleteArtefactsDelete bucket files.
GET/artefacts/publicnoneList the public bucket.
GET/artefacts/public/{path}noneRead a public file.

Upload a bucket file with JWT:

curl -X PUT "$SHEETBOT_BASEURL/artefacts/reports/report.txt" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: text/plain" \
  --data-binary @report.txt

See Working with artefacts and Artefacts.

Events and metrics

MethodPathPermissionPurpose
GET/eventsloginServer-Sent Events for task and agent changes.
GET/tasktrackerloginTask execution statistics (?minutes=60).
GET/agenttrackerloginAgent activity statistics.
GET/transitiontrackerloginTransition evaluation statistics.

Subscribe to events:

curl -N -H "Authorization: Bearer $TOKEN" "$SHEETBOT_BASEURL/events"

Errors

Errors are usually plain text or JSON with an error field. A 403 means the JWT is valid but lacks the required permission; a 401 means the JWT is missing, expired, or invalid. Agent templates translate these into Unauthenticated and Unauthorized.

Next