Set Up Back in Stock via API

Learn how to set up Klaviyo's back in stock functionality via API.

If you want to include Klaviyo's back in stock functionality in your application or custom platform, you can accomplish this by calling the Subscribe endpoint from your app. You have full control of (and responsibility for) when, where, and how the trigger button appears; the appearance, text, and behavior of the modal; and all other aspects of the feature's behavior and appearance within your application.

Once you are successfully sending back in stock events to Klaviyo, you can set up a back in stock flow to ensure that profiles who subscribe to receive back in stock emails are notified.

📘

Info

This API endpoint is only valid for Shopify integrations, BigCommerce integrations, or accounts with inventory-aware custom catalog feeds.

Your POST request from the app must include:

  1. a - Your public Klaviyo API Key
  2. email - The email address entered by the subscriber, correctly formatted and valid
  3. variant - The product's variant ID
  4. platform - The platform ID, such as shopify or bigcommerce

To subscribe a customer to a list as part of the Back In Stock workflow, you will need to make a separate, additional call to the List API.

API Call Format

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe'
--data 'a=AccountID&[email protected]&variant=5000149172256&platform=shopify'

Successful Call & Response

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe' 
--data 'a=AccountID&[email protected]&variant=44222393030&platform=shopify'
{"email": "[email protected]", "success": true}

The correct Account ID and a valid email address must be included to receive a successful response.

Errors

Invalid Email Address

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe' 
--data 'a=AccountID&[email protected]&variant=44221714950&platform=shopify'
{"errors": ["There was something wrong with your request. Please try again."], "data": {}, "success": false}

Invalid Public API Key

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe' 
--data 'a=BadKey&[email protected]&variant=44221714950&platform=shopify'
{"errors": ["There was something wrong with your request. Please try again."], "data": {}, "success": false}

Invalid Variant ID

The API does not validate variant IDs. If an invalid variant ID is included in a request, the API will return a standard success response. No event will be created for the profile and the customer will not be queued to receive a back in stock message.

Duplicate Subscription Requests

If multiple requests are submitted for the same email address on the same variant, only the first will be accepted. It is not possible to submit multiple events for a profile on the same variant.

There is no limit to the number of unique variants that a profile can subscribe to. A single person can sign up to be notified for hundreds or thousands of unique variants.

Clearing a Subscription

After an individual receives an email notifying them that a specific variant is back in stock, their existing subscription is cleared. They are then able to sign up for another subscription on that same variant.  It is not possible to have multiple concurrent subscriptions to the same variant for a single profile.

Please note that no subscribers will be notified when an item is restocked if you do not first set up a back in stock flow.


Did this page help you?