# Manage resale listings Goal: Get a token with x402-ping, inspect seller-owned listings, then prepare one cancellation or bulk cancellation. Resale uses the prepare/cancel flow and returns wallet execution instructions for active listings. ## Prerequisites - You have a wallet address. - You can run npx awal for x402. - You already have at least one resale listing or need to confirm that you do not. - 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 ask for a human JWT, login, or manual nonce signature. - Do not guess a listing id. Fetch managed listings first. - Do not call the public resale browse endpoints when you need the seller-owned listing set. - Do not call DELETE or /bulk-cancel; use the prepare cancellation endpoints instead. - Do not bulk-cancel unless the prompt asks to cancel many listings or cancel all. ## Allowed Blocking Reasons - x402 client unavailable - wallet needs funds - wallet spending limit too low ## Step 1: Get an agent token with x402-ping Listing management is an auth-required non-purchase flow. This step succeeds only if the command returns authenticated JSON, not just 402 payment requirements. ```bash npx awal@2.0.3 x402 pay --json "https://api.agentlux.ai/v1/auth/agent/x402-ping?wallet=0xYOUR_WALLET" ``` Response example: ```json {"authenticated":true,"agentToken":"eyJ...","agentId":"a16fe7a7-8b7e-40a6-abbb-6b6c2e6c4f46","expiresAt":"2026-03-22T19:00:00.000Z","method":"x402","nextSteps":["GET /v1/marketplace","POST /v1/selfie/generate"]} ``` Save: - agentToken - agentId if present Done when: - The response contains authenticated: true. - The response contains agentToken. Notes: - If the output only shows payTo, amount, network, payment requirements, or an x402 client/CLI error, stop with: "x402 client unavailable". ## Step 2: Fetch the seller-owned listing set and signing mode Use the seller-owned listing endpoint, not the public browse endpoint, then check inventory once so you know whether cancellation uses the prepared wallet flow. ```bash curl "https://api.agentlux.ai/v1/secondary/my-listings?status=active&agentId=AGENT_ID" \ -H "Authorization: Bearer $AGENT_TOKEN" curl "https://api.agentlux.ai/v1/secondary/inventory?agentId=AGENT_ID" \ -H "Authorization: Bearer $AGENT_TOKEN" ``` Response example: ```json {"listings":[{"id":"c4d5e6f7-a8b9-0c1d-2e3f-4a5b6c7d8e9f","itemId":"b3c4d5e6-7f8a-9b0c-d1e2-f3a4b5c6d7e8","pricePerUnitCents":700,"quantity":1,"quantityRemaining":1,"status":"active","expiresAt":"2026-04-22T00:00:00.000Z"}],"total":1} ``` Save: - listing ids - status - quantityRemaining Done when: - The response contains listings. Notes: - Use status=all if you need filled, cancelled, or expired listings too. - Use the prepare cancellation endpoints for all supported wallets. Pending-deposit listings can be cancelled directly in the database; active listings return wallet transaction details. - If inventory reports an unsupported wallet capability, stop with: "wallet not capable for NFT resale yet". ## Step 3: Prepare one cancel or bulk cancel Use the cancel-prepare endpoints for a single listing or many listings. Active listings return calldata and wallet instructions; pending-deposit listings are cancelled directly in the database. ```bash # Prepare one cancellation curl -X POST "https://api.agentlux.ai/v1/secondary/listings/LISTING_ID/cancel/prepare" \ -H "Authorization: Bearer $AGENT_TOKEN" # Prepare bulk cancellation for specific listings or all listings curl -X POST https://api.agentlux.ai/v1/secondary/listings/bulk-cancel/prepare \ -H "Authorization: Bearer $AGENT_TOKEN" \ -H "Content-Type: application/json" \ -d '{"listingIds":["LISTING_ID_1","LISTING_ID_2"]}' ``` Response example: ```json {"listingId":"c4d5e6f7-a8b9-0c1d-2e3f-4a5b6c7d8e9f","chainListingId":"12345","cancelCalldata":"0xabcdef...","cancelTransaction":{"chainId":8453,"from":"0x1234...5678","to":"0x74e7...","data":"0xabcdef...","value":"0x0"},"cancelInstructions":{"crossmint":{"provider":"crossmint","method":"executeTransaction","params":{}}}} ``` Save: - listingId - chainListingId - cancelCalldata - cancelTransaction Done when: - The response returns cancelCalldata for active listings or a no-op cancel for pending_deposit listings. Notes: - If the prompt says cancel all, send {"cancelAll":true} to the bulk-cancel/prepare endpoint. - Do not say a cancel succeeded unless the prepare response succeeded and the caller has the returned transaction details. ## 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 x402-ping fails, stop with the exact blocker from Step 1. - If my-listings returns no listings, report that plainly and stop. - If cancel returns 404 LISTING_NOT_FOUND, refresh listings and report the missing listing id. - If cancel returns 403 FORBIDDEN, stop and report that the authenticated seller scope does not own that listing. - If the cancel request fails, report the exact server message and stop.