Skip to main content
The swish.api namespace provides a typed client for the Swish REST API. It handles authentication, caching, and request batching automatically. All methods return promises that resolve to an ApiResponse or PaginatedApiResponse.

Response types

ApiResponse

A discriminated union — a response contains either data or error, never both.
Use "error" in response to narrow the type:

PaginatedApiResponse

The PageInfo object contains:
When no customer profile exists (e.g. a guest visitor), list methods return empty arrays and find methods return null instead of throwing.

Query parameters

List methods accept an optional query object for pagination and filtering. Every list method supports these shared parameters: Some methods accept additional filters, documented alongside each method below.

Items

items.list(query?)

List saved items. In addition to the shared page and limit, the query object accepts:
Returns PaginatedApiResponse<Item>. Saved items carry only Shopify IDs (productId/variantId), not product details like title, price, or images. To render them — for a custom wishlist page, say — enrich each item with Shopify product data using swish.storefront.loadResolvedProduct. You can pass an item straight through; it reads productId/variantId and ignores the rest. Fire the calls concurrently with Promise.all, not in a sequential for loop. Products are cached per product, and concurrent cache-miss fetches are coalesced into batched Storefront requests — so a parallel map doesn’t pay one request per item, while a sequential loop would. Keep each item alongside its resolved product so you still have item.id (to unsave), item.quantity, and other fields when rendering:

items.findById(itemId)

Find a saved item by ID. Returns ApiResponse<ItemDetail>.

items.count()

Get the total number of saved items.
Returns ApiResponse<{ count: number }>.

items.create(item)

Save a product as a new item. The CreateItem object accepts:
Returns ApiResponse<Item>.

items.updateById(itemId, body)

Update a saved item. The UpdateItem object accepts productId, variantId, and quantity, all optional.
Returns ApiResponse<Item>.

items.deleteById(itemId)

Delete a single saved item. Returns ApiResponse<Item> containing the deleted item.

items.delete(itemIds)

Delete multiple saved items in one request.
Returns ApiResponse<Item[]> containing the deleted items.

items.setListsById(itemId, listIds)

Set which lists an item belongs to, replacing any previous list assignments.
Returns ApiResponse<ItemDetail>.

Lists

lists.list(query?)

List all lists. In addition to the shared page and limit, the query object accepts:
Returns PaginatedApiResponse<ListDetail>.

lists.findById(listId)

Find a list by ID. Returns ApiResponse<ListDetail>.

lists.create(list)

Create a new list, optionally with items. The CreateList object accepts:
Returns ApiResponse<List>.

lists.updateById(listId, body)

Update a list’s name or access level. The UpdateList object accepts:
Returns ApiResponse<List>.

lists.deleteById(listId)

Delete a list. Returns ApiResponse<List> containing the deleted list.

lists.addItemsToList(listId, itemIds)

Add existing items to a list by their IDs.
Returns ApiResponse<ListDetail>.

lists.removeItemFromList(listId, itemId)

Remove an item from a list without deleting the item itself. Returns ApiResponse<void>.

lists.orderItems(listId, itemIds)

Set the order of items within a list.
Returns ApiResponse<List>.

Orders

orders.list(query?)

List orders. Returns PaginatedApiResponse<Order>.

orders.findById(orderId)

Find an order by ID. Returns ApiResponse<OrderDetail>.

Notifications

Notification methods require a signed-in customer. They return empty results for guest visitors.

notifications.list(query?)

List notifications. In addition to the shared page and limit, the query object accepts: Returns PaginatedApiResponse<Notification>.

notifications.getUnreadCount()

Get the number of unread notifications.
Returns ApiResponse<{ count: number }>.

notifications.markAsRead(notificationIds)

Mark specific notifications as read.

notifications.markAllAsRead()

Mark all notifications as read.

notifications.deleteById(id)

Delete a notification.

Smart lists

Smart lists are system-managed lists like “Recently viewed”.

smartLists.list()

List all smart lists.
Returns ApiResponse<ListDetail[]>.

smartLists.findById(smartListId)

Find a smart list by ID.
Smart lists ("recently-viewed" and "saved-from-cart") do not require a customer profile.
Returns ApiResponse<ListDetail>.

smartLists.findItems(smartListId, query?)

List items in a smart list. Returns PaginatedApiResponse<Item>.

smartLists.removeItem(smartListId, itemId)

Remove an item from a smart list.
Returns ApiResponse<Item> containing the removed item.

Profiles

Profile methods require a signed-in customer. getProfile returns null for guest visitors.

profiles.getProfile()

Get the current customer’s profile.
Returns ApiResponse<Profile>.

profiles.updateProfile(body)

Update the current customer’s profile. The UpdateProfile object accepts:

Subscriptions

Back-in-stock subscriptions: a shopper asks to hear when a sold-out variant returns.
create works for guest visitors — the SDK issues a session token before the request, so a shopper who has never signed in can still subscribe. The reads need a profile, which the first write mints, and return empty until then.
Subscriptions are variant-level: both productId and variantId are required, and there is no product-wide subscription.

subscriptions.list(query?)

List the current shopper’s subscriptions. In addition to the shared page and limit, the query object accepts: Returns PaginatedApiResponse<Subscription>.

subscriptions.create(body)

Subscribe a contact to a variant.
Returns ApiResponse<Subscription>.

subscriptions.findById(id)

Get one subscription. Returns ApiResponse<Subscription>.

subscriptions.updateById(id, body)

Update a subscription — most usefully to cancel it by setting status.

subscriptions.deleteById(id)

Delete a subscription.

Data types

The shapes returned by swish.api. For the exhaustive field-level schema of every response — including the deeply nested objects noted below — see the REST API reference.

Item

ItemDetail

All Item fields, plus:

List

ListDetail

All List fields, plus:

PreviewImage

Order

OrderDetail

All Order fields (except previewImages), plus: The Fulfillment and OrderLineItem shapes are large; see the REST API reference for their full fields.

Money

Notification

The NotificationProduct, NotificationVariant, and NotificationContext shapes are large; see the REST API reference for their full fields.

Profile

Address

NotificationSettings

MarketingConsent

Subscription

CreateSubscription

Authentication

setAuthToken(token)

Manually set the auth token. Useful for headless environments where you manage authentication yourself.