Solved

How do I create a new Profile via Klaviyo's REST API?

  • 3 November 2020
  • 4 replies
  • 2987 views

Badge +2

Hello!

I’ve been trying to set up some custom integrations via Klaviyo’s REST API and I seem to have reached a wall. I’m trying to create new Profiles based on data from our back-end. I’ve come across two difficulties:

  1. I seem to be unable to POST a new profile. Whenever I try via the server responds with “Method "POST" not allowed.” Then, whenever I try to create a new Profile via a PUT request it says “'The requested resource does not exist.' Is it possible to create a new Profile and not just modify an existing one?
  2. If the above is possible, are you able to create a new Profile without assigning an ID an let Klaviyo generate one for you?

 

Any help would be greatly appreciated, thanks!

icon

Best answer by remstone 3 November 2020, 19:53

View original

4 replies

Userlevel 1
Badge +2

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"}'

 

Userlevel 2
Badge +5

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:

  1. 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)
     
  2. 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 
     
  3. 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

Badge +2

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. 

 

Userlevel 7
Badge +60

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

Reply