# Etsy orders with your own AI agent

Printed in the USA. This is a playbook you can paste into your own AI agent (ChatGPT, Claude, Grok, Cursor, anything that can use a browser or the Etsy API and make web requests).

**How it works.** Your agent works for you, inside your own Etsy account, where Etsy shows you your buyers' addresses. It sends each new order to Madely. When the order ships, it copies the tracking back into Etsy. Madely never logs into Etsy and never sees your Etsy password or keys.

**Rules for your agent.** It acts as you, the seller, in your own account. It follows Etsy's terms, API rules and rate limits. It does not share your Etsy login or keys with Madely or anyone else. It does not buy or message buyers on its own. If Etsy asks for a sign-in, a code or a captcha, it stops and asks you.

## One-time setup (about two minutes)

1. Get an API key: `POST https://api.madely.ai/v1/sandbox/keys` (v0 is a sandbox: test orders only, so use order ids that start with `madely-smoketest-`).
2. Create your store: `POST /v1/stores` with `{"platform":"etsy","name":"My Etsy shop"}`. Save `id` (starts with `mst_`).
3. Send your listings so Madely can match them to blanks: `POST /v1/stores/{store_id}/products` (Shopify-style: `id` = Etsy listing id, `variants[]` with `id`, `sku`, `option1`, `option2`). Confirm the matches and pin a design to each variant. Only confirmed variants with a passing print file ever print.

## The loop (every 15 minutes)

Copy this into your agent:

```
You are my assistant for my Etsy shop, and you act only as me in my own Etsy account.
Follow Etsy's terms and rate limits. Never share my Etsy login or keys. Every 15 minutes:

1. NEW ORDERS. In my Etsy account, list paid orders that are not shipped and that you
   have not sent yet. For each one, POST https://api.madely.ai/v1/orders
   Authorization: Bearer <MADELY_KEY>
   {
     "source": "etsy",
     "store_id": "<mst_...>",
     "external_order_id": "<Etsy receipt id>",
     "items": [ { "listing_id": "<id>", "sku": "<sku>", "quantity": 1,
                  "variations": "Color:Black, Size:M" } ],
     "ship_to": { "name": "...", "line1": "...", "line2": "...", "city": "...",
                  "state": "..", "zip": "...", "country": "US" },
     "gift_message": "<only if the buyer left one>"
   }
   Sending the same order again is safe: it returns the same order and re-checks it.
2. HOLDS. If the answer says "status": "on_hold", tell me the plain-English "holds_summary"
   once. Do not retry until I say it is fixed.
3. TRACKING. GET https://api.madely.ai/v1/orders?source=etsy&status=shipped
   This lists only shipments I have not synced yet.
4. MARK SHIPPED IN ETSY. For each one, in my Etsy account, mark the receipt as shipped with
   the "etsy_carrier_name" and "tracking_number" from Madely (use "other" plus the
   "carrier" text if Etsy does not list the carrier).
5. ACK. Only after Etsy accepted it: POST https://api.madely.ai/v1/orders/{order_id}/tracking/ack
   It then stops appearing in the feed. If Etsy refused, do not ack; tell me.
```

## What comes back

```json
{ "order_id": "eto_...", "status": "ready_for_production", "holds": [], "holds_summary": null,
  "next_step": "Nothing to do yet. Check GET /v1/orders?source=etsy&status=shipped for tracking." }
```

Statuses: `on_hold` (needs you), `ready_for_production`, `shipped`, `cancelled`, `ignored` (none of the lines are ours). A hold always says what is wrong in plain English, for example "No design is attached to "Funny Tee"." or "We ship to the United States only for now."

## Tracking

- Feed: `GET /v1/orders?source=etsy&status=shipped&since=<next_since from last call>` (add `include_acknowledged=true` to see everything).
- One order: `GET /v1/orders/{order_id}/tracking` returns `carrier`, `etsy_carrier_name`, `tracking_number`, `tracking_url`, `shipped_at`, `acknowledged`.
- Ack: `POST /v1/orders/{order_id}/tracking/ack` (safe to repeat).
- Optional push: `PUT /v1/stores/{store_id}/webhook` with `{"url":"https://..."}` gets `order.shipped` events carrying the same fields. Check the `Madely-Signature` header (HMAC-SHA256 of `t.body` with the signing secret shown once). Polling always works too.

## No agent? Use the CSV

1. In Etsy: Shop Manager, Settings, Options, Download Data, **Order Items**. 
2. `POST /v1/stores/{store_id}/etsy/orders-csv` with `{"csv":"<file contents>"}`. Upload the same file twice and nothing is duplicated.
3. When orders ship: `GET /v1/stores/{store_id}/etsy/tracking.csv` and add the tracking in Etsy, one order at a time.

Errors are plain English with a `fix`. Full reference: `/openapi.json` and `/llms-full.txt`.
