Solved

Set Custom Property To Null/Blank or Remove It

  • 6 June 2021
  • 4 replies
  • 1343 views

Badge +5

Using the node-klaviyo library making a call to the “identify” endpoint, if a custom property already exists on a profile with a value and I want to remove that property, or set it to blank/null if I have to, how do I do that?  I’ve tried passing in null or empty string and the existing value remains unchanged.

The use case here is a subscription club level, so someone signs up for “Gold Level” and we set a custom property for Club: “Gold Level”, but then they cancel the club, so now we want to set the club to blank/null or remove the property so they’re not in segments checking for club level.

The only thing I’ve found that kinda works is setting it equal to an empty array.  I feel like that’s going to cause me some grief down the road, so I’m hoping there’s a better way.  Help?

icon

Best answer by julie.accardo 6 June 2021, 15:07

View original

4 replies

Userlevel 5
Badge +34

Hi @Digimatic,

 

You should be able to use the unset command to remove a custom property from a users profile. Below is the example PUT request formatting that I just used in POSTMAN to successfully remove a profile property.

curl -X PUT 'https://a.klaviyo.com/api/v1/person/enteruserIDhere?api_key=XXXX&$unset=[%22enterprofilepropertyhere%22]' 

 

So in your case, your request would look something like this:

curl -X PUT 'https://a.klaviyo.com/api/v1/person/enteruserIDhere?api_key=XXXX&$unset=[%22Gold Level%22]' 

 

I hope this helps!

Julie

Badge +5

Thank you @julie.accardo for the response, but I don’t have a userId/profileId available.  I used the Identity endpoint to add and update profiles, which only ever returns a 1 or 0, so I don’t know what their IDs are.  Is there no way to do this with the Identity endpoint?  Or is there a way to retrieve an ID from an email address or something?

 

Thanks!

Userlevel 7
Badge +60

Hello @Digimatic,

I would recommend taking a look at a Community post answered by @jallain below on how to retrieve a profile’s ID from an email address:

You should be able to use the URL of https://a.klaviyo.com/api/v2/people/search?api_key=API_KEY_HERE&email=EMAIL_HERE to retrieve the contact’s Klaviyo profile ID.

Hope this helps!

David

Badge +5

Thanks @david.to , I think that will work.  Bummer that I have to make an extra call now for every profile update.  It would be great if I could just set the property to NULL or empty string in the identity endpoint and have it unset the property.  If this is the only way, I’ll go this route for now.

 

Thank you!

Reply