Klaviyo's track API with POST method returns 0

  • 14 September 2021
  • 12 replies

Badge +2

here is the payload:

{"token":"public or private key used here","event":"Order Confirmation","customer_properties":{"$email":"","$first_name":"test","$last_name":"test","$phone_number":"1234567890","$address1":"00 abcd, Suite 200","$city":"Forest city","$zip":"94545","$region":"CA","$country":"US","Email Last Acquired Source":"00-000013","Email Last Acquired Date":"2021-09-14 09:41:37"},"properties":{"$event_id":"388948924","$value":"323.01","OrderId":"3000470847612","OrderedDate":"2021-07-26T03:25:33","PaymentTerm":"Credit Card","ProductSubTotal":"294.98","EstimatedTax":"28.03","ShippingTotal":"0.0","OrderTotal":"323.01","DiscountTotal":"0.0","Domain":"","CurrencyISOCode":"USD","CountryISOCode":"US","Items":[{"LineId":"334987274","ProductID":"1871616","SKU":"12377756A","ProductName":"Doctor Maria Montessori","ItemDisplayedType":"Premium Giclee Print","Quantity":"1","UnitCharge":"157.99","Discount":"0","OriginalPrice":"157.99","SellingPrice":"157.99","ItemType":"POD","UnitOfMeasure":"INC","Height":"12","Width":"16","ServiceType":"Frame","ServiceAttributes":{"GlassName":"Acrylic: Clear","Mats":[{"Position":1,"MatName":"Crisp - Bright White"}],"Moldings":[{"Position":"1","MoldingName":"ALLEGRO Silver Wide","SideLengths":{"Top":"18","Right":"22","Bottom":"18","Left":"22"}}],"Liners":[]},"TimeToShip":{"WebsitePromisedTimeToShipDays":"4","WebsitePromisedTimeToShipDate":"2021-08-05T03:24:56","EstimatedShipDate":"2021-08-09T23:59:00","ArrivalByDateMin":"2021-09-18T09:41:36","ArrivalByDateMax":"2021-09-18T09:41:36"},"PrintSize":"12x16","ProductImageURL":"","ImageId":"1743359","PODConfigId":"4986478","PhysicalDimensionWidth":"16","PhysicalDimensionHeight":"12","PhysicalDimensionUnit":"INC"},{"LineId":"334987273","ProductID":"6804869","SKU":"4123616437A","ProductName":"Montessori School","ItemDisplayedType":"Giclee Print","Quantity":"1","UnitCharge":"136.99","Discount":"0","OriginalPrice":"136.99","SellingPrice":"136.99","ItemType":"POD","UnitOfMeasure":"INC","Height":"18","Width":"12","ServiceType":"Frame","ServiceAttributes":{"GlassName":"Acrylic: Clear","Mats":[{"Position":1,"MatName":"Crisp - Bright White"}],"Moldings":[{"Position":"1","MoldingName":"GRAMERCY Black","SideLengths":{"Top":"24","Right":"18","Bottom":"24","Left":"18"}}],"Liners":[]},"TimeToShip":{"WebsitePromisedTimeToShipDays":"4","WebsitePromisedTimeToShipDate":"2021-08-05T03:24:56","EstimatedShipDate":"2021-08-09T23:59:00","ArrivalByDateMin":"2021-08-13T05:17:13","ArrivalByDateMax":"2021-08-13T05:17:13"},"PrintSize":"12x18","ProductImageURL":"","ImageId":"4755636","PODConfigId":"9436042","PhysicalDimensionWidth":"12","PhysicalDimensionHeight":"18","PhysicalDimensionUnit":"INC"}],"BillingAddress":{"FirstName":"Steven","LastName":"Gaudino","Address1":"10 Orchard, Suite 200","City":"Lake Forest","State":"CA","Country":"United States","CountryCode":"US","ZipCode":"92630","Phone":"7134092597"},"ShippingAddress":{"FirstName":"Guidepost","LastName":"Leavenworth","Address1":"571 Metropolitan Ave","City":"Leavenworth","State":"KS","Country":"United States","CountryCode":"US","ZipCode":"66048","Phone":"9132971476"},"Email":"","ShippingPriority":"Standard","CreditCard":{"Type":"MC","Token":"RTA","AccountIdentifier":"0965","ExpirationMonth":"09","ExpirationYear":"2023","AccountName":"Steven Gaudino"}}}


Best answer by cbarley 16 September 2021, 23:34

View original

12 replies

Badge +2
  1. Used public key still the same problem
  2. data is application/x-www-form-urlencoded
Badge +2

Are there any tools given by klaviyo to validate the payload, coz the response 0 doesn’t say what exactly the problem with the payload.

Userlevel 7
Badge +60

Hello @lbaskar,

Thanks for sharing your question with the Klaviyo Community!

An API response of 0 is returned if the payload is not processed. This can be caused by a number of reasons. For example, a 0 response can be caused by having missing/invalid email, missing/invalid public key, malformed base64 string, malformed JSON, etc. 

At present, there aren’t any tools provided by Klaviyo to validate the payload and it’s structure. In lieu of such a tool, I would suggest working with a developer or finding and working with a Klaviyo Partner from the Partners Directory who can better assist you in reviewing your code and how you are passing the payload. 

Other resources that may be helpful to you are some of Klaviyo’s API documents which I’ve included below for your convenience:

I hope you have a great day!


Badge +2

Hi David,

Thanks for your response. I would like to work with developer in absence of the tools and unclear error response. Please let me know how should I proceed further?





Userlevel 3
Badge +5

Hey @lbaskar ,

Connor from the Klaviyo Solution Architect Team here. Couple questions for you:

  1. Do you happen to have a code snippet of how you’ve sent the request to Klaviyo? What language are you using?
  2. Are you using the GET or POST version of the Track API?

I took your exact same payload provided above (changed around some of the user info) and was able to get this to work with the GET endpoint. See code example here:

Admittedly I haven’t tried out the POST Track endpoint, but it should yield the same result. My hunch is that perhaps there's an encoding error that Klaviyo cannot parse but I can give you my thoughts if you share a code snippet!

Badge +2

Hi Connor,

Thanks for your response.

Pls use postman tool test this API with the given payload.

Get endpoint is working for us and we live for almost now 5 months, but our problem comes when we have an order with huge number of lines, say for example 500 line items, then order payload is big and the get method won’t work.



Userlevel 3
Badge +5

Hey @lbaskar , makes sense as to why you’d want to use POST then! I just tested in postman with that payload (using my own account for testing) and was able to get a 1 back successfully. Some things to take note of:

  1. Be sure to use a form urlencoded header:
    'Content-Type: application/x-www-form-urlencoded'
  2. Be sure to add the JSON of the payload as the value to a key called “data”

Here’s my exported request from Postman… 


curl --location --request POST '' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode 'data={ "token":"REDACTED", "event":"Order Confirmation", "customer_properties":{ "$email":"", "$first_name":"test", "$last_name":"test", "$phone_number":"1234567890", "$address1":"00 abcd, Suite 200", "$city":"Forest city", "$zip":"94545", "$region":"CA", "$country":"US", "Email Last Acquired Source":"00-000013", "Email Last Acquired Date":"2021-09-14 09:41:37" }, "properties":{ "$event_id":"388948924", "$value":"323.01", "OrderId":"3000470847612", "OrderedDate":"2021-07-26T03:25:33", "PaymentTerm":"Credit Card", "ProductSubTotal":"294.98", "EstimatedTax":"28.03", "ShippingTotal":"0.0", "OrderTotal":"323.01", "DiscountTotal":"0.0", "Domain":"", "CurrencyISOCode":"USD", "CountryISOCode":"US", "Items":[ { "LineId":"334987274", "ProductID":"1871616", "SKU":"12377756A", "ProductName":"Doctor Maria Montessori", "ItemDisplayedType":"Premium Giclee Print", "Quantity":"1", "UnitCharge":"157.99", "Discount":"0", "OriginalPrice":"157.99", "SellingPrice":"157.99", "ItemType":"POD", "UnitOfMeasure":"INC", "Height":"12", "Width":"16", "ServiceType":"Frame", "ServiceAttributes":{ "GlassName":"Acrylic: Clear", "Mats":[ { "Position":1, "MatName":"Crisp - Bright White" } ], "Moldings":[ { "Position":"1", "MoldingName":"ALLEGRO Silver Wide", "SideLengths":{ "Top":"18", "Right":"22", "Bottom":"18", "Left":"22" } } ], "Liners":[ ] }, "TimeToShip":{ "WebsitePromisedTimeToShipDays":"4", "WebsitePromisedTimeToShipDate":"2021-08-05T03:24:56", "EstimatedShipDate":"2021-08-09T23:59:00", "ArrivalByDateMin":"2021-09-18T09:41:36", "ArrivalByDateMax":"2021-09-18T09:41:36" }, "PrintSize":"12x16", "ProductImageURL":"", "ImageId":"1743359", "PODConfigId":"4986478", "PhysicalDimensionWidth":"16", "PhysicalDimensionHeight":"12", "PhysicalDimensionUnit":"INC" }, { "LineId":"334987273", "ProductID":"6804869", "SKU":"4123616437A", "ProductName":"Montessori School", "ItemDisplayedType":"Giclee Print", "Quantity":"1", "UnitCharge":"136.99", "Discount":"0", "OriginalPrice":"136.99", "SellingPrice":"136.99", "ItemType":"POD", "UnitOfMeasure":"INC", "Height":"18", "Width":"12", "ServiceType":"Frame", "ServiceAttributes":{ "GlassName":"Acrylic: Clear", "Mats":[ { "Position":1, "MatName":"Crisp - Bright White" } ], "Moldings":[ { "Position":"1", "MoldingName":"GRAMERCY Black", "SideLengths":{ "Top":"24", "Right":"18", "Bottom":"24", "Left":"18" } } ], "Liners":[ ] }, "TimeToShip":{ "WebsitePromisedTimeToShipDays":"4", "WebsitePromisedTimeToShipDate":"2021-08-05T03:24:56", "EstimatedShipDate":"2021-08-09T23:59:00", "ArrivalByDateMin":"2021-08-13T05:17:13", "ArrivalByDateMax":"2021-08-13T05:17:13" }, "PrintSize":"12x18", "ProductImageURL":"", "ImageId":"4755636", "PODConfigId":"9436042", "PhysicalDimensionWidth":"12", "PhysicalDimensionHeight":"18", "PhysicalDimensionUnit":"INC" } ], "BillingAddress":{ "FirstName":"Steven", "LastName":"Test", "Address1":"123 main street", "City":"Boston", "State":"MA", "Country":"United States", "CountryCode":"US", "ZipCode":"02118", "Phone":"1234567890" }, "ShippingAddress":{ "FirstName":"Steven", "LastName":"Test", "Address1":"123 main street", "City":"Boston", "State":"MA", "Country":"United States", "CountryCode":"US", "ZipCode":"02118", "Phone":"1234567890" }, "Email":"", "ShippingPriority":"Standard", "CreditCard":{ "Type":"MC", "Token":"RTA", "AccountIdentifier":"123", "ExpirationMonth":"123", "ExpirationYear":"3000", "AccountName":"Test" } } }'


import requests

url = ""


headers = {
'Content-Type': 'application/x-www-form-urlencoded'

response = requests.request("POST", url, headers=headers, data=payload)


It’ll look a bit weird because of the form encoded payload, but at any rate, you can use built in functions from whatever language you’re using to form/urlencode the payload before sending the track request.


Let me know if that helps!

Badge +2

@lbaskar, make sure your payload has data= before your JSON.


"token": "<KEY>",
"event": "Order Confirmation",
"customer_properties": {},


Badge +1

As a point of interest we have seen a huge spike in these responses recently as well - it is only a small subset of calls though, about 5%.  Taking the same payload and submitting it via python instead of dotnet always results in a successful call. The lack of debugging tools is quite painful.

Badge +2

I am having this same error. I run the api through postman and it is a success it will post to our klaviyo account an order placed. But I can’t for the life of me get it to work on our website. It always just returns 0 and I cannot get any curl errors to appear just always 0.


$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_POSTFIELDS => array('data' => '{"token": "VYUvy9", "event": "Placed Order", "customer_properties": {"$email": ""}, "properties": {"item_name": "Boots","$value": 100}}'),
"Content-Type: application/x-www-form-urlencoded"

$response = curl_exec($curl);
echo $response;


Userlevel 7
Badge +60


It looks like you may have to URL encode the data you are sending. 

When comparing the code examples from the Track & Identify section of the Klaviyo's API Documentation versus your example request, we can see the data is not encoded.

Example from the Track & Identify section:


Your example request:

CURLOPT_POSTFIELDS => array('data' => '{"token": "VYUvy9", "event": "Placed Order", "customer_properties": {"$email": ""}, "properties": {"item_name": "Boots","$value": 100}}'),



Badge +2

Thank you for taking a look! I copy pasted the example and swapped my public key and it posted! now I just have to figure out how to code that.