Skip to Content
HeyBug docs
API

API reference

The HeyBug API is JSON over HTTP under `/api`.

The HeyBug API is JSON over HTTP under /api. Bodies and fields are camelCase, lists are never null, and ids are prefixed strings (prj_…, exp_…, run_…, art_…).

Authentication

MethodHowUse it for
Session cookieot_session, set by POST /api/auth/verify or /api/auth/dev-loginThe web app
API keyAuthorization: Bearer ot_…CLI, CI, MCP, scripts

Create a key at POST /api/tokens. The secret is shown once. The CLI reads HEYBUG_TOKEN and HEYBUG_SERVER.

curl -H "Authorization: Bearer $HEYBUG_TOKEN" $HEYBUG_SERVER/api/projects

Public routes (no session or key) are more than the kernel's seven (GET /api/healthz, GET /api/version, GET /api/auth/config, POST /api/auth/magic-link, POST /api/auth/verify, POST /api/auth/dev-login, POST /api/auth/sign-out). Modules add about forty more under /api:

  • sign-in: password, passkey login, OAuth and SSO start and callback, 2FA status and verify, device-code flow;
  • invitations: look up and accept;
  • signed links: shares, report assets, fixture downloads, the OTP inbox;
  • the changelog admin route, which checks its own guard in the handler.

Root routes (/webhooks/*, /scim/v2/*, /t/{id}/*) check their own signatures or tokens. Everything else needs a session or key.

API keys never reach passkey, 2FA-setting or account-export routes, and act only on their own workspace. A session that has passed only the first factor gets two_factor_required until POST /api/auth/2fa/verify. Sign-in answers carry twoFactorRequired and a redirect to the code screen.

Errors

Every failure is {"error":{"code","message","field?"}}.

Statuscode
401unauthorized
403forbidden
404not_found
409conflict
422invalid (field names the bad input)
429rate_limited
503unavailable (also "Email is not configured" when no mail provider is set)
500internal

Other codes you may see: two_factor_required (401), token_expired (401), insufficient_scope (403), sso_required (403), feature_gated (403), insufficient_credits (402), link_expired (403), not_implemented (501).

Account and keys

EndpointRequestResponse
GET /api/meMeResponse: user, workspace, role, llm, limits
GET /api/tokens{tokens}
POST /api/tokens{name}{token, secret}: follows the workspace token policy (cap and maximum lifetime)
DELETE /api/tokens/{tokenId}revokes the key: its owner, or an owner or admin

Projects

EndpointRequestResponse
GET /api/projects{projects}; each has lastRun, caseCount
POST /api/projects{baseUrl, name?, description?}the project
GET /api/projects/{projectId}{project, currentPlan?, latestExploration?, recentRuns, hasCredentials}
PATCH /api/projects/{projectId}{name?, baseUrl?, description?}the project
DELETE /api/projects/{projectId}archives it
GET /api/projects/{projectId}/credentials{username, hasPassword, loginUrl, notes, updatedAt?}
PUT /api/projects/{projectId}/credentials{username, password?, loginUrl, notes} (omit password to keep it)same as GET
DELETE /api/projects/{projectId}/credentialsremoves them

Explorations

EndpointRequestResponse
POST /api/projects/{projectId}/explorations{url?, instructions?}the exploration
GET /api/projects/{projectId}/explorations{explorations}
GET /api/explorations/{explorationId}{exploration, pages, steps, lastSeq}
POST /api/explorations/{explorationId}/cancelthe exploration
GET /api/explorations/{explorationId}/events?after=SSE

Plans

EndpointRequestResponse
GET /api/projects/{projectId}/planthe current plan
POST /api/projects/{projectId}/plan{baseVersion, cases, run, runCaseKeys?}{plan, run?}
GET /api/projects/{projectId}/plans{versions}: id, version, source, caseCount, useCaseCount, createdAt
GET /api/plans/{planId}the plan

A case is {key?, useCase, title, priority, goal, steps}. Leave key empty for a new case. Each apply saves a new version. run: true also starts a run.

Runs and results

EndpointRequestResponse
POST /api/projects/{projectId}/runs{planId?, caseKeys?, targetUrl?}202, the run
GET /api/projects/{projectId}/runs{runs, nextCursor?}
GET /api/runs/{runId}{run, project, cases, lastSeq}
POST /api/runs/{runId}/cancelthe run
GET /api/runs/{runId}/events?after=SSE
GET /api/case-results/{caseResultId}{result, run, steps, case?, script?}; script is Playwright code
GET /api/artifacts/{artifactId}the file bytes (screenshots, video, traces)
POST /api/quick-runs{url, projectId?, instructions?}{id, status, project, exploration?, run?, cases?, url}
GET /api/quick-runs/{quickRunId}same shape; status is exploring, running, done or failed

Events (SSE)

Both event routes stream text/event-stream. Frames look like id: <seq>, event: <type>, data: <json>. A : ping comment arrives every 15 s.

  • Resume: pass ?after=<seq>, or let the browser send Last-Event-ID (it wins). Use lastSeq from the detail response as the starting value. A negative or non-numeric value returns 422.
  • Close: the server ends the stream after the terminal status (run passed, failed, error or canceled; exploration finished or canceled).
curl -N -H "Authorization: Bearer $HEYBUG_TOKEN" "$HEYBUG_SERVER/api/runs/$RUN/events?after=0"

Chat

The project assistant (see the Chat guide). All routes are under /api, authenticated like the rest of the API; sessions are private to your user, and sending or resolving a card needs edit access to the project.

RouteWhat it does
POST /projects/{id}/chat/sessionsStart a session: {title?} → the session object.
GET /projects/{id}/chat/sessionsYour sessions in the project, newest first, each with its status.
GET /chat/sessions/{sid}One session: status, pendingCard, activeTurn, usage (session tokens, workspace daily budget).
PATCH /chat/sessions/{sid}Set the session's model: {modelProviderId: "…"|null} (paid models gated by plan) or rename it.
GET /chat/sessions/{sid}/messagesThe stored messages.
POST /chat/sessions/{sid}/messagesSend text (1..8000 chars; secrets are refused). Returns 202 {turnId} at once — the turn runs in the background and streams as events. 409 {code:"card_pending"} while a card waits.
GET /chat/sessions/{sid}/streamSSE of the session's events; resume with ?after=<seq> or Last-Event-ID.
GET /chat/sessions/{sid}/events?after=The same events as JSON, for polling clients.
POST /chat/cards/{cardId}/resolveAnswer a card: {action, input?}. Actions: confirm, decline, apply, apply_and_run, reject, answer. Exactly-once per card; a repeat with the same action replays the stored result, with a different action it is 409 {code:"already_resolved"}. Starts the continuation turn.

Chat events (kind): token, step_start, step_end, tool_call, tool_result (with an optional link — "View browser"), card, card_resolved, message, done (status of done, waiting_card, paused or failed) and error. The turn survives closing the tab: reopen the session and the stream resumes from your last seq.

MCP

POST /api/mcp is a remote MCP server (JSON-RPC 2.0, Streamable HTTP, JSON responses). Send Authorization: Bearer ot_…. GET and DELETE return 405. GET /api/mcp/tools lists the tools without auth. Setup steps are in MCP. The stdio server is heybug mcp.

On this page