Solved

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

  • 1 April 2022
  • 2 replies
  • 126 views

Badge +1
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}
icon

Best answer by JeffV.klaviyo 7 April 2022, 01:28

View original

2 replies

Userlevel 7
Badge +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 

Userlevel 1
Badge +4

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. 

Reply