# REST API

Use the REST API to read and change wishlists from your own systems, such as a CRM, an ERP or a headless storefront. To build a storefront on it, start with [Headless storefronts](https://wishlist.themivo.com/docs/headless).

## Base URL

All endpoints are served from:

```text
https://wishlist-edge.themivo.com/api/v1
```

The same URL is shown on the **Developers** page under **Edge base URL**. Requests go over HTTPS only.

## Authentication

Create an API key in the app under **Developers → API keys**. The key is shown once; store it somewhere safe. Send it in the `Authorization` header:

```bash
curl https://wishlist-edge.themivo.com/api/v1/products/top \
  -H "Authorization: Bearer wl_live_…"
```

The key identifies your store, so there is no store parameter. It gives access to every shopper's wishlist, so call the API from your server only, never from a browser or an app bundle. The API doesn't send CORS headers.

Each key has one or both scopes:

| Scope | Allows |
|---|---|
| `read` | Reading wishlists, lists, items, rules, product stats and analytics |
| `write` | Adding, removing and moving items, and managing lists, sharing and invites |

You can have up to 10 keys. Revoking a key takes effect within a few minutes.

## Conventions

- Send JSON bodies. `DELETE` endpoints also accept their fields as query parameters.
- Ids are numeric Shopify ids as strings (`"7982301"`), not GIDs. List ids are the strings the API returns.
- `variantId` is `""` for a product-level item. When adding, leave it out or send `""` to save the product. When removing, leave it out to remove every variant of the product, or send `""` to remove only the product-level item.
- Times are Unix milliseconds. Prices and revenue are integers in the minor unit of the shop's currency (cents for USD).
- Mutations that change nothing answer `200` with `"changed": false`, for example adding an item that is already saved.

## Shopper endpoints

These act as one shopper, the way the storefront does. The app checks that the shopper owns the list, or collaborates on it, before reading or changing it. A list id from another shopper answers `404`.

A shopper is either a customer or a guest:

| Prefix | Shopper |
|---|---|
| `/customers/{customerId}` | A Shopify customer, by numeric id. |
| `/guests/{guestId}` | A shopper without an account, by a UUID v4 that you generate and keep, for example in a cookie. |

| Method | Path (after the prefix) | Scope | Description |
|---|---|---|---|
| `GET` | `/wishlist` | `read` | Lists and saved items, for showing buttons and counts. Supports `ETag`. |
| `GET` | `/lists` | `read` | Lists the shopper owns, each with all its items. |
| `GET` | `/products/{productId}` | `read` | Whether the product is saved, and in which lists. |
| `POST` | `/items` | `write` | Adds an item. |
| `DELETE` | `/items` | `write` | Removes an item. |
| `POST` | `/items/move` | `write` | Moves an item to another list, or changes its variant. |
| `POST` | `/lists` | `write` | Creates a list. Needs **Multiple lists**. |
| `PATCH` | `/lists/{listId}` | `write` | Renames a list. |
| `DELETE` | `/lists/{listId}` | `write` | Deletes a list and its items. The default list can't be deleted. |
| `GET` | `/lists/{listId}/items` | `read` | Items of one list, paginated. |
| `POST` | `/lists/{listId}/share` | `write` | Creates a share link, or returns the existing one. Needs **Sharing**. |
| `DELETE` | `/lists/{listId}/share` | `write` | Turns the share link off. |
| `POST` | `/lists/{listId}/invites` | `write` | Creates an invite to collaborate. Customers only; needs **Collaborators**. |
| `POST` | `/invites/{token}/accept` | `write` | Joins a list from an invite. Customers only. |
| `POST` | `/lists/{listId}/leave` | `write` | Leaves a list the customer collaborates on. |
| `POST` | `/merge` | `write` | Moves a guest's lists into a customer when they sign in. Customers only. |
| `POST` | `/customer-token` | `write` | A customer token for the [storefront script](https://wishlist.themivo.com/docs/headless#signed-in-customers) on a headless storefront. Customers only. |

Guests can save only while **Guest wishlists** is on under **Settings → Features**. When it's off, guest writes answer `401 login_required`.

### Wishlist

`GET /customers/{customerId}/wishlist` returns the lists the shopper can open and the items of the lists they own:

```json
{
  "shopperId": "c:7982301",
  "isGuest": false,
  "version": 12,
  "lists": [
    {
      "id": "l_8f2c1a",
      "name": "Wishlist",
      "isDefault": true,
      "kind": "wishlist",
      "itemCount": 2,
      "shared": false,
      "role": "owner",
      "version": 4,
      "updatedAt": 1767225600000
    }
  ],
  "items": [
    { "listId": "l_8f2c1a", "productId": "632910392", "variantId": "" },
    { "listId": "l_8f2c1a", "productId": "632910393", "variantId": "808950810" }
  ]
}
```

A shopper who never saved anything gets empty `lists` and `items`, never `404`. Lists are created the first time the shopper saves. `kind` is `wishlist` or `saved_for_later`, and `role` is `owner`, `editor` or `viewer`. Items of lists shared with the customer by someone else are read with `GET /lists/{listId}/items`.

Each response carries an `ETag`. Send it back in `If-None-Match` to get `304 Not Modified` while nothing changed.

### Lists with items

`GET /customers/{customerId}/lists` returns `{ "customerId", "lists" }`, or `{ "guestId", "lists" }` for a guest. Each list has the fields above plus `items`, the full items of that list (at most 500), newest first:

```json
{
  "listId": "l_8f2c1a",
  "productId": "632910393",
  "variantId": "808950810",
  "quantity": 1,
  "addedAt": 1767225600000,
  "addedBy": null,
  "priceAtAdd": 2499
}
```

`addedBy` is `null` when the shopper or a collaborator added the item, `"api"` for items added with `POST /lists/{listId}/items`, `"admin"` for items added from the app, and `"staff:<id>"` for items added in Shopify POS. `priceAtAdd` is the variant price when the item was saved, or `null` if it isn't known yet.

### Saved product

`GET /customers/{customerId}/products/{productId}` returns `{ "inList": true, "listIds": ["l_8f2c1a"] }`. It looks at every variant of the product.

### Add, remove and move

```bash
curl -X POST https://wishlist-edge.themivo.com/api/v1/customers/7982301/items \
  -H "Authorization: Bearer wl_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "productId": "632910393", "variantId": "808950810" }'
```

| Endpoint | Body |
|---|---|
| `POST /items` | `productId`, optional `variantId`, `quantity` (1–999, default 1) and `listId`. Without `listId`, the item goes to the default list. |
| `DELETE /items` | `productId`, optional `variantId` and `listId`. Without `listId`, the item is removed from every list the shopper owns. |
| `POST /items/move` | `productId`, optional `variantId`, `fromListId` and `toListId`. Optional `toVariantId` saves the item as that variant instead, for example when the shopper picks a size; `toListId` can then be the same list. |
| `POST /lists` | `name` (1–80 characters), optional `kind`. |
| `PATCH /lists/{listId}` | `name`. |
| `POST /merge` | `guestId`. |

They return `{ "changed": true, "state": { … } }`, where `state` is the shopper's wishlist after the change, in the same shape as `GET /wishlist`. A new item answers `201`. `POST /lists` answers `201` and adds `listId`. `POST /merge` returns only the customer's wishlist.

`changed` is `false` when nothing changed, for example when the item was already removed. Each shop's wishlist makes one change at a time, so when two requests remove the same item, only one gets `true`. Use that as a claim: to move an item from Save for later to the cart, remove it first and add it to the cart only when `changed` is `true`. There's no idempotency key. See [Headless storefronts](https://wishlist.themivo.com/docs/headless#add-to-cart-and-orders) for an example.

When a guest signs in, call `POST /customers/{customerId}/merge` with their guest id. Items they had saved join the customer's lists, and duplicates are dropped. Merging a guest id that has nothing saved does nothing.

### Sharing and invites

`POST /lists/{listId}/share` returns `{ "token", "url" }`. `url` points to the wishlist page of your Online Store. On a headless storefront, build your own link with `token` and read the list with `GET /shared/{token}`.

`POST /lists/{listId}/invites` returns `{ "token", "expiresAt" }`. The invite works for 7 days. Send the link to the person you invite; when they open it signed in, call `POST /customers/{theirId}/invites/{token}/accept`. An invalid or expired invite answers `404`.

### Customer tokens

`POST /customers/{customerId}/customer-token` returns `{ "token", "expiresAt" }`. Put `token` on the headless storefront script as `data-customer-token`: the script then acts as that customer, the way the Online Store does for a signed-in customer. The optional body `{ "expiresIn": 86400 }` sets the lifetime in seconds, from 300 (5 minutes) to 604800 (7 days); the default is 1 day. A token works only for your shop, and revoking the key that minted it ends it within 5 minutes. Mint it on your server only, for the customer who is signed in.

## Store endpoints

These read or change data across the store, for back-office systems.

| Method | Path | Scope | Description |
|---|---|---|---|
| `GET` | `/lists/{listId}/items` | `read` | Items of any list, paginated. |
| `POST` | `/lists/{listId}/items` | `write` | Adds an item to any list: `productId`, optional `variantId` and `quantity`. The item shows as added by `api`. |
| `DELETE` | `/lists/{listId}/items` | `write` | Removes an item from any list: `productId`, optional `variantId`. |
| `GET` | `/shared/{token}` | `read` | A shared list: `{ "list": { "id", "name", "itemCount", "ownerFirstName" }, "items": { "items", "nextCursor" } }`. |
| `GET` | `/rules` | `read` | Products covered by hide rules: `{ "hideButton": [...], "hidePrice": [...] }`. |
| `GET` | `/products/top` | `read` | Most saved products, paginated. Optional `from` and `to`. |
| `GET` | `/products/{productId}/stats` | `read` | Stats for one product. Optional `from` and `to`. |
| `GET` | `/analytics/summary` | `read` | Totals for a date range. Optional `from` and `to`. |

Use `/customers/{customerId}/lists` to find a customer's list ids.

Dates are `YYYY-MM-DD` in UTC, and both ends are included. Without `from` and `to`, the range is the last 30 days ending today. With only `from`, it ends today; with only `to`, it covers that one day. `count` is always the current number of saves, whatever the range.

- `GET /products/top` returns a page of products with `productId`, `count` (current saves), `adds`, `removes`, `addToCart`, `orders` and `revenue`.
- `GET /products/{productId}/stats` returns the same fields for one product plus a daily `series`.
- `GET /analytics/summary` returns `from`, `to`, `adds`, `removes`, `addToCart`, `orders`, `revenue`, `customers` and `guests`.

## Pagination

Paginated endpoints take `limit` (1–250, default 50) and the `nextCursor` from the previous response as `cursor`.

```http
GET /api/v1/products/top?limit=100&cursor=eyJ… HTTP/1.1
```

```json
{
  "items": [],
  "nextCursor": null
}
```

`nextCursor` is `null` on the last page.

## Errors

Every error uses the same shape, with an HTTP status that matches the code:

```json
{
  "error": {
    "code": "not_found",
    "message": "List not found"
  }
}
```

| Code | Status | Meaning |
|---|---|---|
| `bad_request` | 400 | The request body, query or an id is invalid. |
| `unauthorized` | 401 | The key is missing, invalid or revoked. |
| `login_required` | 401 | Guests can't do this: guest wishlists are off, or the action needs a customer. |
| `forbidden` | 403 | The key doesn't have the required scope, the shopper can't change this list, or a hide wishlist button rule covers the product. |
| `feature_disabled` | 403 | The feature is off under **Settings → Features**, such as multiple lists, sharing or collaborators. |
| `not_found` | 404 | The resource doesn't exist, or the shopper can't open it. |
| `conflict` | 409 | The change conflicts with the current state. |
| `limit_reached` | 422 | A limit was reached, such as 500 items per list or 20 lists per shopper. |
| `rate_limited` | 429 | Too many requests. Retry after the number of seconds in the `Retry-After` header. |
| `internal` | 500 | Something went wrong on our side. |

## Rate limits

| Endpoints | Limit |
|---|---|
| Shopper endpoints | 60 requests per 10 seconds for each shopper, and 2,000 per 10 seconds for each key |
| Store endpoints | 100 requests per 10 seconds for each key |

Limits are counted per Cloudflare location, so treat them as approximate.

## Versioning

The version is part of the path (`/v1`). Breaking changes ship as a new version. New fields and endpoints can be added to `v1`; ignore fields you don't use.
