Skip to main content
Contributor I
March 22, 2022
Solved

Clearing property value via API

  • March 22, 2022
  • 9 replies
  • 1491 views

I am able to set Klaviyo and custom properties with API calls but cannot clear/blank out the property value. I can not do it through the interface or with the API.  For example if I set Location to “NY” and want to then set it to blank, neither the interface or API will allow it.  Through the interface I can remove the property.  I would prefer blanking it out but if that is not possible is there a way to remove the property through the API?

    This topic has been closed for replies.
    Best answer by David To

    Hello@John99,

    Great question!

    You can certainly remove profile properties through API using the $unset command as @julie.accardo mentioned in the Community post below:

    In addition, you can also use something like the following if you were working with an identify  request, or whatever values you have in properties set in the customer_properties  section of a track request:

    {
    "token":"abc123",
    "properties":{
    "$email":"person@email.com",
    "$unset":["property_to_unset_key"]
    }
    }

    I hope this helps!

    David

    9 replies

    David To
    Klaviyo Employee
    David ToAnswer
    Klaviyo Employee
    March 23, 2022

    Hello@John99,

    Great question!

    You can certainly remove profile properties through API using the $unset command as @julie.accardo mentioned in the Community post below:

    In addition, you can also use something like the following if you were working with an identify  request, or whatever values you have in properties set in the customer_properties  section of a track request:

    {
    "token":"abc123",
    "properties":{
    "$email":"person@email.com",
    "$unset":["property_to_unset_key"]
    }
    }

    I hope this helps!

    David

    John99Author
    Contributor I
    March 23, 2022

    David - Thank you! I was able to do what I needed to do.

    Contributor I
    March 16, 2023

    Hi,

    I’m using Revision: 2023-01-24 and cannot get $unset to work. There’s also no reference to it in the API docs https://developers.klaviyo.com/en/reference/api_overview

    Does this feature no longer work or is there a new alternative? 

    David To
    Klaviyo Employee
    Klaviyo Employee
    March 17, 2023

    Hey @nick1,

    Great observations! 

    Since the launch of our new APIs, the previously undocumented $unset feature is actually out of scope. The new behavior to clear/unset an existing profile property is to set it to null. 

    David

    Contributor I
    March 17, 2023

    Thanks for your help David!

    Before finding out about $unset I had actually already tested submitting a null value. This didn’t delete the property unfortunately, it was still listed but with None presented as it’s value. Is there a way to remove the property completely so it doesn’t appear at all?

    Brian Turcotte
    Klaviyo Alum
    March 20, 2023

    Hi @nick1!

     

    For now, the only ways to remove properties entirely are to use the legacy API’s $unset property or delete them in the UI dashboard.

     

    However, our product team is aware of the demand for this feature in the new APIs, so I will update the thread if anything similar becomes available in the future. 

     

    I hope this helps to clarify!

    - Brian

    Contributor IV
    July 7, 2023

    Would love to see/hear of a way to remove profile properties via new API

    Brian Turcotte
    Klaviyo Alum
    July 11, 2023

    Hi @mscheurichpatou!

     

    I’ll definitely forward this feedback to our Developer Experience team and update the thread when there are more updates!

     

    - Brian

    Kim Strauch
    Klaviyo Employee
    Klaviyo Employee
    August 19, 2023

    Hi @nick1 @mscheurichpatou and @John99!

    It is possible to completely remove a profile property in our APIs as of the 2023-07-15 revision using meta.patch_properties : https://developers.klaviyo.com/en/docs/changelog_#improved-endpoints

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

    If I had previously created a profile with a custom property called “FunFact”, I could completely remove that from the profile using the following payload in a call to the Update Profiles endpoint. 

    {
    "data": {
    "type": "profile",
    "id": "PROFILE_ID_TO_UPDATE",
    "meta": {
    "patch_properties": {
    "unset": "FunFact"
    }
    }
    }
    }

    You can also append an item to a custom list property like so: 

    {
    "data": {
    "type": "profile",
    "id": "PROFILE_ID_TO_UPDATE",
    "meta": {
    "patch_properties": {
    "append": { "listProperty": "itemToAdd" }
    }
    }
    }
    }


    Or you can remove an item from a custom list property like so: 

    {
    "data": {
    "type": "profile",
    "id": "PROFILE_ID_TO_UPDATE",
    "meta": {
    "patch_properties": {
    "unappend": {
    "listProperty": "itemToRemove"
    }
    }
    }
    }
    }