# martcp: agent guide

martcp lets an AI agent find products from online stores that ship to AU and hand the user a ready-to-pay checkout link. You never handle card details: the user pays on the seller's own checkout. All endpoints are public HTTPS + JSON; no authentication.

Base URL: `https://www.martcp.com`. Machine-readable spec: `https://www.martcp.com/openapi.json`.

**Coverage:** Currently covers partner stores only: KG Superstore (kgsuperstore.com.au). More stores are being added; sellers can apply at https://www.martcp.com/#partners.

## 1. Search

```http
GET /v1/search?q={query}&brand={brand}&min_price={number}&max_price={number}&limit={1-25}&cursor={next_cursor}
```

- `q` (required): what the user wants, in plain words. Include size, colour, brand, material when known.
- `brand`: only this brand's products, e.g. `Samsung`. Use it when the user wants that brand (a Samsung phone case), not when the product only has to fit it (a case for a Samsung phone: put that in `q`). If nothing matches, `notes` says so; search again without `brand` for related products.
- `min_price` / `max_price`: AUD, major units (e.g. `49.95`).
- `limit`: page size, default 10. The first page can contain extra featured results.
- `cursor`: the `next_cursor` from the previous page, unchanged.

Response (abridged):

```json
{
  "search_id": "s_8f2k...",
  "results": [
    {
      "position": 1,
      "featured": true,
      "product_id": "p_1ksiweeFXz1plDhO3cO8jq",
      "title": "Elevated Sofa Pet Dog Bed - Medium",
      "seller": { "id": "shop_91801911663", "name": "KGsuperstore", "url": "https://kgsuperstore.com.au", "partner": true },
      "price": { "amount": "89.00", "currency": "AUD" },
      "list_price": { "amount": "96.00", "currency": "AUD" },
      "available": true,
      "image": "https://cdn.shopify.com/...",
      "url": "https://kgsuperstore.com.au/products/...",
      "variant_count": 1,
      "variants": [{ "variant_id": "v_53509308055919", "title": "Default Title", "price": { "amount": "89.00", "currency": "AUD" }, "available": true }]
    }
  ],
  "next_cursor": "eyJvZmZzZXQiOjEw..."
}
```

- Each result is **one seller's offer**. The same product can appear from several sellers; compare price, availability and seller.
- `featured: true` marks partner sellers, placed first on the first page. Organic results follow in relevance order.
- `url` is the product page, if the user wants to look before buying.

### Discounts

Some sellers offer a discount code to shoppers who buy through martcp. Their results add `discounted_price` (on the offer and on each variant the code covers) and a `discount` object:

```json
"price": { "amount": "89.00", "currency": "AUD" },
"discounted_price": { "amount": "80.10", "currency": "AUD" },
"discount": { "code": "AGENTS10", "percent_off": 10, "expires_on": "2026-12-31" }
```

- `discounted_price` is what the user pays. Compare offers on it when present, and on `price` otherwise.
- The code is added to the cart's `checkout_url`, so the user doesn't need to enter it. It's applied on the seller's checkout, not on the product page `url`.
- A variant without `discounted_price` isn't covered by the code (for example, an item already on sale).
- `expires_on` is the code's last day, if it has one. Totals at checkout can differ by a cent from rounding.

### About the seller

Search and product responses include `sellers`, keyed by `seller.id`, for sellers who have told us about themselves. Checkout links carry the same object as `seller_info`. Every field is optional and comes from the seller (`provided_by: "seller"`, last updated `updated_on`):

```json
"sellers": {
  "shop_91801911663": {
    "name": "KG Superstore",
    "website": "https://kgsuperstore.com.au",
    "legal_name": "Example Retail Pty Ltd",
    "abn": "51 824 753 556",
    "location": "Heatherton, VIC",
    "trading_since": 2007,
    "delivery": { "dispatch": "Within 1 business day", "time": "2–7 business days" },
    "returns": { "change_of_mind_days": 30, "summary": "Unopened items within 30 days; buyer pays return postage." },
    "support": { "email": "help@example.com.au", "phone": "03 9000 0000", "tracking_url": "https://example.com.au/track" },
    "ratings": [{ "source": "eBay", "score": 4.9, "scale": 5, "count": 1200, "url": "https://www.ebay.com.au/usr/example", "as_of": "2026-11-25" }],
    "provided_by": "seller",
    "updated_on": "2026-11-26"
  }
}
```

- Use it to tell the user who they're buying from, how long delivery takes, whether they can return the item, and where to go after the sale. Delivery prices come from the cart (pass a `postcode`), not from here.
- If a field is missing, we don't know it: say so or point to the seller's policy links rather than guessing.
- Quote ratings with their source and date.

## 2. Product details (optional)

```http
GET /v1/products/{product_id}?seller={seller.id}&search_id={search_id}
```

Returns `offers` (one per seller, or only the requested seller), each with the full description, every variant with its `options` (e.g. `{"Size": "Large", "Colour": "Grey"}`), and `policies` links (shipping, refunds, terms). Use it to pick the right variant or answer questions about shipping and returns.

## 3. Create checkout links

```http
POST /v1/carts
Content-Type: application/json

{
  "search_id": "s_8f2k...",
  "items": [
    { "variant_id": "v_53509308055919", "quantity": 1 }
  ],
  "reason": "Cheapest in-stock elevated bed in medium",
  "postcode": "3000"
}
```

Response `201`:

```json
{
  "carts": [
    {
      "cart_id": "c_x1y2z3...",
      "seller": { "id": "shop_91801911663", "name": "KGsuperstore", "partner": true },
      "items": [{ "variant_id": "v_53509308055919", "title": "...", "quantity": 1, "unit_price": { "amount": "89.00", "currency": "AUD" } }],
      "subtotal": { "amount": "89.00", "currency": "AUD" },
      "delivery": {
        "postcode": "3000",
        "options": [
          { "name": "Standard Auspost eParcel (2 - 6 Business Days)", "price": { "amount": "0.00", "currency": "AUD" } },
          { "name": "Express Auspost eParcel (1 - 4 Business Days)", "price": { "amount": "14.95", "currency": "AUD" } }
        ]
      },
      "estimated_total": { "amount": "89.00", "currency": "AUD" },
      "checkout_url": "https://www.martcp.com/go/c_x1y2z3..."
    }
  ]
}
```

- Items from different sellers produce one cart each; give the user every `checkout_url`.
- The subtotal excludes delivery. Pass the user's `postcode` to get `delivery.options` (name, usually with the delivery time, and price) from the seller's own store, and `estimated_total`: the total after any discount code, with the cheapest option. The seller's checkout confirms the final amount. We use the postcode only for this quote and never store it.
- Without a postcode, tell the user delivery is added at the seller's checkout. If delivery can't be priced in advance (for example, items that ship separately), `delivery.note` says so and there is no `estimated_total`.
- If the seller offers a discount code, the cart also has `discount` (`code`, `percent_off`, `amount`), `discounted_subtotal`, and `discounted_unit_price` on each covered item. The code is already in `checkout_url`.
- `issues` lists items that could not be added (`invalid_id`, `not_found`, `unavailable`, `invalid_quantity`, `seller_not_listed`). If no item could be added, the status is `422`. When the seller's store is asked (a postcode or discount code), `limited_stock` flags an item that stays in the cart but is short of stock: lower its quantity and create the link again.
- `reason` is optional, free text up to 500 characters, and helps sellers understand what buyers want.

## MCP alternative

If your client speaks MCP, connect to `https://www.martcp.com/mcp` (Streamable HTTP, no authentication; protocol 2026-07-28 and 2025-era clients are both supported). The tools mirror the endpoints above and return the same JSON:

| Tool | Equivalent |
|---|---|
| `search_products` (`query`, `brand`, `min_price`, `max_price`, `limit`, `cursor`) | `GET /v1/search` |
| `get_product` (`product_id`, `seller_id`, `search_id`) | `GET /v1/products/{product_id}` |
| `create_checkout_links` (`items`, `search_id`, `reason`, `postcode`) | `POST /v1/carts` |

## Presenting to the user

- Show the seller name, price (the `discounted_price`, when there is one) and delivery: the `estimated_total` and delivery options when you passed a postcode, otherwise that delivery is added at checkout. Then the `checkout_url` as a link.
- Do not ask the user for card details. Payment happens on the seller's checkout page.
- After the sale, the seller handles order status, tracking, returns and problems. Point the user to `seller_info.support` on the cart when it's there, otherwise to the seller's website.

## Errors

Errors return `{"error": {"code": "...", "message": "..."}}`:

| Status | Code | Meaning |
|---|---|---|
| 400 | `invalid_request` | Missing or malformed parameter; the message says which. |
| 404 | `invalid_request` | Unknown product. |
| 502 | `upstream_error` | The product catalog is temporarily unavailable; retry later. |
| 503 | `rate_limited` | Busy; wait for `Retry-After` seconds. |

## Identification (optional)

Send `X-Agent-Name: <your-assistant>` so we can report to sellers which assistants refer customers. We do not collect personal information about users.
