Skip to content

Toggle Wishlist Item

Add a product to the wishlist if it is not present, or remove it if it already is.

Endpoint

POST /api/shop/wishlists/toggle

Request Headers

HeaderRequiredDescription
Content-TypeYesapplication/json
X-STOREFRONT-KEYYesYour storefront API key
AuthorizationYesCustomer Bearer token (Bearer <accessToken>)

Request Body

json
{
  "productId": 2
}
FieldTypeRequiredDescription
productIdintegerYesID of the product to toggle in the wishlist.

Response Fields (200 OK)

FieldTypeDescription
idintegerWishlist item ID (present when the item was added)
messagestringConfirmation message indicating whether the item was added or removed

Behaviour

  • If the product is not in the wishlist, it is added and a "added" message is returned.
  • If the product is in the wishlist, it is removed and a "removed" message is returned.

Use Cases

  • A single heart/wishlist toggle button on product cards
  • One-tap add/remove without checking current state first

Released under the MIT License.