ReferenceBeta

API reference

Every endpoint, parameter and header in one place.

Basics

Base URLhttps://api.staging.boxline.dev
Authenticationx-api-key: <key> or Authorization: Bearer <key> on every request
Request bodiesJSON with content-type: application/json, except file writes, which send the raw bytes
ErrorsMatching HTTP status and {"error": {"code": "not_found", "message": "…"}}
Shell
curl https://api.staging.boxline.dev/v1/usage \
  -H "x-api-key: $BOXLINE_API_KEY"

Error codes you will meet often: concurrency_limit (429, too many running sessions for your plan), plan_limit (403, e.g. a timeout above your plan’s maximum), session_not_running (409) and not_found (404).

With a proxy you may also see plan_limit (402, your plan does not include the platform’s proxies), spend_limit (402, this month’s proxy data is used up) and proxy_unavailable (503). See Proxies.

captcha_timeout: a plain-English step waited 4 minutes for someone to solve a CAPTCHA. It comes in the action result (ok: false, code: "captcha_timeout"), and the SDKs raise it with status 409. The SDKs’ waitForHuman / wait_for_human raise the same code (408) when their own timeout runs out. See CAPTCHAs.

WebSockets and live view

Session fieldWhat it is
connectUrlChrome DevTools Protocol WebSocket (/v1/connect?sessionId=…&token=…) for Playwright or Puppeteer.
liveUrlLive view HTML page (/live/:id?token=…). Open it to watch the browser or take control, for example to solve a CAPTCHA. Anyone with it can control the browser: treat it like a password. Only Boxline’s own apps can frame it; embedding it on your site needs per-project embed origins, not available yet.
terminalUrlTerminal WebSocket (/v1/sessions/:id/terminal?token=…). Send JSON text frames {"type":"input","data":"…"} or {"type":"resize","cols":N,"rows":N}; receive raw terminal output as binary frames.

All endpoints

EndpointDescription
POST/v1/sessionsCreate a session.
GET/v1/sessionsList sessions.
GET/v1/sessions/:idGet a session. Besides its settings, it has attention: { type: "captcha", kind, url, tabId, since } while a CAPTCHA waits for a person, otherwise null.
GET/v1/sessions/:id/eventsThe session's log, oldest first: console, network, navigation, error, lifecycle, action, exec and captcha events. GET /v1/sessions/:id/events/stream sends them live.
PATCH/v1/sessions/:idChange a running or paused session.
POST/v1/sessions/:id/proxy/rotateGive the session's proxy a new IP; a sticky session keeps one IP until you call this. 400 without a proxy.
POST/v1/sessions/:id/releaseEnd a session (also DELETE /v1/sessions/:id). Billing stops.
POST/v1/sessions/:id/pauseSave browser state and files, free the machine and stop billing.
POST/v1/sessions/:id/resumeResume a paused session. Connecting or calling actions, exec or files also resumes it.
POST/v1/sessions/:id/moveMove a running session to a fresh machine. Clients reconnect to the same connectUrl.
GET/v1/sessions/:id/liveGet fresh signed live view and terminal URLs.
POST/v1/sessions/:id/actionsRun one action or a list of actions next to the browser.
POST/v1/sessions/:id/browser/cookies/exportWrite the browser's cookies as a Netscape cookie file (for curl -b / wget) in the workspace.
POST/v1/sessions/:id/execRun a command in the session's persistent shell.
POST/v1/sessions/:id/shell/restartRestart a persistent shell.
GET/v1/sessions/:id/filesRead a file, or list a directory with list=1.
PUT/v1/sessions/:id/filesWrite a file. The request body is the raw bytes.
DELETE/v1/sessions/:id/filesDelete a file.
GET/v1/sessions/:id/files/waitWait for a finished file matching a glob. 408 if none appears in time.
POST/v1/contextsCreate a context for saved browser state (cookies and localStorage).
GET/v1/contexts/:idGet a context, including inUseBy (the running session using it, or null).
DELETE/v1/contexts/:idDelete a context. 409 while a running session uses it.
POST/v1/fetchOpen a URL in a real browser and return its content. captcha is the kind of CAPTCHA waiting for a person on the page (e.g. "recaptcha"), or null.
POST/v1/screenshotScreenshot of a URL in a fresh browser context. Headers x-final-url, x-page-status, x-page-title (URI-encoded), x-page-captcha (the kind of CAPTCHA waiting for a person, or empty) and x-render-ms describe the page.
POST/v1/pdfPDF of a URL, printed like Chrome's Save as PDF. Same headers as screenshot.
POST/v1/extractStructured data from pages: they load in a real browser, then a model follows prompt and/or fills schema.
POST/v1/crawlStart a crawl from a URL in the background (breadth-first, robots.txt respected). Poll GET /v1/crawl/:id for the pages (each has captcha: a CAPTCHA kind, or null); POST /v1/crawl/:id/cancel stops it.
POST/v1/agent/runsStart a Claude-powered agent run.
GET/v1/agent/runs/:idGet a run. status is "running", "paused", "completed", "failed" or "canceled". While paused, handover is { by: "user" | "agent" | "captcha", reason }; "captcha" runs continue by themselves once a person has solved it, and fail after 5 minutes.
GET/v1/agent/runs/:id/eventsServer-sent events, one per step.
GET/v1/usageYour account's usage.
GET/v1/pricingThe public price table, including proxies: { residentialPerGb, datacenterPerGb, customPerGb }.

Sessions

POST/v1/sessions

Create a session. Returns 201 Session. Guide: Sessions.

NameTypeDescription
browserbooleanStart Chrome. Default true.
shellbooleanAdd a bash shell (Python, Node, ffmpeg and sudo included). Default false.
timeoutnumberLifetime in seconds. Default 300, minimum 60, maximum set by your plan.
keepAlivebooleanKeep a browser-only session running after its last CDP client disconnects. Default false.
viewportobject{ width, height }, 200×200 to 3840×2160.
userMetadataobjectAny JSON; returned on the session.
contextobject{ id, persist? }: load a context; with persist, save back on end.
proxytrue | object | arraySend the session's traffic through a proxy: true (a residential proxy in the US), { type: "residential" | "datacenter", country?, state?, city?, ip?, scope? }, { type: "custom", server, username?, password?, ip?, scope? }, or a list of up to 10 rules by site (each a proxy or { type: "none" }, with an optional domainPattern; the first match wins). ip defaults to "sticky", scope to "browser".
captchastringWhat agent runs and plain-English steps do when a CAPTCHA waits for a person: "ask" (default) waits until someone solves it in the live view (agent runs up to 5 minutes, steps up to 4); "ignore" carries on. The platform never solves CAPTCHAs.

GET/v1/sessions

List sessions. Returns { data: [Session] }. Guide: Sessions.

NameTypeDescription
statusstringRUNNING, PAUSED, COMPLETED or ERROR.
limitnumberMaximum number of sessions to return.

GET/v1/sessions/:id

Get a session. Besides its settings, it has attention: { type: "captcha", kind, url, tabId, since } while a CAPTCHA waits for a person, otherwise null. Returns Session. Guide: Sessions.

GET/v1/sessions/:id/events

The session's log, oldest first: console, network, navigation, error, lifecycle, action, exec and captcha events. GET /v1/sessions/:id/events/stream sends them live. Returns { data: [Event], nextAfter }. Guide: Logs & replay.

NameTypeDescription
typesstringComma-separated event types, e.g. captcha or console,error.
afternumberOnly events after this seq; pass back nextAfter to page forward.
limitnumberMaximum number of events. Default 500, at most 2000.

PATCH/v1/sessions/:id

Change a running or paused session. Returns Session. Guide: Session control.

NameTypeDescription
keepAlivebooleanKeep a browser-only session running after its last CDP client disconnects.
userMetadataobjectReplaces the session's metadata.
proxytrue | object | array | nullA new proxy or list of rules (same shape as on create), or null to remove it. New connections use it at once. Left out: unchanged.
captchastring"ask" or "ignore" (see create). Left out: unchanged.

POST/v1/sessions/:id/proxy/rotate

Give the session's proxy a new IP; a sticky session keeps one IP until you call this. 400 without a proxy. Returns Session. Guide: Proxies.

POST/v1/sessions/:id/release

End a session (also DELETE /v1/sessions/:id). Billing stops. Returns Session (COMPLETED). Guide: Sessions.

POST/v1/sessions/:id/pause

Save browser state and files, free the machine and stop billing. Returns Session (PAUSED). Guide: Move, pause & resume.

POST/v1/sessions/:id/resume

Resume a paused session. Connecting or calling actions, exec or files also resumes it. Returns Session (RUNNING). Guide: Move, pause & resume.

POST/v1/sessions/:id/move

Move a running session to a fresh machine. Clients reconnect to the same connectUrl. Returns { session, timings: { captureMs, acquireMs, restoreMs, totalMs } }. Guide: Move, pause & resume.

GET/v1/sessions/:id/live

Get fresh signed live view and terminal URLs. Returns { liveUrl, terminalUrl }. Guide: Browser.

Browser

POST/v1/sessions/:id/actions

Run one action or a list of actions next to the browser. Returns { results: [{ ok, action, value?, error?, code?, ms }] }. Guide: Browser.

NameTypeDescription
actionsarraygoto, click, fill, type, press, scroll, wait, screenshot, content, evaluate, upload, tabs, newTab, switchTab, closeTab, back, forward, reload, step (plain English; waits up to 4 minutes while a CAPTCHA waits for a person, with the session's captcha option "ask"). Or send a single action object as the body.

POST/v1/sessions/:id/browser/cookies/export

Write the browser's cookies as a Netscape cookie file (for curl -b / wget) in the workspace. Returns { path, count }. Guide: Shell.

NameTypeDescription
pathstringWhere to write it. Default cookies.txt.

Shell

POST/v1/sessions/:id/exec

Run a command in the session's persistent shell. Returns { stdout, stderr, exitCode, timedOut, truncated, durationMs }, or an NDJSON stream. Guide: Shell.

NameTypeDescription
commandstringThe bash command to run.
timeoutMsnumberDefault 120,000, maximum 3,600,000.
cwdstringWorking directory inside the workspace.
envobjectExtra environment variables.
shellstring | false"default", another name for a separate persistent shell, or false for a fresh process.
streambooleanStream {type:"stdout"|"stderr", data} lines, then {type:"exit", …}.

POST/v1/sessions/:id/shell/restart

Restart a persistent shell. Returns 204. Guide: Shell.

NameTypeDescription
shellstringWhich shell. Default "default".

Files

GET/v1/sessions/:id/files

Read a file, or list a directory with list=1. Returns File bytes, or { path, entries: [{ name, type, size, mtime }] }. Guide: Files.

NameTypeDescription
pathstringRelative to /workspace, or absolute inside it.
list1List the directory instead of reading a file.

PUT/v1/sessions/:id/files

Write a file. The request body is the raw bytes. Returns { path, size }. Guide: Files.

NameTypeDescription
pathstringWhere to write the file.

DELETE/v1/sessions/:id/files

Delete a file. Returns 204. Guide: Files.

NameTypeDescription
pathstringThe file to delete.

GET/v1/sessions/:id/files/wait

Wait for a finished file matching a glob. 408 if none appears in time. Returns { path, size }. Guide: Files.

NameTypeDescription
patternstringGlob in the last segment, e.g. downloads/*.csv.
timeoutMsnumberHow long to wait.

Contexts

POST/v1/contexts

Create a context for saved browser state (cookies and localStorage). Returns { id, sizeBytes, createdAt, updatedAt }. Guide: Contexts.

GET/v1/contexts/:id

Get a context, including inUseBy (the running session using it, or null). Returns { id, sizeBytes, createdAt, updatedAt, inUseBy }. Guide: Contexts.

DELETE/v1/contexts/:id

Delete a context. 409 while a running session uses it. Returns 204. Guide: Contexts.

Fetch, screenshot, PDF, extract and crawl

POST/v1/fetch

Open a URL in a real browser and return its content. captcha is the kind of CAPTCHA waiting for a person on the page (e.g. "recaptcha"), or null. Returns { url, finalUrl, status, title, content, captcha, ms }. Guide: Fetch API.

NameTypeDescription
urlstringThe page to fetch.
formatstring"markdown", "html" or "text".
timeoutMsnumberHow long to wait for the page.
waitUntilstring"load", "domcontentloaded" or "networkidle".
proxytrue | object | arrayLoad the page through a proxy (same shape as on sessions). ip defaults to "rotating".

POST/v1/screenshot

Screenshot of a URL in a fresh browser context. Headers x-final-url, x-page-status, x-page-title (URI-encoded), x-page-captcha (the kind of CAPTCHA waiting for a person, or empty) and x-render-ms describe the page. Returns PNG or JPEG bytes. Guide: Proxies.

NameTypeDescription
urlstringThe page. Required.
fullPagebooleanThe whole page instead of the viewport.
formatstring"png" or "jpeg".
qualitynumberJPEG quality, 1 to 100.
selectorstringCapture only the first element that matches.
viewportobject{ width, height }.
waitUntilstringWhen the page counts as loaded: "load", "domcontentloaded" or "networkidle".
delayMsnumberExtra wait after the page loads, up to 10,000.
timeoutMsnumberHow long to wait for the page.
proxytrue | object | arrayLoad the page through a proxy (same shape as on sessions). ip defaults to "rotating".

POST/v1/pdf

PDF of a URL, printed like Chrome's Save as PDF. Same headers as screenshot. Returns PDF bytes. Guide: Proxies.

NameTypeDescription
urlstringThe page. Required.
paperstring"A4", "A3", "A5", "Letter", "Legal" or "Tabloid".
landscapebooleanLandscape instead of portrait.
printBackgroundbooleanPrint background colours and images. Default true.
scalenumberZoom of the printed page.
waitUntilstringWhen the page counts as loaded: "load", "domcontentloaded" or "networkidle".
delayMsnumberExtra wait after the page loads, up to 10,000.
timeoutMsnumberHow long to wait for the page.
proxytrue | object | arrayLoad the page through a proxy (same shape as on sessions). ip defaults to "rotating".

POST/v1/extract

Structured data from pages: they load in a real browser, then a model follows prompt and/or fills schema. Returns { data, pages: [{ url, finalUrl, status, title }], provider, model, usage, ms }. Guide: Proxies.

NameTypeDescription
url or urlsstring or string[]One page, or up to 10.
promptstringWhat to extract. prompt or schema is required.
schemaobjectJSON Schema the result must match.
provider, modelstringWhich model to use; a fast, low-cost one by default.
waitUntilstringWhen the page counts as loaded: "load", "domcontentloaded" or "networkidle".
delayMsnumberExtra wait after the page loads, up to 10,000.
timeoutMsnumberHow long to wait for the page.
proxytrue | object | arrayLoad the pages through a proxy (same shape as on sessions). ip defaults to "rotating".

POST/v1/crawl

Start a crawl from a URL in the background (breadth-first, robots.txt respected). Poll GET /v1/crawl/:id for the pages (each has captcha: a CAPTCHA kind, or null); POST /v1/crawl/:id/cancel stops it. Returns 201 crawl job. Guide: Proxies.

NameTypeDescription
urlstringWhere to start. Required.
maxPagesnumberDefault 20, maximum 200.
maxDepthnumberDefault 3, maximum 10.
sameHostbooleanStay on the start URL's host. Default true.
include, excludestring[]Regular expressions for URLs to follow or skip.
formatstring"markdown", "text" or "html".
waitUntilstringWhen the page counts as loaded: "load", "domcontentloaded" or "networkidle".
delayMsnumberExtra wait after the page loads, up to 10,000.
timeoutMsnumberHow long to wait for the page.
proxytrue | object | arrayCrawl through a proxy (same shape as on sessions). ip defaults to "sticky": one IP for the whole crawl.

Agent

POST/v1/agent/runs

Start a Claude-powered agent run. Returns 201 { id, status, sessionId }. Guide: Agent API.

NameTypeDescription
taskstringWhat the agent should do. Required.
sessionIdstringUse an existing session.
browserbooleanNew session gets a browser. Default true.
shellbooleanNew session gets a shell. Default false.
maxStepsnumberDefault 30, maximum 100.
effortstring"low", "medium", "high", "xhigh" or "max".
keepSessionbooleanKeep the session the run created. Default false.
proxytrue | object | arrayA proxy for the session the run creates (same shape as on sessions). Ignored with sessionId: that session's proxy applies.

GET/v1/agent/runs/:id

Get a run. status is "running", "paused", "completed", "failed" or "canceled". While paused, handover is { by: "user" | "agent" | "captcha", reason }; "captcha" runs continue by themselves once a person has solved it, and fail after 5 minutes. Returns { id, status, task, sessionId, provider, model, steps, result, error, usage, handover }. Guide: Agent API.

GET/v1/agent/runs/:id/events

Server-sent events, one per step. Returns text/event-stream. Guide: Agent API.

Usage

GET/v1/usage

Your account's usage. Returns { sessions, browserSeconds, sandboxVcpuSeconds, sandboxGibSeconds, proxy: { residentialGb, datacenterGb, customGb, costUsd }, costUsd, byDay: [{ date, seconds, costUsd }] }. costUsd includes proxy data. Guide: Pricing.

GET/v1/pricing

The public price table, including proxies: { residentialPerGb, datacenterPerGb, customPerGb }. Returns Price table. Guide: Pricing.

These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.