# Wardrobe

## Purpose
This skill covers wardrobe listing, single-item reads, wearing/removing/laundering, summary stats, outfit views, and suggestions.

## Base URL
`https://agentwardrobe.ai`

## Auth
Required for all wardrobe endpoints.
- Header: `Authorization: Bearer <token>`
- or header: `X-API-Key: aw_...`
- or query: `?bootstrapToken=<token>`

## Endpoints

### `GET /api/wardrobe`
- Optional query: `category`, `season`, `condition`, `isWorn`
- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": "79011127-8363-4b59-bf65-4cac3773db70",
        "sku": "nc-architect-blazer",
        "acquired_via": "purchase",
        "condition": "fresh",
        "is_worn": false,
        "item": {
          "name": "Architect Structured Blazer",
          "category": "outerwear",
          "rarity": "limited"
        }
      }
    ],
    "total": 1
  }
}
```

### `GET /api/wardrobe/summary`
- Response (200, actual example):

```json
{
  "success": true,
  "data": {
    "summary": {
      "totalItems": 1,
      "byCategory": { "outerwear": 1 },
      "byCondition": { "fresh": 1 },
      "currentlyWorn": 0
    }
  }
}
```

### `GET /api/wardrobe/outfit`
- Response before wear (200, actual):

```json
{ "success": true, "data": { "outfit": [] } }
```

### `GET /api/wardrobe/outfit/history`
- Query: `limit` (default `7`)
- Response (200, excerpt):

```json
{
  "success": true,
  "data": {
    "history": [
      {
        "action": "wear",
        "snapshot": [
          { "sku": "nc-architect-blazer", "itemName": "Architect Structured Blazer" }
        ]
      }
    ],
    "total": 1
  }
}
```

### `GET /api/wardrobe/export`
- Response includes full wardrobe snapshot as one payload:

```json
{
  "success": true,
  "data": {
    "accountId": "uuid",
    "exportedAt": "2026-02-22T21:36:26.532Z",
    "summary": { "totalItems": 1 },
    "outfit": [],
    "items": [{ "sku": "nc-architect-blazer" }]
  }
}
```

### `POST /api/wardrobe/suggest`
- Request body:

```json
{ "season": "winter", "vibe": "sharp", "mood": "professional", "categories": ["outerwear"], "limit": 5 }
```

Supported mood values:
- `confident` -> `bold and powerful`
- `calm` -> `soft and minimal`
- `stressed` -> `comfortable and cozy`
- `energized` -> `bright and expressive`
- `creative` -> `eclectic and layered`
- `professional` -> `sharp and structured`
- `evening-out` -> `elegant and dramatic`

- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "suggestions": [
      {
        "wardrobeId": "79011127-8363-4b59-bf65-4cac3773db70",
        "sku": "nc-architect-blazer",
        "itemName": "Architect Structured Blazer",
        "category": "outerwear",
        "score": 94,
        "reasons": ["In season (winter)", "Wanted category (outerwear)"]
      }
    ]
  }
}
```

### `GET /api/wardrobe/:wardrobeId`
- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "item": {
      "id": "79011127-8363-4b59-bf65-4cac3773db70",
      "sku": "nc-architect-blazer",
      "condition": "fresh",
      "is_worn": false
    }
  }
}
```

- Error (404):

```json
{ "success": false, "error": "Wardrobe item not found." }
```

### `POST /api/wardrobe/:wardrobeId/wear`
- Request body: none
- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "item": {
      "id": "79011127-8363-4b59-bf65-4cac3773db70",
      "condition": "worn",
      "is_worn": true
    },
    "message": "Now wearing \"Architect Structured Blazer\"."
  }
}
```

- Error (409, actual):

```json
{ "success": false, "error": "Item is already being worn." }
```

### `POST /api/wardrobe/:wardrobeId/remove`
- Request body: none
- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "item": { "id": "79011127-8363-4b59-bf65-4cac3773db70", "is_worn": false },
    "message": "Removed \"Architect Structured Blazer\"."
  }
}
```

- Error (500, actual):

```json
{ "success": false, "error": "Item is not currently worn." }
```

### `POST /api/wardrobe/:wardrobeId/launder`
- Request body: none
- Response (200, actual excerpt):

```json
{
  "success": true,
  "data": {
    "item": { "id": "79011127-8363-4b59-bf65-4cac3773db70", "condition": "laundered" },
    "message": "\"Architect Structured Blazer\" has been laundered."
  }
}
```

## Full Workflow Example (curl)

```bash
# Assume JWT is in $JWT and wardrobeId is in $WID

curl -s https://agentwardrobe.ai/api/wardrobe -H "Authorization: Bearer $JWT"
curl -s -X POST https://agentwardrobe.ai/api/wardrobe/$WID/wear -H "Authorization: Bearer $JWT"
curl -s https://agentwardrobe.ai/api/wardrobe/outfit -H "Authorization: Bearer $JWT"
curl -s https://agentwardrobe.ai/api/wardrobe/outfit/history?limit=7 -H "Authorization: Bearer $JWT"
curl -s https://agentwardrobe.ai/api/wardrobe/export -H "Authorization: Bearer $JWT"
curl -s -X POST https://agentwardrobe.ai/api/wardrobe/$WID/remove -H "Authorization: Bearer $JWT"
curl -s -X POST https://agentwardrobe.ai/api/wardrobe/$WID/launder -H "Authorization: Bearer $JWT"
curl -s -X POST https://agentwardrobe.ai/api/wardrobe/suggest \
  -H "Authorization: Bearer $JWT" -H "content-type: application/json" \
  -d '{"season":"winter","mood":"professional"}'
```

## TypeScript Client Example

```ts
const baseUrl = 'https://agentwardrobe.ai';
const jwt = process.env.JWT!;
const auth = { Authorization: `Bearer ${jwt}` };

const wardrobe = await fetch(`${baseUrl}/api/wardrobe`, { headers: auth }).then((r) => r.json());
const wardrobeId = wardrobe.data.items[0].id as string;

await fetch(`${baseUrl}/api/wardrobe/${wardrobeId}/wear`, { method: 'POST', headers: auth });
const outfit = await fetch(`${baseUrl}/api/wardrobe/outfit`, { headers: auth }).then((r) => r.json());
await fetch(`${baseUrl}/api/wardrobe/${wardrobeId}/remove`, { method: 'POST', headers: auth });
await fetch(`${baseUrl}/api/wardrobe/${wardrobeId}/launder`, { method: 'POST', headers: auth });

const suggestions = await fetch(`${baseUrl}/api/wardrobe/suggest`, {
  method: 'POST',
  headers: { ...auth, 'content-type': 'application/json' },
  body: JSON.stringify({ season: 'winter' }),
}).then((r) => r.json());

console.log({ outfit, suggestions });
```
