Skip to main content
Solved

Subscribe a profile using API


Forum|alt.badge.img+2

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 ​​​​​​​

Best answer by Brian Turcotte

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

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

stem
Problem Solver III
Forum|alt.badge.img+5
  • Problem Solver III
  • 20 replies
  • August 28, 2023
            "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 **


Forum|alt.badge.img+2
  • Author
  • Contributor II
  • 3 replies
  • August 28, 2023

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


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • September 7, 2023

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