Skip to main content
Solved

Constantly updating a custom property with new values via API


Forum|alt.badge.img+1

With our current integration we are passing a custom field to a Klaviyo contact called “promotion_id” which identifies which of our promotions they came through. 

For example, promotion_id: 2715

If that same email address enters another promotion, it will automatically update the promotion_id field with the ID of the new promotion, overwriting the old value. 

How do we keep the old value and add a new value, WITHOUT having to first lookup what values currently exist?

Ideally, as customers enter different promotions, we can just keep adding new values to the promotion_id field. However, after reading through the API docs, it appears we have to first look up the user to see what values already exist for the promotion_ID field, and pass all the values through? Is there anyway around this to not have to make that extra API call?

Best answer by Kim Strauch

+1 to @wanttoknowallaboutecommerce’s answer. See this answer for a bit more detail on these properties: 

Note: if you’re working with an existing custom property that is not a list, you’ll first need to update it to be a list to be able to take advantage of this append functionality. If starting fresh, you can just always use “append” which will create the property if it doesn’t exist or append to it if it does exist. 

If you are trying to update this field when creating an event, you should be able to follow a similar pattern using the  profile.meta.append object.  See https://developers.klaviyo.com/en/reference/create_event

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

Hi there,
Did you want to keep the old values and add the new custom property as well, or overwrite the old value with the new one?

I recommend checking out Patch Profile endpoint and particularly the append/unappend objects.

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


Kim Strauch
Klaviyo Employee
Forum|alt.badge.img+9
  • Klaviyo Employee
  • 91 replies
  • Answer
  • August 25, 2023

+1 to @wanttoknowallaboutecommerce’s answer. See this answer for a bit more detail on these properties: 

Note: if you’re working with an existing custom property that is not a list, you’ll first need to update it to be a list to be able to take advantage of this append functionality. If starting fresh, you can just always use “append” which will create the property if it doesn’t exist or append to it if it does exist. 

If you are trying to update this field when creating an event, you should be able to follow a similar pattern using the  profile.meta.append object.  See https://developers.klaviyo.com/en/reference/create_event