REST API overview

The API exposes one resource, the task. Tasks take minutes, so the API is asynchronous: you create a task, then wait for it with a long-poll instead of holding a request open.

Conventions

  • JSON request and response bodies with snake_case fields. The SDK uses the same names.
  • Every endpoint is versioned under /v1.
  • Authenticate with Authorization: Bearer <api key>. Keys start with bw_.
  • Timestamps are ISO 8601 in UTC.
  • IDs are prefixed, for example task_….

Endpoints

Endpoint Purpose
POST /v1/tasks Create a task. Returns 202 with the task object and a Location header.
GET /v1/tasks/:id Get a task. ?wait=<seconds> (max 30) long-polls until the task finishes or the wait ends.
GET /v1/tasks List your tasks, newest first, with ?limit and ?cursor.
POST /v1/tasks/:id/confirm Answer the task's yes/no question.
POST /v1/tasks/:id/cancel Request cancellation. Idempotent; returns the task.
GET /health Liveness check. No auth.

A complete exchange

# Create
curl "https://browserwhale-api.browserwhale.workers.dev/v1/tasks" \
  -H "Authorization: Bearer $BROWSERWHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2a7e-first-task" \
  -d '{ "url": "https://example.com", "task": "Find the page'\''s main heading." }'

# Wait up to 30 s per request until it finishes
curl "https://browserwhale-api.browserwhale.workers.dev/v1/tasks/task_…?wait=30" \
  -H "Authorization: Bearer $BROWSERWHALE_API_KEY"

The API is at https://browserwhale-api.browserwhale.workers.dev. The SDKs call it without being told.

Reference

  • Endpoints: requests, parameters and responses.
  • Task object: every field, statuses, causes and the step log.
  • Errors and limits: the error shape, HTTP codes, rate limits, idempotency and URL rules.