Skip to main content
Contributor I
May 2, 2024 12:58 AM UTC
Solved

Unable to create or update profile custom properties

using api v2024-02-15

POST https://a.klaviyo.com/api/profiles/
PATCH https://a.klaviyo.com/api/profiles/{id}/

Unable to add custom properties on existing profile and new create profile.

 

Proflie can be created but properties has not add to the profile.

 

postman example with POST https://a.klaviyo.com/api/profiles/

{

  "data": {

    "type": "profile",

    "attributes": {

      "email": "ptctech@gmail.com",

      "phone_number":"+61431111232",

      "first_name": "Peter123",

      "last_name": "Chai"

    },

            "properties": {

                "membership": "GOLD"

            }

  }

}

 

Return:

{

    "data": {

        "type": "profile",

        "id": "01HWVCVDZADCX4GF5HQY86EAFN",

        "attributes": {

            "email": "ptctech@gmail.com",

            "phone_number": "+61431111232",

            "external_id": null,

            "anonymous_id": null,

            "first_name": "Peter123",

            "last_name": "Chai",

            "organization": null,

            "title": null,

            "image": null,

            "created": null,

            "updated": null,

            "last_event_date": null,

            "location": {

                "longitude": null,

                "zip": null,

                "city": null,

                "address1": null,

                "country": null,

                "latitude": null,

                "region": null,

                "address2": null,

                "timezone": null,

                "ip": null

            },

            "properties": {}

        },

        "relationships": {

            "lists": {

                "links": {

                    "self": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/relationships/lists/",

                    "related": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/lists/"

                }

            },

            "segments": {

                "links": {

                    "self": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/relationships/segments/",

                    "related": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/segments/"

                }

            },

            "conversation": {

                "links": {

                    "self": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/relationships/conversation/",

                    "related": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/conversation/"

                }

            }

        },

        "links": {

            "self": "https://a.klaviyo.com/api/profiles/01HWVCVDZADCX4GF5HQY86EAFN/"

        }

    }

}

 

    This topic has been closed for replies.
    Kim Strauch
    Klaviyo Employee
    Jun 12, 2024 9:18 PM UTC

    Hey @peterchai89,

    You can definitely update custom properties using the new APIs. The problem you’re running into here is how you’re structuring your API request payload. You need properties to be nested under attributes for this to work properly. Here’s an updated payload example:

     

    {

      "data": {

        "type": "profile",

        "attributes": {

          "email": "ptctech@gmail.com",

          "phone_number":"+61431111232",

          "first_name": "Peter123",

          "last_name": "Chai",

          "properties": {

            "membership": "GOLD"

          }

        }        

      }

    }

    There’s also an API endpoint you can use to create or update a profile in a single request here, if that’s desired: https://developers.klaviyo.com/en/reference/create_or_update_profile 

    3 replies

    Brian Turcotte
    Klaviyo Alum
    May 6, 2024 4:14 PM UTC

    Hi @peterchai89!

    I’m going to check on this internally and I’ll update the thread ASAP!
     

    - Brian

    Contributor I
    May 13, 2024 2:01 AM UTC

    Thank you Brian.

    do you have any update?

    Kim Strauch
    Klaviyo Employee
    Klaviyo Employee
    Jun 12, 2024 9:18 PM UTC

    Hey @peterchai89,

    You can definitely update custom properties using the new APIs. The problem you’re running into here is how you’re structuring your API request payload. You need properties to be nested under attributes for this to work properly. Here’s an updated payload example:

     

    {

      "data": {

        "type": "profile",

        "attributes": {

          "email": "ptctech@gmail.com",

          "phone_number":"+61431111232",

          "first_name": "Peter123",

          "last_name": "Chai",

          "properties": {

            "membership": "GOLD"

          }

        }        

      }

    }

    There’s also an API endpoint you can use to create or update a profile in a single request here, if that’s desired: https://developers.klaviyo.com/en/reference/create_or_update_profile