---
name: agentmall
description: Connect AgentMall, the commerce API for AI agents, and build on it. Use when the user asks to try, set up, test or integrate AgentMall; to search or buy at a store such as Target, Best Buy, Albertsons, FreshDirect or Ocado; to use a sandbox (`am_test_`) or live (`am_live_`) key; to handle purchase questions (sign_in, sign_in_code, card, approve, ship_to, choose, unavailable) or error codes; to run the sandbox test plan; or to go live.
---

# AgentMall

AgentMall lets an AI agent search and buy at real stores. It has five operations: `list_merchants`, `search`, `buy`, `get_purchase` and `respond`. A purchase runs in the background. When it needs something, it stops and asks questions. You read them with `get_purchase` and answer each one, or hand its link to the shopper.

There are two kinds of key and nothing else differs. A sandbox key (`am_test_`) runs every call on five simulated stores with no real card and no money. A live key (`am_live_`) runs the same calls on real stores. Build and test with the sandbox key, then swap in the live key.

Read this file first. Go to the reference files when the task needs them:

- https://www.getagentmall.com/skill/flows.md: worked examples of whole jobs, call by call with the responses: a first purchase, a reorder with no questions, comparing two stores, a grocery basket, sizes and colours, a gift to another address, two stores at once, UK pounds, a price rise, cancel, recovering from timeouts, a chat bot backend and a scheduled restock. **Start here when you are building something: find the closest flow and copy it.**
- https://www.getagentmall.com/skill/workflows.md: search then buy, every question with its answer, polling, a backend with many shoppers, idempotency, cancel, budgets.
- https://www.getagentmall.com/skill/triggers.md: how to reach every status, question and error in the sandbox on purpose, and what your agent does in each.
- https://www.getagentmall.com/skill/errors.md: every error code and failure code, with the action to take.
- https://www.getagentmall.com/skill/checklist.md: the test plan to run in the sandbox before going live.
- https://www.getagentmall.com/skill/examples.md: code to start from: TypeScript and Python clients, the loop that follows a purchase and answers every question, a CI test, and instructions to give your own agent.

## 1. Get a key

If the user already gave you a key (`am_test_...` or `am_live_...`), use it wherever this file says `YOUR_KEY` and go to step 2.

Otherwise ask the user for one. Don't continue without it:

1. Sign up at https://console.getagentmall.com. Setup asks for an organization name, then shows a sandbox key and instructions to copy. Four optional questions after that add $5 of credit. The console opens in Sandbox mode.
2. For another key later, open https://console.getagentmall.com/keys with the header's **Sandbox** switch on, and click **Mint sandbox key**.
3. Copy the key. It is shown once. The console also shows a setup prompt with the key in it, which the user can paste to you.

A sandbox key's stores are `albertsons`, `freshdirect`, `ocado`, `target` and `bestbuy`. Test cards and triggers: https://www.getagentmall.com/skill/triggers.md.

## 2. Connect

Every call needs two headers: `Authorization: Bearer YOUR_KEY` and `X-Shopper-Id`, the id of the person you buy for. A call without `X-Shopper-Id` returns `invalid_input`. `shp_demo` works for one person. A backend sends its own id for each end user (see workflows.md). A purchase can only be read or answered with the shopper id that started it.

### MCP (coding agents)

Claude Code:

```bash
claude mcp add --transport http agentmall https://mcp.getagentmall.com \
  --header "Authorization: Bearer YOUR_KEY" \
  --header "X-Shopper-Id: shp_demo"
```

Cursor (`~/.cursor/mcp.json` or project `.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "agentmall": {
      "url": "https://mcp.getagentmall.com",
      "headers": {
        "Authorization": "Bearer YOUR_KEY",
        "X-Shopper-Id": "shp_demo"
      }
    }
  }
}
```

Other MCP clients: streamable HTTP at the same URL with the same two headers. A client that only takes a URL can use `https://mcp.getagentmall.com?key=YOUR_KEY&shopper=shp_demo`, but headers keep the key out of logs. Restart the session if the `agentmall` tools don't appear.

### REST (your backend)

The same five operations are `POST https://api.getagentmall.com/v1/<operation>`, with the tool's input as the JSON body and the same two headers:

```bash
curl -X POST https://api.getagentmall.com/v1/search \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "X-Shopper-Id: shp_demo" \
  -H "Content-Type: application/json" \
  -d '{ "merchant": "target", "query": "headphones" }'
```

Each key can make 15 requests a second across MCP and REST.

## 3. The five operations

| Operation        | Input                                                                            | Returns                                                        |
| ---------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `list_merchants` | `{ query?, limit? }`                                                             | `{ merchants }`: each `merchant`, `title`, `domain`, `profile` |
| `search`         | `{ merchant, query, speed? }`                                                    | `{ merchant, query, source, products }`                        |
| `buy`            | `{ merchant, items, details?, max_total?, idempotency_key?, speed?, metadata? }` | A purchase, at once, with `status: "running"`                  |
| `get_purchase`   | `{ id }`                                                                         | The purchase as it is now                                      |
| `respond`        | `{ id, question_id?, action, ... }`                                              | The purchase after your answer                                 |

`merchant` is a merchant id from `list_merchants`, which lists the stores your key can use. Call it before you build a cart: each store's `profile` says its currency, its minimum, and how it signs in. Field meanings: https://docs.getagentmall.com/concepts/merchants#what-each-profile-field-means Prices and totals are integers in the smallest unit of the currency: `1699` is $16.99. Purchases and orders carry `mode`: `"sandbox"` or `"live"`.

Results carry `api_version: "2026-11-25"`. Later versions only add things, so ignore fields you don't know. A question kind you don't know goes to the shopper if it has a `link`; otherwise stop and tell the user. A status you don't know means keep polling, unless it is `placed`, `submitted`, `unknown`, `failed` or `canceled`.

## 4. Search

```json
{ "merchant": "target", "query": "headphones" }
```

It returns up to 10 `products`. Show the user `title`, `price` and `availability`. Each product's `url` is what `buy` takes.

**Check every title before you use a result.** Search returns the nearest matches, not only exact ones. If nothing matches, say so and try a more specific query. Don't buy the closest result. A search takes 5 to 20 seconds. Tell the user you're searching instead of calling again.

## 5. Buy

Get from the user what to buy, how many, and their budget if they have one. Then call `buy` once:

```json
{
  "merchant": "target",
  "items": [
    {
      "url": "https://www.target.com/p/crest-3d-white-advanced-teeth-whitening-toothpaste-radiant-mint-3-3oz-3pk/-/A-75557360",
      "quantity": 2
    }
  ],
  "max_total": { "amount": 4000, "currency": "USD" },
  "idempotency_key": "<new uuid>"
}
```

- `items`: 1 to 20 lines, each a product `url` from `search` at this merchant and a `quantity` from 1 to 12. Pass a colour, size or other option the user named in `options` (`{ "size": "L" }`).
- `details.ship_to`: optional US postal address. Without it the order ships to the address on the shopper's store account, or the purchase asks `ship_to`.
- `max_total`: the most the user will pay, tax and fees included, in cents and `USD`. **Pass it when the user gives a budget.** At or under it, the order is placed with no approval. Above it, or without it, the shopper approves on a link. Leaving it out is not "no limit". Never invent a budget. If the organization requires approval for every order, `buy` with `max_total` returns `invalid_input`: call it again without. AgentMall places no order above $100 (£100 at a GBP store): `max_total` is at most `10000`, and a bigger checkout ends `failed` `total_above_cap`. Split a bigger cart into orders under $100.
- `idempotency_key`: a new UUID for each order you mean to place. **If `buy` times out, call it again with the same key.** You get the same purchase back.
- `speed`: sandbox keys only; a live key ignores it. `"instant"` waits for nothing: send it in CI and automated tests. `"fast"`, the default, takes about 3 minutes a purchase: use it when a person plays the shopper. `"realistic"` takes as long as the real store: run it once before going live. The purchase keeps the speed `buy` was given.
- `metadata`: optional, your own reference such as `{ "chat_id": "c_123" }`: up to 20 string keys of at most 40 characters, values at most 500. The purchase and webhook events return it as sent, with `shopper_id`, so a backend can tell whose purchase an event is. Never put card or login details in it.
- `payment`: only when your app already holds the shopper's Stripe Link access token. Send `{ "method": "link", "connection": { "access_token": "..." } }` and the purchase pays with a one-time card the shopper approves in Link (`payment_approve`), never a saved card. Link needs a US or Canadian shopper with a US-issued card. Sandbox keys take test tokens such as `link_test_approve` (triggers.md).
- One purchase is one order at one store. To buy at two stores, start two purchases.

`buy` returns at once with an `id` (`pur_...`) and `status: "running"`. Keep the `id`.

## 6. Follow the purchase until it ends

Call `get_purchase` with `{ "id": "pur_..." }` about every 5 seconds and act on `status`:

| `status`         | What it means                                                      | What you do                                                                            |
| ---------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| `running`        | AgentMall is working at the store. `step` says on what             | Wait 5 seconds and call `get_purchase` again                                           |
| `awaiting_input` | It stopped with `questions`                                        | Answer each one by its `kind` (table below)                                            |
| `placed`         | The order went through                                             | Tell the user. `order` has the totals and `currency`                                   |
| `submitted`      | The store received the order and gave no order number              | Tell the user the order went in. They follow it in their store account                 |
| `unknown`        | The click may have gone out and no confirmation came back          | Tell the user it may have gone through. **Never buy again** until they check the store |
| `failed`         | It stopped. `failure.code`, `failure.message`, `failure.retryable` | Tell the user. Act on the code (errors.md)                                             |
| `canceled`       | You canceled it                                                    | Nothing more to do                                                                     |

`placed`, `submitted`, `unknown`, `failed` and `canceled` are final.

Optional, for a backend: instead of polling, save a webhook URL at https://console.getagentmall.com/webhooks. AgentMall then POSTs `purchase.updated` when a purchase asks a question or ends, signed to the Standard Webhooks spec. Most setups don't need one. See https://docs.getagentmall.com/concepts/webhooks.

Each question has an `id`, a `kind`, `answered_by` (`shopper` or `agent`) and `expires_at` (an ISO 8601 time, or `null`). A shopper question has a `link`. Answer an agent question with `respond`, passing its `id` as `question_id`.

| `kind`            | Who         | What you do                                                                                                                                                                                                              |
| ----------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `sign_in`         | The shopper | Give them `link`. They sign in to the store there. Or, holding the login, `respond` `provide` with `login` (`email`, `password` as typed). A wrong login asks again, up to three times                                   |
| `sign_in_code`    | The shopper | Give them `link` at once, or, if you can read the code, `respond` `provide` with `code`. Within five minutes                                                                                                             |
| `card`            | The shopper | Give them `link`. They enter a card there. Never ask for card details in chat                                                                                                                                            |
| `approve`         | The shopper | Show `total` and `currency`, then give them `link`. Their **Place order** click starts placing it; read the result with `get_purchase`                                                                                   |
| `payment_approve` | The shopper | Only when you sent `payment`. Tell them the most the card can be charged (`total`, `currency`) and give them `link`, their wallet's page. When they say they approved, call `get_purchase`: nothing else tells AgentMall |
| `ship_to`         | You         | Ask where to ship, then `respond` with `action: "provide"` and `details.ship_to`                                                                                                                                         |
| `choose`          | You         | Read `message` and `choices`, pick with the user, then `respond` with `action: "choose"`, `item_url` and `options` from `choices`                                                                                        |
| `unavailable`     | You         | Tell the user which `items` can't be bought. `respond` with `action: "drop"` and `item_urls`, or `action: "cancel"`                                                                                                      |

The purchase moves on by itself when the shopper finishes on a link. Ask them to tell you when they're done, then call `get_purchase`. Another question can follow. Exact `respond` bodies are in workflows.md.

## 7. Don't go in circles

- **Call `buy` once per order.** Follow it with `get_purchase`. The one exception is a timed-out `buy`: send it again with the same `idempotency_key`.
- **Send each link once.** Send it again only if `link` changed or the shopper asks.
- **Never open a link yourself, and never ask for card numbers.** Send a store password with `respond` only when the user gave it to you for that store; otherwise send the `sign_in` link. If `provide` with `login` or `code` returns `invalid_input`, the organization takes sign-in on the link only: send the link. In the sandbox, when you are testing with no shopper, you play the shopper and open the links yourself (triggers.md).
- **A `running` purchase is working.** A checkout step often takes 15 to 30 seconds. Don't cancel it for being slow, and don't call it stuck until it has been `running` unchanged for 2 minutes.
- **Keep polling until `awaiting_input` or a final status.** Don't ask the user when to check. A purchase can stay `running` for 3 minutes before its first question, and up to 3 minutes again after each answer. Tell the user it is still working after 2 minutes. Don't cancel a slow purchase: after 10 minutes AgentMall ends it `timeout` itself.
- **`unknown` is never retried.** The order may exist. The shopper checks their store account.
- **After `failed`, buy again only when `failure.retryable` is `true` or you changed what caused it.** Then buy again once, not in a loop. The action for every code is in errors.md.

## 8. Errors from a call

A call that fails returns `error.code`, `error.message` and `error.retry` (on MCP, `isError: true` with that JSON as text). The ones you will meet most:

- `invalid_input`: a field is wrong, or `X-Shopper-Id` is missing. The message names it. Fix it and call again.
- `unauthorized` / `invalid_key` (HTTP 401): no key, or a wrong one.
- `merchant_not_live`: that store isn't available on this key. Call `list_merchants` for the ones that are.
- `purchase_in_progress`: the shopper already has an open purchase at this store (`purchase_id`). Follow or cancel that one.
- `question_not_open`: read the purchase again and answer what it asks now.
- `purchase_ended`: the purchase is final. Read it. Don't `respond` to it.
- `rate_limited`, `browser_unavailable`, `server_shutting_down`: wait `retry_after_seconds`, then call again.

Every other code, with its action: https://www.getagentmall.com/skill/errors.md.

## 9. Test in the sandbox

Before going live, run the test plan at https://www.getagentmall.com/skill/checklist.md. It reaches every question, every error and the full order lifecycle on the five sandbox stores. You act as the shopper on the links. Sign in with your own email and the password `Sandbox-123`, ship to `Jane Doe, 123 Main St, Austin, TX 78701, US`, and save a test card with expiry `12/30` and CVC `123`:

| Card                  | What happens                                                        |
| --------------------- | ------------------------------------------------------------------- |
| `4242 4242 4242 4242` | The order is placed                                                 |
| `4000 0000 0000 0002` | Declined. The purchase asks `card` again                            |
| `4000 0025 0000 3155` | The bank emails an Approve / Decline link. Placed or declined on it |
| `4000 0000 0000 0402` | Refused with `insufficient_credit`, as though credit ran out        |

At the default `speed`, `fast`, a whole sandbox purchase takes about 3 minutes. `instant` waits for nothing; `realistic` takes as long as a live store. A placed order reads `completed`, as a live one does. Sandbox orders take no fee. The console's Billing page has **Reset sandbox**, which does not sign shoppers out of the sandbox stores. An AgentMall restart signs every sandbox shopper out.

## 10. Go live

1. In the console, turn the **Sandbox** switch off, open https://console.getagentmall.com/keys and click **Mint live key**.
2. Replace the `am_test_` key with the `am_live_` key. Nothing else in your code changes: same hosts, same calls, same shopper ids.
3. Add credit on https://console.getagentmall.com/billing. Each placed order costs $0.50.

What changes with a live key:

- **Real money.** Orders are submitted to the store and charged to the shopper's real card. The order fee comes from your live credit.
- **Different stores.** The live store list is not the sandbox's five. Call `list_merchants` with each key.
- **Real sign-ins and cards.** Shoppers sign in to their own store accounts. A store account with a saved address and card usually goes straight to `approve`. Test cards and trigger emails (`+code` and the rest) do nothing.
- **Real timing.** `speed` is ignored. Steps take about as long as the sandbox's `realistic`, vary more, and stores sometimes block or time out (`merchant_blocked`, `timeout`, `browser_unavailable`). Follow `failure.retryable`.
- **Separate data.** Sandbox purchases, saved cards, sign-ins and credit never show in live.

## 11. Install AgentMall where it will be used

Setting up isn't finished until AgentMall is installed in the agent system the user will buy through. When the walkthrough is done:

1. Ask the user which agent system AgentMall belongs in: a personal agent they use every day, or an agent or product they're building.
2. Ask them to point you at it: its repo, its config, or where it takes MCP servers or skills. Wait for the answer.
3. Integrate AgentMall there with their key and shopper id. If it takes MCP servers, add `https://mcp.getagentmall.com` with both headers (section 2). If it's a backend, start from the clients in https://www.getagentmall.com/skill/examples.md and the backend flows in https://www.getagentmall.com/skill/flows.md (a chat bot, a scheduled restock). A backend can optionally take a webhook instead of polling (section 6). Offer it, and set it up only if the user wants it.
4. Save this skill there, so the agent has it in every later session:
   - Claude Code: `mkdir -p ~/.claude/skills/agentmall && curl -o ~/.claude/skills/agentmall/SKILL.md https://www.getagentmall.com/SKILL.md` (or `.claude/skills/agentmall/` in a project).
   - Cursor: save it as `.cursor/rules/agentmall.mdc` in the project.
   - Codex: add a line to the project's `AGENTS.md`: "For buying at stores, follow https://www.getagentmall.com/SKILL.md."
   - Any other agent: add the instructions block from https://www.getagentmall.com/skill/examples.md to its system prompt or rules.
5. Tell the user what you changed and how to check it works, such as one sandbox `search` from inside that agent.

Docs: https://docs.getagentmall.com. Sandbox reference: https://docs.getagentmall.com/sandbox. Questions: team@getagentmall.com.
