# agentwardrobe.ai

Clothes for AI agents, paid with USDC on Base over [x402](https://x402.org). One HTTP call buys an item and puts it on.

For humans: GET /humans. Machine docs: `GET /docs`, `GET /llms.txt`, `GET /.well-known/x402`. MCP tools: `GET /api/mcp/tools`.

## 1. Buy (one call)

```
GET /api/items/{sku}/buy?wear=1
```

1. Call it with no payment header. You get `402 Payment Required` with a `PAYMENT-REQUIRED` header: price, network `eip155:8453` (Base), asset USDC, and `payTo`.
2. Retry with a `PAYMENT-SIGNATURE` header from any x402 client. The server verifies the payment, settles it on Base, then grants the item.
3. You get `200` with the purchase, the settled `x402TxHash`, and a `PAYMENT-RESPONSE` header.

Your paying wallet is your account. No signup, no API key, no quote. The first purchase creates the account and returns a `bootstrapToken` (valid 15 minutes) you can trade for an API key.

```js
import { wrapFetchWithPayment, x402Client } from '@x402/fetch';
import { registerExactEvmScheme } from '@x402/evm/exact/client';
import { privateKeyToAccount } from 'viem/accounts';

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_PRIVATE_KEY) });
const fetchWithPay = wrapFetchWithPayment(fetch, client);

const res = await fetchWithPay('https://agentwardrobe.com/api/items/nc-architect-blazer/buy?wear=1');
console.log(await res.json());
```

The wallet needs USDC on Base. No ETH is needed for gas: the facilitator submits the transfer. Want to rehearse for free? Use the Base Sepolia testnet deployment with faucet USDC from https://faucet.circle.com; see `/docs/x402`.

Bundles work the same way: `GET /api/bundles/{bundleId}/buy?wear=1`.

## 2. Find something to buy

| What | Call |
| --- | --- |
| Stores | `GET /api/stores` |
| Items in rotation | `GET /api/catalog?storeId=nordic-core&category=outerwear` |
| Penny items for testing | `GET /api/catalog?storeId=starter` |
| One item | `GET /api/catalog/{sku}` |
| Bundles | `GET /api/bundles` |

The Starter Shelf sells items from $0.01, always in rotation, for testing your first payment.

Browsing is free and needs no auth. Items rotate by season and weekday; an item out of rotation returns `404` before you are asked to pay.

## 3. Wear, swap, check

Get an API key once, using the bootstrap token from your first purchase:

```
POST /api/auth/api-keys?bootstrapToken=<token>
```

Lost the token? Sign in with your EOA wallet instead: `GET /api/auth/challenge?walletAddress=0x...`, sign the exact returned SIWE `message`, then `POST /api/auth/login` with `{ walletAddress, signature, message }`. The challenge expires in five minutes and can be used once. Browser clients must use the same allowed Origin for both calls; nonbrowser clients omit Origin on both calls. Request a new challenge after expiry or use.

Then send `X-API-Key: aw_...` on:

| Action | Call |
| --- | --- |
| Current outfit | `GET /api/wardrobe/outfit` |
| Everything you own | `GET /api/wardrobe` |
| Put on | `POST /api/wardrobe/{wardrobeId}/wear` |
| Take off | `POST /api/wardrobe/{wardrobeId}/remove` |
| Launder ($0.01, paid with x402 like a purchase) | `POST /api/wardrobe/{wardrobeId}/launder` |
| Purchase history | `GET /api/purchases/history` |

## What can go wrong

| Response | Meaning | Charged? |
| --- | --- | --- |
| `402` with `PAYMENT-REQUIRED` | No or invalid payment, or the price changed. Pay the amount in the header. | No |
| `402` "settlement failed" | The transfer did not go through (usually not enough USDC on Base). | No |
| `404` | Unknown item, or not in rotation today. | No |
| `409` "already own" | Your wallet already owns this item. | No |
| `409` "payment settled ... logged for a refund" | Rare race after payment. The operator refunds these. | Yes, refunded |
Stuck on a 402? `POST /api/x402/explain` with the header you sent and the 402 you got back; it names the exact problem.

Retrying the exact same `PAYMENT-SIGNATURE` after a dropped connection returns the original result. It never charges twice.

## Older flow (deprecated)

`POST /api/purchases/quote` followed by `POST /api/purchases/complete` still works until 2026-12-31 and returns `Deprecation` headers. New agents should use the one-call buy above.
