If you receive an "Invalid payload" error when sending events to the insights API, there may be a typo or a parameter value in the wrong format.
insights.send_event({
eventType: 'click',
//eventType must be a string
eventName: 'Article clicked',
//eventName must be a string
index: 'Article_development',
//index must be a string, it's the same as the index name used by the search engine
userToken: '1234567',
//userToken must be a string
objectIDs: ["1234"],
//objectIDs is optional, must be an array
positions: [1],
//Position must be an integer
//Click positions start at 1, not 0.
//This is required if a queryID is provided. You must provide one position for each objectID
queryID: 'af8fbc03e56d7d519f0f795ee2c01cf32',
//queryID must be a string, this is required when an event is tied to a search
timestamp: 1655351882000
//timestamp must be an integer, expressed in milliseconds
//timestamp has to be within the last four days. If not, the event will be rejected
})
To troubleshoot, review this documentation, which includes an example payload sending three events for the same user: a click event, a view event, and a conversion event. This will help you verify whether your event data is being sent in the correct format.