Solved

Updating custom profile property when creating an event

  • 14 December 2023
  • 2 replies
  • 112 views

Badge

I’m wondering if it’s possible to add or update profile custom properties using the Create Event endpoint? I’m sending a POST request as described in the docs and including both an existing custom property (with a new value) as well as a totally new custom property, but it seems that the value of the existing custom property isn’t changing, and the new custom property isn’t being added. This is despite being able to see the event show up in the events list for the profile in question.

Here’s the body of the request, and it’s returning a 202 Accepted status.

{
"data": {
"type": "event",
"attributes": {
"properties": {},
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": "Test Event"
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": "matt@emails.com"
},
"properties": {
"Existing Property": 500,
"Totally New Property": "some_value"
}
}
}
}
}
}

Any thoughts on what I might be doing wrong, or whether this just isn’t possible (and a separate Update Profile call would be required to change profile custom properties)?

icon

Best answer by KeviSunshine 14 December 2023, 21:19

View original

2 replies

Userlevel 4
Badge +7

Hi @MattH,

I just tried your API call and the issue is that `properties` needs to be nested inside of `attributes`.

{
"data": {
"type": "event",
"attributes": {
"properties": {},
"metric": {
"data": {
"type": "metric",
"attributes": {
"name": "Test Event"
}
}
},
"profile": {
"data": {
"type": "profile",
"attributes": {
"email": "matt@emails.com",
"properties": {
"Existing Property": 500,
"Totally New Property": "some_value"
}
}
}
}
}
}
}

Cheers,

Kevin.

Badge

Ah, yep, that does it and I’m now able to both add new properties and update existing ones too!

Thanks Kevin, appreciate your help.

Reply