The profiles API needs a person ID to work, use the ‘identify’ API with the properties you want and that will create a profile. If you need to get the person ID you can use the call below. Its not part of the API docs but I was given this by their solutions architect.
curl -X GET \
https://a.klaviyo.com/api/v2/people/search \
-H 'Accept: */*' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'accept-encoding: gzip, deflate' \
-H 'api-key: 'YOUR_PRIVATE_KEY' \
-d '{"email":"CUSTOMER_EMAIL"}'
Hey @jnazemi! You could do this in a couple ways but it really depends on how you’re creating the profile.
Here are the couple options:
- If you want to create a profile and add a user to a list, you can use the following endpoint: https://www.klaviyo.com/docs/api/v2/lists#post-subscribe (note, this follows the opt-in settings for the list)
- If you want to just add a profile or add a profile and add custom properties, I’d recommend this endpoint: https://www.klaviyo.com/docs/http-api#identify
- If you want to add a profile and track an event as well as add custom properties, you can use this endpoint: https://www.klaviyo.com/docs/http-api#track
Note: option 2 and 3 have a slightly different authentication system than using the rest API like option 1.
Let me know if you have questions but here are some options!
Best,
Rem
Hi,
I have the the same problem here.
While I am using the identity (https://apidocs.klaviyo.com/reference/track-identify#identify) to create the profile, I got the response message “1” , according the documentation it means ‘Success’ , but still I can’t see the new profile in profile page.
Beside this method, is there another way to create profile with Rest API?
Thanks.
Hello @Mars,
The response you are receiving of “1" would indicate that the call was successfully processed. If you are not seeing this profile in your Profile’s tab of your Klaviyo account, I would recommend double checking to ensure that you are using a public API key of your Klaviyo account as opposed to the private API key for these calls.
Using a private API key would respond with a “1” but actually not processing anything offering a false positive.
You can also find more resources on utilizing Klaviyo’s Identify and Track API from the Track and Identify API Reference article.
Hope this helps!
David