HomeGuidesAPI Reference
ChangelogHelp CenterCommunityContact Us
Guides
These docs are for v2023-07-15. Click to read the latest docs for v2024-10-15.

Update profile identifiers via API

Learn how to update profile identifier fields using Klaviyo's RESTful APIs.

Profile identifiers are fields such as $email and $phone_number that can be used to uniquely identify a profile in your account. The following fields are all considered to be identifier fields:

  • Email ($email)
  • Phone number ($phone_number)
  • External ID (external_id)

🚧

The Identify API, which accepts public API Keys and is designed to be called directly within a webpage, does not allow updates to profile identifiers directly. Protecting updates to profile identifiers (such as email address and phone number) behind an API that requires using a Private API key is designed to prevent any potential abuse of Klaviyo’s APIs.

If you are building a workflow that requires updates to profile identifiers via API, we recommend you follow the examples below to update profile identifiers securely using a private key and Klaviyo's RESTFul APIs.

To update non-identifier profile properties, check out the Update Profile API reference.

Update profile identifiers

If you don’t already have the Klaviyo profile ID for the profile you’d like to update, then updating profile identifiers via our RESTful APIs will require two requests to be made per profile:

  1. A GET request to the Get Profiles endpoint to look up the Klaviyo profile ID for the profile you want to update
  2. A PATCH call to Update Profiles endpoint to update the desired identifiers using the Klaviyo profile ID you’ve just retrieved

GET the Klaviyo profile ID

Our example profile has the external ID "external_id":"abcd1234". To look up the Klaviyo profile ID for this profile, make the following GET request to our get profiles endpoint, using filtering to look for that specific profile given the external_id:

curl --location -g 'https://a.klaviyo.com/api/profiles/?filter=any(external_id%2C[%22abcd1234%22])' \
--header 'revision: 2023-02-22' \
--header 'Accept: application/json' \
--header 'Authorization: Klaviyo-API-Key PRIVATE-API-KEY'

If this profile is found, the endpoint will return a 200 response with the corresponding Klaviyo profile ID in the body "id": "01GTCV5HXWKPQFS5YXC1KBGKY8":

{
    "data": [
        {
            "type": "profile",
            "id": "01GTCV5HXWKPQFS5YXC1KBGKY8",
            "attributes": {
                "email": "[email protected]",
                "phone_number": null,
                "external_id": "abcd1234",
                "anonymous_id": null,
                "first_name": null,
                "last_name": null,
                "organization": null,
                "title": null,
                "image": null,
                "created": "2023-02-28T20:24:36+00:00",
                "updated": "2023-03-01T17:45:10+00:00",
                "last_event_date": null,
                "location": {
                    "address1": null,
                    "address2": null,
                    "city": null,
                    "country": null,
                    "latitude": null,
                    "longitude": null,
                    "region": null,
                    "zip": null,
                    "timezone": null
                },
                "properties": {}
            },
            "links": {
                "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/"
            },
            "relationships": {
                "lists": {
                    "links": {
                        "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/relationships/lists/",
                        "related": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/lists/"
                    }
                },
                "segments": {
                    "links": {
                        "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/relationships/segments/",
                        "related": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/segments/"
                    }
                }
            }
        }
    ],
    "links": {
        "self": "https://a.klaviyo.com/api/profiles/?filter=any(external_id,[%22abcd1234%22])",
        "next": null,
        "prev": null
    }
}

Update the profile’s email address

Now that we have the profile’s Klaviyo ID, we can update their email address identifier. For this example, we will update email for this profile to [email protected].

To update the email profile identifier, make the following PATCH request. Note that the klaviyo profile id must be included in the url as well as the payload:

curl --location --request PATCH 'https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/' \
--header 'revision: 2023-02-22' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Klaviyo-API-Key PRIVATE-API-KEY' \
--data-raw '{
	"data": {
		"type": "profile",
		"id": "01GTCV5HXWKPQFS5YXC1KBGKY8",
		"attributes": {
			"email": "[email protected]"
		}
	}
}'

If the request successful, the endpoint will return the new updated profile object with its updated email address:

{
    "data": {
        "type": "profile",
        "id": "01GTCV5HXWKPQFS5YXC1KBGKY8",
        "attributes": {
            "email": "[email protected]",
            "phone_number": null,
            "external_id": "abcd1234",
            "anonymous_id": null,
            "first_name": null,
            "last_name": null,
            "organization": null,
            "title": null,
            "image": null,
            "created": "2023-02-28T20:24:36+00:00",
            "updated": "2023-03-01T17:46:46.691266+00:00",
            "last_event_date": null,
            "location": {
                "address1": null,
                "address2": null,
                "city": null,
                "country": null,
                "latitude": null,
                "longitude": null,
                "region": null,
                "zip": null,
                "timezone": null
            },
            "properties": {}
        },
        "links": {
            "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/"
        },
        "relationships": {
            "lists": {
                "links": {
                    "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/relationships/lists/",
                    "related": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/lists/"
                }
            },
            "segments": {
                "links": {
                    "self": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/relationships/segments/",
                    "related": "https://a.klaviyo.com/api/profiles/01GTCV5HXWKPQFS5YXC1KBGKY8/segments/"
                }
            }
        }
    }
}