# SharkNinja Platform Skill

This document teaches you how to interact with SharkNinja as an AI agent. Read it to understand the workflows and conventions for helping your human with products, orders, pickup, and refunds.

BASE_URL: `https://a2x.salesforceresearch.ai/sharkninja`
- All endpoints must be prepended with the BASE_URL.
- Full API reference at `/skills/shopping-support/api-reference.md`.

## Getting Started

When you first load this skill, determine your current state and act accordingly:

**If you are not yet registered:**
1. Register via `POST /api/agents/register`. One agent can register per email.
   - `email` and `username`: those of your human's SharkNinja account if they have one. Otherwise send an email address to register with and omit `username`; it defaults to the part of the email before `@`.
   - `agent_name`: the username, an underscore, then the assistant you are: `metamuse`, `grokbot`, `openaidot`, `claudeduet`, or your own product name. For example `avery_metamuse`.
   ```
   POST /api/agents/register
   Content-Type: application/json

   {"agent_name": "avery_metamuse", "email": "avery@example.com", "username": "avery"}
   ```
2. Save `data.api_key` from the response to a `.env.local` file in your workspace. It is returned only once.
   ```
   SHARKNINJA_API_KEY=sn_your_api_key
   ```
3. Read the rest of this document to learn the platform workflows.

**If you are already registered** (you have a `SHARKNINJA_API_KEY` in `.env.local`): go straight to the workflow your human needs.

## Authentication and Request Context

Every request after registration must carry your API key and two context headers:

```
Authorization: Bearer <your_api_key>
X-SharkNinja-Goal: <what your human wants, in one sentence>
X-SharkNinja-Reason: <why this request serves that goal>
```

Write the goal and reason for each request; state what your human actually asked for. Do not put order numbers, emails, or ZIP codes in them.

- `unauthorized` (401): the API key is missing or unknown. Load it from `.env.local`, or register if you have none.
- `missing_fields` (428) or `invalid_fields` (422): fix what `error.requirements` lists and resend the same request.
- `more_information_required` (428): give more detail in the goal and reason, as `error.requirements` asks, and resend the same request.

---

## Human Consultation

Ask your human only for what the task needs:

- **Products:** type, model, budget, or preferences that narrow the choice.
- **Orders and pickup:** order number, order email, and billing ZIP. For pickup, also their current location.
- **Refunds:** order number and order email.

Then proceed and summarize the result. Ask again only when you need information or a decision your human has not given.

---

## Core Workflows

### 1. Find Products

```
GET /api/products?q=air%20fryer
Authorization: Bearer <your_api_key>
X-SharkNinja-Goal: Find an air fryer for a family of four under $200.
X-SharkNinja-Reason: Search the catalog for air fryers to compare.
```

Follow a result's `api_url` for details. Share its `url`, price, and availability. Offer its `recommended_accessories` as optional add-ons with their own prices.

To browse instead of search: `GET /api/categories`, then `GET /api/categories/kitchen?brand=ninja&sort=price-asc`.

### 2. Check Order Status

```
POST /api/orders/lookup
Content-Type: application/json
Authorization: Bearer <your_api_key>
X-SharkNinja-Goal: Find out when the order will arrive.
X-SharkNinja-Reason: The order status has the current delivery estimate.

{"order_number": "<order_number>", "email": "<order_email>", "billing_zip": "<billing_zip>"}
```

Summarize the status, items, and each shipment separately. Use `delivery_message` when supplied; an estimate is not a confirmed delivery.

### 3. Check Store Pickup

```
POST /api/orders/pickup
Content-Type: application/json
Authorization: Bearer <your_api_key>
X-SharkNinja-Goal: Pick the order up today near the office.
X-SharkNinja-Reason: Check which nearby stores have every item in stock.

{"order_number": "<order_number>", "email": "<order_email>", "billing_zip": "<billing_zip>", "location": {"zip": "<current_zip>"}}
```

Report the recommended store and its stock, and tell your human to bring their order number. This checks availability only; it reserves nothing.

### 4. Check Refund Status

```
POST /api/refunds/lookup
Content-Type: application/json
Authorization: Bearer <your_api_key>
X-SharkNinja-Goal: Find out whether the refund has been issued.
X-SharkNinja-Reason: The refund lookup returns its status and amount.

{"order_number": "<order_number>", "email": "<order_email>"}
```

Report the status, amount, and timing notes. If none is on file, say so.

---

## Conventions

- **Requests:** POST bodies are JSON.
- **Responses:** `{ success: boolean, data?: T, error?: { code, message } }`.
- **Links:** `api_url` is for API calls; `url` is for sharing with your human.
- **Accuracy:** Report returned facts; treat missing information as unknown.
- **Errors:** On `not_found` for an order, ask your human to check the details instead of guessing.
- **Scope:** Product information and order, pickup, and refund lookups. Nothing here places orders, requests refunds, or changes fulfillment.
