Solved

Subscribe a profile using API

  • 28 August 2023
  • 3 replies
  • 550 views

Badge +1

I’m about to send data from a webflow form to Klaviyo using the API. 

Currently, the process is: 
Using the create profile endpoint: https://a.klaviyo.com/api/profiles/ to create a profile with the data from the form.

That works perfectly. 

Then I want to subscribe that profile to a list. 

I then use the Subscribe Profiles endpoint https://a.klaviyo.com/api/profile-subscription-bulk-create-jobs/ to subscribe the profile with the data gathered from the create a profil API call. 

I use the ID from the create a profile API call for the ID in the Subscribe Profiles API Call. 

I do not get any errors, but the Subscribe to Profiles does not happen. 

Here is the Create profile Body

{
"data": {
"type": "profile",
"attributes": {
"email": "Email


",
"first_name": "Name


",
"location": {
},
"properties": {
"newKey": "New Value"
}
}
}
}


Here is the subscribe profiles body:
 

{
"data": {
"type": "profile-subscription-bulk-create-job",
"attributes": {
"custom_source": "Marketing Event",
"profiles": {
"data": [
{
"type": "profile",
"id": "id


",
"attributes": {
"email": "Email


",
"phone_number": "+15005550006",
"subscriptions": {
"email": [
"MARKETING"
],
"sms": [
"MARKETING"
]
}
}
}
]
}
},
"relationships": {
"list": {
"data": {
"type": "list",
"id": "RenFTF"
}
}
}
}
}


Any idea why this is not working, or if there is an easier way? 

​​​​​​​Best ​​​​​​​

icon

Best answer by Brian Turcotte 7 September 2023, 20:57

View original

3 replies

Userlevel 2
Badge +5
            "id": "id


",

In your actual call, you’ve replaced that with the id of the profile, right?

 

** ignore me. I see you’ve left most of the PII like that and this is most likely not the issue **

Badge +1

Yes is replaced the ID with the profile ID I got from the first call, which was create profile. 
 

Userlevel 7
Badge +36

Hi @saksmoto!

The first step I would recommend would be to check if the list is double opt-in, and if it is, are you ensuring that the opt-in email is being confirmed?

 

For the sake of your testing, it may be easier to make the List single opt-in in order to rule this out:

 

When you say the Subscribe to List isn’t working, are you getting an error? Or is the call successful, but the profile is not subscribed within Klaviyo?

 

Also - if you want to just include the profile’s email address in the second call (and omit the Profile ID), the call will still work as expected.

 

Best,

Brian

Reply