Do the task on the live websites and return the result
runExecutes the task on live websites and returns the result. Call get_library FIRST, then run({ script }). From your app or a cron: POST https://api.bowmark.ai/v1/run (bowmark.ai/docs/http-api).
THE SCRIPT is a plain async JavaScript body, not a wrapping function. bowmark is a global: await bowmark.<capability>.<fn>(...), or one site via await bowmark.providers.<provider>.<fn>(...). return what you want back; log(...) for progress. Built-ins plus URL/URLSearchParams exist; fetch, import, setTimeout and a filesystem do not — bowmark is the only I/O.
MIND THE CLOCK. Your client times out around 55 seconds; calls take 30-55 seconds; default to ONE per script. Several? Use Promise.allSettled together (a dropped leg still returns partial), never one after another or in a for loop. Keep the RESULT under ~25,000 chars or it comes back as a file link.
CHECK status BEFORE ok — ok | error | partial | needs_user | running:
• running: still going. Call run({ runId }) to await the SAME run; never resend the script.
• partial: result is real but narrower than asked; incomplete names what did not answer. Tell the user — never call it complete. incomplete.failures[].fixable: true means your argument was wrong: fix it, rerun.
• needs_user: a site needs your user signed in. Give them meta.handoff.url, name the sites, then call wait_for_sign_in (meta.handoff.ref). On done, resend the SAME script.
• error: there is no result; error says why. Never fill a fact a failed lookup did not verify from memory.
Keep a day-to-day baseline with bowmark.files.save (30 days by default). Schedules, exit IP, secrets, warnings, billed fallbacks: get_library({ query: "run guide" }).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "run"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runId | No | Send EXACTLY ONE of `script` or `runId`, never both and never neither. `runId` is only to collect a run an earlier call answered `status: "running"` for: pass its `runId` alone, with no `script`, and this call waits for that same run's result. Leave it out when starting a run. | |
| egress | No | Optional. `"link"` sends every request of this run through the user's own Chrome (Bowmark Buddy) and fails with "Link not connected" when it is not open; `"link-first"` tries the user's Chrome first and falls back to Bowmark's own route (use it when the answer must come from the user's own address, e.g. a YouTube stream URL that will play in their browser); `"default"` or leaving it out uses Bowmark's own route. The result echoes what was applied as `egress` (`"default"` when a `"link-first"` run found no Chrome). | |
| script | No | Send EXACTLY ONE of `script` or `runId`, never both and never neither; `script` starts a new run. The JavaScript script body to execute (async, against the `bowmark` global). e.g. `const { flights, warnings } = await bowmark.flights.search({from:'SFO',to:'JFK',depart:'2027-03-02'}); return { best: flights.sort((a,b)=>a.price-b.price)[0], warnings };` | |
| maxSeconds | No | Optional, 100 to 900. Lets ONE run last this many seconds instead of the default 90, for long paging jobs. The call still answers within about 40 seconds with `status: "running"` and a `runId`; collect the result with `run({ runId })`. Leave it out for an ordinary run. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ms | No | ||
| ok | Yes | ||
| logs | No | ||
| meta | No | ||
| error | No | ||
| needs | No | ||
| notes | No | ||
| runId | No | ||
| egress | No | ||
| notice | No | ||
| result | No | ||
| status | No | ||
| queuedMs | No | ||
| incomplete | No | ||
| savedFiles | No | ||
| emptyHanded | No | ||
| secretNeeds | No | ||
| savedSecrets | No |