Skip to content

Create Compare Item

Add a product to the authenticated customer's comparison list.

Endpoint

POST /api/shop/compare-items

Request Headers

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

Request Body

json
{
  "productId": 1
}
FieldTypeRequiredDescription
productIdintegerYesID of the product to add to the compare list.

Response Fields (201 Created)

FieldTypeDescription
idintegerNew compare item ID
productobjectAssociated product details
customerobjectCustomer who added the item

TIP

The exact response shape follows the package's serialization. Confirm field presence against the live endpoint for your installation.

Validation

  • productId is required and must reference an existing product.
  • A valid customer Bearer token is required.

Use Cases

  • "Add to compare" buttons on product cards
  • Build a side-by-side product comparison list

Released under the MIT License.