> ## 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.

> ## Agent Instructions
> Anchor Browser is cloud browser infrastructure for AI agents and automation: browser sessions you control over CDP or REST, natural-language web tasks, versioned automation tasks, managed authentication into third-party web apps (identities with MFA), persistent volumes and profiles, recordings, live view, batch sessions, webhooks, and network options including residential proxies, extra stealth, and captcha solving for sites that block standard browsers. The for-agents page (https://docs.anchorbrowser.io/for-agents) covers authentication and the first API calls. API keys are created at https://app.anchorbrowser.io/api-keys. Append .md to any page URL for its Markdown version. The SDKs read the API key from ANCHORBROWSER_API_KEY, and REST calls send it in the anchor-api-key header. End every session you create with DELETE /v1/sessions/{id}, because a session is billed until it ends. Location targeting, captcha solving and managed authentication need the Starter plan, and extra stealth needs the Growth plan; on the Free plan, create a session with an empty body. Plans and limits are at https://docs.anchorbrowser.io/pricing. The hosted MCP server is https://api.anchorbrowser.io/v1/mcp.

# Shop a Store, Stop Before Payment

> Example: an agent task that finds a product on a real store, adds it to the cart and returns the cart as validated JSON, without checking out.

This example sends the agent to a real online store. It finds a named product, adds it to the cart and reads the cart back. It stops there: no checkout, no personal details, no payment.

* The store and the product come from [Commerce Bench](https://github.com/anchorbrowser/commerce-bench), an open harness that tests shopping agents on real stores. Barnes & Noble is one of the stores its reference agent finished on a default Anchor session.
* The prompt states where to stop. Keep that line in any shopping task you write.

Before you run it, set `ANCHORBROWSER_API_KEY` and install the SDK. The Node.js version also needs `zod` 4, and the Python version needs `pydantic`.

```javascript node.js theme={null}
import { z } from "zod";
import { client, agentTask, Sessions } from "anchorbrowser";

client.setConfig({ auth: () => process.env.ANCHORBROWSER_API_KEY });

const Cart = z.object({
  product_title: z.string(),
  format: z.string(),
  unit_price: z.string(),
  cart_item_count: z.number(),
  cart_subtotal: z.string(),
});

const task = await agentTask(
  `Find the book "Atomic Habits" by James Clear in Hardcover. Add one copy to the cart, then open the cart. Return the product title, the format, the unit price, the number of items in the cart and the cart subtotal. Stop at the cart. Do not start checkout, do not enter any personal details and do not enter any payment details.`,
  {
    taskOptions: {
      url: "https://www.barnesandnoble.com/",
      outputSchema: z.toJSONSchema(Cart),
    },
  }
);

try {
  if (task.status !== "success") throw new Error(`Task failed: ${task.result}`);
  const cart = Cart.parse(JSON.parse(task.data.result));
  console.log(cart);
} finally {
  await Sessions.deleteSession({ path: { session_id: task.sessionId } });
}
```

```python python theme={null}
import json
import os

from anchorbrowser import Anchorbrowser
from pydantic import BaseModel

anchor_client = Anchorbrowser(api_key=os.getenv("ANCHORBROWSER_API_KEY"))


class Cart(BaseModel):
    product_title: str
    format: str
    unit_price: str
    cart_item_count: int
    cart_subtotal: str


task = anchor_client.agent.task(
    """Find the book "Atomic Habits" by James Clear in Hardcover. Add one copy to the cart, then open the cart. Return the product title, the format, the unit price, the number of items in the cart and the cart subtotal. Stop at the cart. Do not start checkout, do not enter any personal details and do not enter any payment details.""",
    task_options={
        "url": "https://www.barnesandnoble.com/",
        "output_schema": Cart.model_json_schema(),
    },
)

try:
    if task.data.status != "success":
        raise RuntimeError(f"Task failed: {task.data.result}")
    cart = Cart.model_validate(json.loads(task.data.result))
    print(cart.model_dump())
finally:
    anchor_client.sessions.delete_session(task.data.sessionId)
```

## Output

Both scripts on this page were run against the live API on November 27, 2026. This is the output of one of those runs. Your values will differ.

```json theme={null}
{
  "product_title": "Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones",
  "format": "Hardcover",
  "unit_price": "$22.00",
  "cart_item_count": 1,
  "cart_subtotal": "$22.00"
}
```

## Notes

* Two runs put different listings of the book in the cart: one at $22.00 and one at $37.99. Both were hardcover. Name the edition or the ISBN in the prompt when the exact item matters.
* No agent in these docs submits payment. If you extend this example toward checkout, stop before the payment step.
* Many stores turn an automated browser away before the agent can act. In the published Commerce Bench runs, the same agent got into 12 of 30 stores from a laptop browser, 17 on a default Anchor session and 25 with the best Anchor setup for each store. See the [results](https://commerce.assistantanalysis.com/).
* If a store blocks a default session, turn on a proxy, captcha solving or extra stealth. See [Network and stealth](https://docs.anchorbrowser.io/network-and-stealth/overview.md) for what each plan includes.
* The task result is checked: a `status` other than `success` raises an error instead of printing a failure as if it worked.
* The session is ended in a `finally` block. A task does not end the session it runs in.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.