Skip to main content
Solved

When using Subscribe API and Zapier its creating two profiles (one for email and one for phone)


Forum|alt.badge.img+2
When using the following code its creating two profiles instead of combining them.  Any idea why?# configuring sms_consent mapping to boolean value
sms_consent = True
# configuring $consent mapping to list value
#consent = input_data["$consent"].split(",")    
payload = {"profiles": [
  {"email": input_data["email"]},
  {
    "first_name": input_data["name"],
    "phone_number": input_data["phone_number"],
    "sms_consent": sms_consent,
    "$consent": ["sms","email"]
  }
]}
headers = {
  "Accept": "application/json",
  "Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers, params=querystring)
# Zapier requires an 'output' object
output = {"response text": response.text}

Best answer by JeffV.klaviyo

Hi there,

Jeff with support engineering here. We resolved this offline, but for the sake of transparency, the reason why two profiles are being created is because the payload has two profile objects within the profile array:

{"profiles": [
  {
     "email": input_data["email"]
  },
  {
    "first_name": input_data["name"],
    "phone_number": input_data["phone_number"],
    "sms_consent": sms_consent,
    "$consent": ["sms","email"]
  }
]}

 

The curly bracket {} signify separate profiles. So if we wanted all this information to sync over as one profile it would look like this:

payload = {

    "profiles": [{

        "email": input_data["email"],

        "first_name": input_data["name"],

        "phone_number": input_data["phone_number"],

        "sms_consent": sms_consent,

        "$consent": ["sms", "email"]

    }]

}

 

In the above payload, we include all information within one set of curly brackets {} and they will sync to Klaviyo as one profile. 

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

2 replies

Taylor Tarpley
Community Manager
Forum|alt.badge.img+60

Hi @ojhurst

 

Thanks for sharing your question with us! I’m gonna loop in one of our engineers to take a peek at this as this payload looks correct for me and doesn’t show any obvious errors!

 

-Taylor 


JeffV.klaviyo
Klaviyo Employee
Forum|alt.badge.img+4
  • Klaviyo Employee
  • 6 replies
  • Answer
  • April 6, 2022

Hi there,

Jeff with support engineering here. We resolved this offline, but for the sake of transparency, the reason why two profiles are being created is because the payload has two profile objects within the profile array:

{"profiles": [
  {
     "email": input_data["email"]
  },
  {
    "first_name": input_data["name"],
    "phone_number": input_data["phone_number"],
    "sms_consent": sms_consent,
    "$consent": ["sms","email"]
  }
]}

 

The curly bracket {} signify separate profiles. So if we wanted all this information to sync over as one profile it would look like this:

payload = {

    "profiles": [{

        "email": input_data["email"],

        "first_name": input_data["name"],

        "phone_number": input_data["phone_number"],

        "sms_consent": sms_consent,

        "$consent": ["sms", "email"]

    }]

}

 

In the above payload, we include all information within one set of curly brackets {} and they will sync to Klaviyo as one profile.