Skip to main content

Hi!

We are working on an integration with Klaviyo, we'll be sending events to the platform based on the data that we have tracked on the website. We are using the events bulk create endpoint.

Usually, when there is invalid input for this endpoint (like an invalid phonenumber), the error pointer will point to the invalid event and we can remove those in a subsequent request so that only valid events are remaining and the request will succeed.

Now we have the following scenario, the JSON we are sending is as follows (only need to look at the profile attributes):

{
   "data":{
      "type":"event-bulk-create-job",
      "attributes":{
         "events-bulk-create":{
            "data":
               {
                  "type":"event-bulk-create",
                  "attributes":{
                     "profile":{
                        "data":{
                           "type":"profile",
                           "attributes":{
                              "_kx":"r-xYo18d25SDCR7gwRkV4Q.SaGU2i"
                           }
                        }
                     },
                     "events":{
                        "data":
                           {
                              "type":"event",
                              "attributes":{
                                 "properties":{
                                    "test":"test"
                                 },
                                 "metric":{
                                    "data":{
                                       "type":"metric",
                                       "attributes":{
                                          "name":"Viewed Product - TrackBee"
                                       }
                                    }
                                 },
                                 "time":"2024-12-16T13:32:58.153237Z",
                                 "value":1.00,
                                 "value_currency":"EUR"
                              }
                           }
                        ]
                     }
                  }
               },
               {
                  "type":"event-bulk-create",
                  "attributes":{
                     "profile":{
                        "data":{
                           "type":"profile",
                           "attributes":{
                              "email":"selcuk@trackbee.io"
                           }
                        }
                     },
                     "events":{
                        "data":
                           {
                              "type":"event",
                              "attributes":{
                                 "properties":{
                                    "test":"test"
                                 },
                                 "metric":{
                                    "data":{
                                       "type":"metric",
                                       "attributes":{
                                          "name":"Viewed Product - TrackBee"
                                       }
                                    }
                                 },
                                 "time":"2024-12-16T13:33:58.153237Z",
                                 "value":1.00,
                                 "value_currency":"EUR"
                              }
                           }
                        ]
                     }
                  }
               }
            ]
         }
      }
   }
}

 

These are two events, one with an invalid _kx (for whatever reason, it looks valid to me) and a valid emailadress. However the error we get is as follows:
 

{
   "errors":
      {
         "id":"03326af3-82dd-4578-b0c5-9ff4af2640e1",
         "status":400,
         "code":"invalid",
         "title":"Invalid input.",
         "detail":"Invalid _kx token",
         "source":{
            "pointer":"_kx",
            "parameter":null
         }
      }
   ]
}

 

How are we supposed to tell, from this error, which event is the culprit. For other error types we usually get a pointer that looks like "/data/attributes/events-bulk-create/data/0” if it's regarding the first event (index 0) but we don't get that here.

And I get that in this specific scenario there is only one _kx parameter present in the entire request, but even with multiple events that have _kx, if one of them is invalid it'll throw this error with this same pointer.


Bumping this post, really need a reply from someone on how to solve this


Hello TrackBea,

To troubleshoot the invalid _kx token error you're encountering, Klaviyo doesn't seem to specify the exact event in the error response, which can make it challenging to identify the problematic event.

Here’s what you can do:

  1. Isolate the Invalid Event

    • Since the error points to the _kx attribute, test with one event at a time to see which one triggers the error. This will help you pinpoint which event contains the invalid _kx token.
  2. Double-check _kx Value

    • Ensure the _kx token is correctly formatted. Even if it looks valid, it could be improperly encoded or malformed in some cases. Try regenerating or validating the _kx token again.
  3. Log or Track Errors

    • If the error persists with multiple events, try logging each event individually before sending it to Klaviyo. This way, you can cross-reference the failed event with the error message and narrow down which one is causing the issue.
  4. Reach Out for Further Guidance

    • If this still seems complicated, feel free to message me on WhatsApp at g+2349151237531], and I’ll help you sort this out!

Reply