Skip to main content

I cannot find any documentation or even pages with an example of how to use the create_event API endpoint. While the API lists the format of the attributes, I still cannot figure out how to correctly send the profile information.

https://developers.klaviyo.com/en/reference/create_event

 

I’m trying to trigger an event for an existing profile for which I have the ID. When I do this using the create_event endpoint on the API, I see the Metric Activity Feed with data for the new events I create, but they are not really associated to the actual profile I want to.

 

Let’s say I have a profile id “01GFPQR35A6CBGJD1FY4EH43MA”. I can see that ID on the URL for Profiles on Klaviyo, and also returned as the id field by the API on other calls, so that is actually correct.

When I do a request like this:

curl --request POST \
--url https://a.klaviyo.com/api/events/ \
--header 'Authorization: Klaviyo-API-Key XXXXXXXXXXXXXXXXXXXXX' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'revision: 2022-10-17' \
--data '
{
"data": {
"type": "event",
"attributes": {
"profile": {
"$id": "01GFPQR35A6CBGJD1FY4EH43MA"
},
"metric": {
"name": "gift-card-confirmed",
"service": "the-service"
},
"properties": {
"one": "AAA",
"two": "BBB"
},
"time": "2022-11-04",
"value": 5,
"unique_id": "once-again-5"
}
}
}
'

 

The event is indeed created for the given metric, but it's not really associated to that profile. Apparently it creates a new profile with a new ID. I can see that on this page, see that the ID on the URL is for a different profile and what I send as a profile ID is used as a handle.

 

I’m probably doing something wrong, but cannot figure out what it is.

Hi there @ckozus ,

Welcome to the Community.

Question, have you tried to send the external_id in place of the id in the profile object? That should be the action to correctly associate it with the right profile.

 


@alex.hong 

 the profiles dont´t seem to have an external_id associated with them. Should they?

This is the output I get when I query the same profile that in the previous example over the API:

 

{
"data": {
"type": "profile",
"id": "01GFPQR35A6CBGJD1FY4EH43MA",
"attributes": {
"email": "nicolask10@gmail.com",
"phone_number": null,
"external_id": null,
"anonymous_id": null,
"first_name": "Nicolas",
"last_name": "Prueba",
"organization": null,
"title": null,
"image": null,
"created": "2022-10-18T23:44:33+00:00",
"updated": "2022-11-05T02:31:43+00:00",
"last_event_date": "2022-11-05T02:31:41+00:00",

 


Reply