Skip to main content
Solved

Unable to create or update profile custom properties

  • May 2, 2024
  • 3 replies
  • 121 views

Forum|alt.badge.img+1

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/"

        }

    }

}

 

Best answer by Kim Strauch

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
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • May 6, 2024

Hi @peterchai89!

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

- Brian


Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 1 reply
  • May 13, 2024

Thank you Brian.

do you have any update?


Kim Strauch
Klaviyo Employee
Forum|alt.badge.img+9
  • Klaviyo Employee
  • 91 replies
  • Answer
  • June 12, 2024

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