Documentation Index
Fetch the complete documentation index at: https://docs.anchorbrowser.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
A workflow is a JSON document describing an ordered graph of segments that run against a browser session. Each segment can run deterministic Playwright code, an AI agent, or both. Segment outputs flow forward by parameter name into a shared state, and the workflow’s final output is read from that state at the end. This page covers two things: the JSON schema you need to understand to edit workflows by hand, and the API flow for pushing those edits. See Automation Tasks for the basics of creating and running tasks.API process for editing a workflow
Get the underlying task ID
Use the same tool ID you already use to run the workflow.Grab
task_id from the response.Read the current workflow JSON
code field is base64-encoded. Decode it to get the raw workflow JSON.Edit and save as draft
Edit the decoded JSON using the schema reference below, re-encode it to base64, then save:
Top-level shape
| Field | Description |
|---|---|
name | Human-readable workflow name. |
startSegmentName | The name of the segment that runs first. Must match one of segments[].name. |
inputParameters | Values supplied by the caller at run time. |
outputParameters | Values returned at the end of the run, read from the shared state by name. |
segments | The segments that make up the graph. |
Parameter
| Field | Default | Notes |
|---|---|---|
name | — | The state key. Outputs flow forward by name — an output named foo becomes the input foo of any later segment that declares it. |
type | — | One of string, number, boolean, secret, file. secret is a string that is masked in logs. file carries a base64 data URI; the runtime writes it to a temp path before Playwright setInputFiles. |
required | true | Required parameters must be present and non-null. For optional parameters, see Optionality. |
description | null | Read by the AI agent when present. Be concrete and action-oriented. |
defaultValue | null | Applied before validation when the value is missing/empty. |
options | null | If set, the value must be one of the listed strings (renders a dropdown). Treated as a string at runtime regardless of type. |
{ "name": "...", "type": "..." } — the rest take their defaults.
Use
secret for credentials, tokens, API keys. Use file for user-uploaded attachments — declare it as a workflow input, reference it as {{parameter_name}} in prompts and parameters.parameter_name in deterministic code. Do not use string for binary uploads.Segment
inputParameters. The shared state is global, but the segment’s parameters object at runtime contains only the values the segment opted into. If you forget to declare an input, parameters.foo is undefined, even if an earlier segment produced foo.
Segment types
| Type | When to use | deterministic | prompt | AI fallback if deterministic throws |
|---|---|---|---|---|
ui | DOM interaction, navigation, visible-page extraction (the default) | recommended | required | yes |
network | Reading data out of recorded API responses | required | required | yes |
logic | Deterministic-only control flow / hard errors / invariant checks | required | must be null | no — segment hard-fails |
agent | Subjective judgment (“best”, “most relevant”, visual selection) | must be null | required | n/a — agent is the only mode |
- Default to
ui. Reach fornetworkonly when the response payload is the source of truth (the user said “from API”, or UI parsing is brittle). - Use
logicwhen you specifically want no AI fallback — for example, throwing “no results” errors or post-filter validation. - Use
agentwhen deterministic code can’t reliably encode the decision.
deterministic
deterministic is a JSON string containing a stringified async arrow function — not a live function. Two valid signatures:
pageis a Playwright page bound to the active session.parameterscontains all declaredinputParametersfor this segment.networkResponses(network segments only) — see Network segments below.- The function must return an object — use
{}if there are no outputs. - Throw on missing/invalid required values; never return
nullplaceholders.
await page.goto('https://example.com'); return {}; becomes:
prompt
Plain English for the AI agent. Reference parameters as {{parameter_name}} for runtime substitution. Describe the goal in terms of logical actions, not selectors:
- ✅
"Search Amazon for {{search_query}} and submit." - ❌
"Click button[aria-label=Search], fill input#q, press Enter."
ui/network segments, the prompt is also used as the AI fallback if the deterministic step throws — write it as if it might run on its own.
next and router
- Linear:
"next": "next_segment". - Terminal:
"next": null(workflow ends after this segment). - Branching:
"next": ["segment_a", "segment_b"]plus"router": "(parameters) => parameters.x ? 'segment_a' : 'segment_b'".
Data flow
State is a single flat map keyed by parametername. After a segment runs, its outputParameters are merged into that map and made available to every later segment whose inputParameters declare the same name. The workflow’s outputParameters are read from the same map at the end.
Implications:
- Two segments with the same output name overwrite each other.
- A segment only reads parameters it explicitly declares in
inputParameters— declaring an input is opt-in even though the underlying state is shared. - A router only reads its own segment’s outputs — see the warning above.
- If a downstream segment treats an input as
required: true, the producing segment’s output should also berequired: true, and its deterministic code must throw (not returnnull/empty) when the value is unavailable. - Demonstration values and static URLs belong inside the prompt, not as parameters.
Network segments
Fortype: "network" segments, the deterministic function receives a third argument — networkResponses — containing all responses recorded during the session.
Each entry has fields like requestUrl, method, status, headers, and a body. The body field name varies by recorder version, so always read it with the canonical fallback:
page.waitForResponse inside a workflow segment — networkResponses is the deterministic source of truth.
Reliability patterns
These are the highest-leverage rules for hand-written deterministic code.Split navigation from interaction
Always putpage.goto(url) in its own segment. Element waits, fills, and clicks belong in the next segment.
- ❌
nav_open_and_fill_search— navigation + interaction in one segment - ✅
nav_to_search_page→fill_search_form
page.waitForLoadState('networkidle') after page.goto. The next segment handles waiting for specific elements to appear. Splitting them makes segments reusable and resilient to timing issues.
Click and input stability
For any element that may be off-screen or in a virtual list, use the canonical pattern:state: 'attached'waits for DOM presence even when the element is off-screen. The defaultstate: 'visible'breaks on virtual lists.- For text inputs (
input,textarea, contenteditable), click/focus first, thenfill()ortype().
Selector quality
Prefer stable attributes in this order:data-testid → aria-label → name → semantic role + text. Scope selectors to a relevant region before text matching; avoid global .first() unless uniqueness is guaranteed.
Optionality (the most common gotcha)
The schema validator acceptsundefined (i.e. a missing key) for optional fields, not null. An AI agent producing structured JSON tends to emit "field": null for “absent”, which fails validation — especially for optional fields with options (enums).
Three patterns that work:
1. Route around it. Declare the optional value as an outputParameter of the segment whose router will read it, so the router can branch before the consuming segment ever runs. The consuming segment can then treat the input as required.
parameters.estimation here refers to this segment’s own output, which is what the router receives.
2. Add an explicit “none” option. For optional enums, include a sentinel like "none" in options and make the field required: true. The agent will pick "none" instead of null.
3. Omit the key. If you control the deterministic code, return {} (omit the key entirely) instead of { field: null }.
AI fallback
Forui and network segments, if the deterministic function throws, the runtime automatically retries the same step using the agent. The agent is driven by:
- the segment’s
prompt(with{{parameter_name}}substituted from the segment’s input parameters), and - the segment’s
outputParameters— converted to a JSON-schema contract that the agent must satisfy.
outputParameters you declare for the deterministic path are also the schema the AI fallback must produce. Declaring outputs carefully matters for both paths.
The execution is tagged "AI Fallback" so you can detect when this happened.
To disable fallback, set type: "logic". To force the agent path, set type: "agent" and deterministic: null.
Identity-linked workflows
When a browser identity is attached to the workflow, the platform pre-authenticates the session before the workflow runs. In that case:- Do not declare
username,password,otp_code,totp_secret,mfa_code, loginemail, or any other auth credential as aninputParameter. - Do not add login segments to the workflow — login is handled before your first segment runs.
- Treat any login actions you saw during recording as pre-conditions performed by the platform, not as part of the user’s task.
- Only declare business-logic parameters the user actually needs to provide at runtime (e.g.
report_name,invoice_number,search_query).
Authoring checklist
- Every segment has a
type. -
logicsegments haveprompt: nulland a non-nulldeterministic. -
agentsegments havedeterministic: nulland a comprehensiveprompt. - Every value referenced in a
routeris declared as anoutputParameterof the same segment as the router. - Every value a segment uses is declared in its
inputParameters. - Required downstream inputs come from required upstream outputs; deterministic code throws instead of returning
nullfor them. - Optional values are handled by routing, an explicit
"none"option, or by omitting the key — not by emittingnull. - Prompts use
{{parameter_name}}for dynamic values; static URLs and demonstration values are embedded in the prompt, not declared as parameters. -
secretfor credentials/tokens;filefor user-uploaded attachments. - Navigation segments do
page.gotoonly — element waits and interactions live in the next segment. -
next: nullonly on terminal segments; otherwise a single string or an array paired with arouter. -
deterministicis a JSON string with quotes escaped, on a single line. - If an identity is attached, no auth credentials are declared as parameters.

