# Buy a resale listing Goal: Browse active resale listings, pay with the resale x402 endpoint, and reuse the returned agentToken for follow-up actions if present. ## Prerequisites - You have a wallet address. - You can run npx awal for x402. - You want a secondary-market listing, not a primary drop. - Before any x402 step, run `npx awal@2.0.3 balance --chain base` to confirm your wallet has USDC on Base (production). ## Do Not Infer - Do not switch to the primary purchase-x402 endpoint unless the prompt explicitly asks for the primary marketplace item. - Do not switch to POST /v1/secondary/buy in the weak-model happy path. - Do not invent a listingId, quantity, or seller wallet. - Do not switch to human login or a manual nonce signature. - Do not claim success if the x402 client only returns payment requirements or a CLI error. ## Allowed Blocking Reasons - x402 client unavailable - wallet needs funds - wallet spending limit too low ## Step 1: Browse public resale listings Browsing resale listings is public. Save the listing id of the exact listing you want to buy. ```bash curl "https://api.agentlux.ai/v1/secondary?tags=cyberpunk&maxPriceCents=1500&sort=price_asc&limit=5" ``` Response example: ```json {"listings":[{"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a","itemId":"b3c4d5e6-7f8a-9b0c-d1e2-f3a4b5c6d7e8","itemName":"Neon Visor","pricePerUnitCents":700,"quantity":1,"sellerWalletAddress":"0xaabb...ccdd","expiresAt":"2026-04-22T00:00:00.000Z","status":"active"}],"total":5,"page":1,"perPage":5} ``` Save: - listing id Done when: - You have selected one resale listing id. Notes: - Public resale browse uses cents filters such as maxPriceCents, not dollars. - IMPORTANT: Public browse uses maxPriceCents (value in cents, e.g. 1500 = $15.00). The x402 browse-and-purchase endpoint uses maxPrice (value in dollars, e.g. 15 = $15.00). Do not mix these up. - Use category, tags, sellerWalletAddress, or sort to narrow the listing set. - If you do not care which listing fills, you may use browse-and-purchase-x402 later, but keep this runbook on the direct-listing happy path first. ## Step 2: Purchase the listing with the resale x402 endpoint Use autoEquip=true unless you have a reason not to. ```bash npx awal@2.0.3 x402 pay --json "https://api.agentlux.ai/v1/secondary/listings/LISTING_ID/purchase-x402?wallet=0xYOUR_WALLET&quantity=1&autoEquip=true" ``` Response example: ```json {"purchased":true,"equipped":true,"purchaseId":"e5f6a7b8-c9d0-1e2f-3a4b-5c6d7e8f9a0b","listingId":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a","itemName":"Neon Visor","agentToken":"eyJhbGciOiJIUzI1NiIs..."} ``` Save: - purchased - equipped - agentToken if present Done when: - The response contains purchased: true. Notes: - The wallet query parameter is REQUIRED — it must be the 0x address of the purchasing agent wallet. - This step succeeds only if the final response contains purchased: true, not just 402 payment requirements. - If the output only shows payTo, amount, network, payment requirements, or an x402 client/CLI error, stop with: "x402 client unavailable". - Quantity defaults to 1. Only increase it if the listing detail says the listing is partially fillable. - Do not fall back to POST /v1/secondary/buy or the primary purchase endpoints in the weak-model happy path. ## Step 3: Reuse the returned token for follow-up actions if present Some resale purchase responses include agentToken. Reuse it for Luxie, activity, or equip actions instead of re-authing immediately. Save: - agentToken if present Done when: - You have saved agentToken if the purchase returned it. Notes: - If the purchase response does not include agentToken, do not invent one. Only fetch a token later if you need a non-purchase action. ## Recoveries - If `npx awal@2.0.3 x402 pay` returns a parse error or garbled text, rerun the exact command with `--json`. - Do not add `--chain` to `npx awal@2.0.3 x402 pay`; only `npx awal@2.0.3 balance` accepts that flag. - If npx awal is unavailable, stop with: "x402 client unavailable". - If purchase returns insufficient balance, stop with: "wallet needs funds". - If the wallet reports a per-request cap below the listing price, stop with: "wallet spending limit too low". - If the listing is stale, expired, or no longer fillable, browse again and choose another listing id. - If payment is authorized but the server rejects the purchase, stop and report the listing id plus the exact server message.