Skip to main content

Hello, I am new to Klaviyo and I would like to make a back in stock API call out of my Shopify store, like explained here. I do not understand the error: is my products do not have a variant, only a product ID. And maybe I miss understood the concept of a relationship. I thought I am creating one by assigning a product to a profile by this query. Maybe someone can help me.

# URL
url = "https://a.klaviyo.com/client/back-in-stock-subscriptions/?company_id=myID"

# Body
body = {
"data": {
"type": "back-in-stock-subscription",
"attributes": {
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": "email@mail.com"
}
}
},
"channels": ""EMAIL"]
},
"relationships": {
"product": {
"data": {
"type": "catalog-variant",
"id": "$shopify:::$default:::productID"
}
}
}
}
}

 

I get the error code:

Response Text: {"errors":r{"id":"dfae79b0-0dd5-46e4-9b3c-7906e4ed4280","status":404,"code":"variant_not_found","title":"The variant in your relationship payload does not exist","detail":"The variant in your relationship payload does not exist","source":{"pointer":"/data/relationships/variant/data/id"},"links":{},"meta":{}}]}

@ITgirl I am SO sorry for the late reply here. You post was mistakenly flagged as spam by our system. I’m investigating why further. 

In the meantime, did you get this figured out?


Hello @kaila.lawrence,

no problem. No, not yet.


Hey @ITgirl, the error you’re getting is because you’re using the product ID instead of the variant ID. I believe even in the case where you don’t have multiple variants configured for Shopify there is a default variant ID that can be obtained. 

We have a recommended way to install Back in Stock using a JS widget detailed on our Help Center here: https://help.klaviyo.com/hc/en-us/articles/360001895651.This way, Klaviyo.js handles some of the heavy lifting around determining the variant ID, whether the item is in stock or out of stock and what the variant ID is.
 

If you’re trying to wire this up yourself using the client API directly….

const variantId = document.querySelector('uname="id"]').value


Thank you, that helped!


Reply