# Bazaar / agentic.market — get discovered

Operator runbook for listing AUTOGROK Desk job routes on Coinbase CDP Bazaar
and [agentic.market](https://www.agentic.market).

Official docs (follow these; do not invent APIs):

- [Get discovered (Bazaar)](https://docs.cdp.coinbase.com/x402/seller/get-discovered)
- [Bazaar extension](https://docs.x402.org/extensions/bazaar)
- Validate: `POST https://api.cdp.coinbase.com/platform/v2/x402/validate`

There is **no registration form**. Indexing happens after a **successful settled
payment** through the **CDP facilitator** when the client echoes `extensions.bazaar`.

**Do not spend real USDC in CI or agent automation.** Wayne funds a tiny buyer
wallet when ready to index.

---

## What the code already does

| Piece | Location | Notes |
|-------|----------|--------|
| Agent-ready descriptions (≤500 chars, when-to-call) | `src/catalog.ts` | Per SKU |
| Input/output examples + JSON Schema | `src/catalog.ts` | `exampleBody`, `exampleOutput`, `outputSchema` |
| Tags (≤5, Search/Data) | `src/catalog.ts` | e.g. `page-extract`, `url-probe`, `search`, `data` |
| `declareDiscoveryExtension` | `src/discovery.ts` → `skuBazaarExtensions` | From `@x402/extensions/bazaar` |
| Live CDP routes + bazaar override | `src/middleware/x402.ts` `initLiveX402` | Full RouteConfig: `serviceName`, `tags`, `extensions` |
| Stub 402 also advertises bazaar | `buildPaymentRequired` | Same extension shape for local/validate-like probes |
| Free agent catalog | `GET /v1/discovery`, `/v1/catalog`, `/.well-known/x402` | Does not call facilitator |

`createX402Server` auto-injects a **minimal** bazaar declaration; our explicit
`extensions` from `declareDiscoveryExtension` **replace** that per-route (CDP docs).

---

## SKU resources (five)

Replace `YOUR_HOST` with `PUBLIC_BASE_URL` (public HTTPS, not ngrok if you care about ranking).

| id | Method + path | Price |
|----|---------------|------:|
| `url-probe` | `POST /v1/jobs/url-probe` | $0.03 |
| `page-extract` | `POST /v1/jobs/page-extract` | $0.05 |
| `watch-once` | `POST /v1/jobs/watch-once` | $0.10 |
| `json-shape` | `POST /v1/jobs/json-shape` | $0.15 |
| `brief` | `POST /v1/jobs/brief` | $0.25 |

Pay-to (public receive only): env `PAY_TO_ADDRESS` — documented placeholder
`0x2Beb44D877aC1A3fe12230Ded74EF5f934caBC29`. Network: Base `eip155:8453`, USDC.

---

## Step 1 — Deploy + env

1. Public HTTPS host with `PUBLIC_BASE_URL=https://your.host`
2. `PAY_TO_ADDRESS` = receiving wallet on Base
3. `CDP_API_KEY_ID` + `CDP_API_KEY_SECRET` so settlement is **live** (not stub)
4. Confirm unpaid job POST returns **HTTP 402** with `PAYMENT-REQUIRED` and
   `extensions.bazaar` (empty body should still 402, not 400)

```bash
curl -sS -o /tmp/402.json -w "%{http_code}\n" \
  -X POST "https://YOUR_HOST/v1/jobs/url-probe" \
  -H "Content-Type: application/json" \
  -d '{}'
# expect 402
jq '.extensions.bazaar.info, .resource.serviceName, .resource.tags' /tmp/402.json
```

---

## Step 2 — Validate endpoint (no API key, no payment)

For **each** job resource:

```bash
curl -sS -X POST https://api.cdp.coinbase.com/platform/v2/x402/validate \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "https://YOUR_HOST/v1/jobs/url-probe",
    "method": "POST"
  }' | jq '{valid, simulation, bazaarExtension: .bazaarExtension, preflight}'
```

Success shape (per CDP docs): `valid: true` and `simulation.outcome: "accepted"`.
Review `preflight` for required failures vs advisory notes. Inspect
`bazaarExtension` to confirm schemas/examples look right.

Repeat for: `page-extract`, `watch-once`, `json-shape`, `brief`.

---

## Step 3 — One settled payment per route (Wayne — real tiny USDC)

Blocked on a **buyer wallet** with a little USDC on Base (mainnet) **or** Base
Sepolia if `NETWORK=base-sepolia` + CDP facilitator development environment.

For each of the five routes:

1. Call the unpaid endpoint → receive 402 + `PAYMENT-REQUIRED` (includes `extensions.bazaar`).
2. Pay with an x402 client that **echoes** the bazaar extension into `PaymentPayload`
   (official `@x402` / CDP clients do this when talking to a bazaar-declaring server).
3. Settle through the **CDP facilitator** (same stack as live Desk).
4. Read settle/verify `EXTENSION-RESPONSES` (base64 JSON). Decode and check:

| `bazaar.status` | Meaning |
|-----------------|--------|
| `success` | Metadata validated and cataloged |
| `processing` | Accepted; indexing async — wait, then re-check catalog |
| `rejected` | See `rejectedReason` (often schema validation) |

**Important:** verify alone is not enough; **settle** triggers indexing. The
settled payload must carry `paymentPayload.resource` and the echoed bazaar extension.

Cheapest path to index all five: one successful paid call each (url-probe $0.03
… brief $0.25). Total ≈ **$0.58 USDC** plus gas/facilitator side effects as applicable.

Do **not** force this from the agent/CI. Wayne runs it when ready.

---

## Step 4 — Confirm on agentic.market / CDP discovery

After settle (allow time; ranking metrics can lag up to ~6 hours):

1. Browse [agentic.market](https://www.agentic.market) for “AUTOGROK Desk” or SKU tags.
2. Or query CDP discovery (facilitator catalog), filtering by payTo:

```bash
# Shape may evolve — see current CDP “Discover services” docs if this 404s.
curl -sS "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources?payTo=0x2Beb44D877aC1A3fe12230Ded74EF5f934caBC29" \
  | jq '.items[]? | {resource, type, extensions}'
```

3. Optional buyer client: `@x402/extensions` `withBazaar(facilitatorClient)` →
   `listResources` / `search` (see Bazaar extension docs). Note: x402.org
   facilitator catalog ≠ CDP Bazaar; Desk targets **CDP**.

Resources with **no settlement for 30 days** can drop from the catalog — plan
occasional paid traffic if you want to stay listed.

---

## Still needs Wayne

- [ ] Public HTTPS + `PUBLIC_BASE_URL` (dedicated domain preferred over tunnel hosts)
- [ ] Live CDP keys on the host (if not already)
- [ ] Tiny USDC in a **buyer** wallet (mainnet Base, or Sepolia for testnet listing)
- [ ] Run validate curl for each of 5 routes; fix any `preflight` failures
- [ ] One **settled** paid call per route; confirm `EXTENSION-RESPONSES` bazaar status
- [ ] Confirm listing on agentic.market / discovery `payTo` filter
- [ ] Optional: `iconUrl` (absolute https) if we add a public icon later
- [ ] Optional: DNS TXT `_x402` (see `docs/DISCOVERY.md`)
- [ ] Optional curation tier later (≥99% availability, live mainnet, agent-ready metadata — we already aim at metadata)

---

## Local checks (no USDC)

```bash
npm run build
curl -s http://localhost:8787/v1/discovery | jq '{name, settlement, resources: [.resources[] | {id, tags, hasBazaar: (.extensions.bazaar != null)}]}'
curl -s -X POST http://localhost:8787/v1/jobs/url-probe -H 'Content-Type: application/json' -d '{}' \
  | jq '{code, serviceName: .resource.serviceName, tags: .resource.tags, bazaar: .extensions.bazaar.info.input}'
```

Stub mode accepts any `PAYMENT-SIGNATURE` without facilitator verify — that does
**not** index Bazaar.

---

## Wayne-only blocker — Bazaar settle / indexing

Desk **cannot self-settle** Bazaar indexing without a funded buyer wallet:

1. Indexing requires a **real USDC payment on Base** that settles through the CDP facilitator with `extensions.bazaar` echoed.
2. The Desk pay-to address receives funds; it does **not** spend them. There is no operator “index me” API that skips payment.
3. **Do not invent fake settlements.** Validate (below) is free and only checks metadata shape / https resource URLs.

When ready: fund a tiny Base USDC buyer wallet, run one paid call per SKU with a client that echoes bazaar, then confirm via CDP discovery search / EXTENSION-RESPONSES.


---

## Ready-to-run (agent prepared 2026-09-28)

- Buyer address (public): [`docs/BAZAAR_BUYER_ADDRESS.txt`](./BAZAAR_BUYER_ADDRESS.txt)
- Fund steps: [`docs/BAZAAR_FUND_CHECKLIST.md`](./BAZAAR_FUND_CHECKLIST.md)
- After funding: `npm run bazaar:check` then `npm run bazaar:settle` (`scripts/bazaar-settle.mjs`)
