Solved

Updating SMS Consent (Node.js Server-side)

  • 18 May 2021
  • 2 replies
  • 77 views

Badge

(solved, see reply below!)

Having some trouble updating a Profile to indicate that the user has consented to receiving SMS messages.  I’m following along this document:
https://help.klaviyo.com/hc/en-us/articles/360054803711-Guide-to-Collecting-SMS-Consent-via-API#include-phone-number-and-consent-status5

Looks pretty straightforward -- just make an HTTP POST with the signup details. But even after I submit that POST, when I go look in that users’ profile in the Klaviyo UI, I don’t see any SMS consent -- I only see email consent listed in the `Channels` area:

 

 

My HTTP POST looks like this. My list “S****k” is set to double-opt-in, if that matters.

POST https://a.klaviyo.com/api/v2/list/S****k/subscribe

{
"api_key":"pk_f7************************eb",
"profiles":[
{
"email": "jo**********+20@sp********.com",
"$consent": ["sms"],
"phone_number": "+12345678902",
"sms_consent": true
}
]
}

The response is a 200 OK with an empty array:

200 OK

[]

 

When I “Export Profile” the user through the Klaviyo UI, I can definitely see that the phone number I sent in was saved, and all of the SMS properties appear to be set too!

customer_properties.json

{
"object": "person",
"id": "01******************H6",
"$address1": "",
"$address2": "",
"$city": "",
"$country": "United States",
"$latitude": "",
"$longitude": "",
"$region": "",
"$zip": "",
"$email": "jo******************+20@sp*******.com",
"$first_name": "",
"$last_name": "",
"$organization": "",
"$title": "",
"$phone_number": "+12345678902",
"$timezone": "",
"$id": "",
"$consent_timestamp": "2021-05-18T18:35:02.161Z",
"$source": -9,
"$consent": [
"sms"
],
"sms_consent": true,
"email": "jo******************+20@sp*******.com",
"first_name": "",
"last_name": "",
"created": "2021-05-18 17:47:11",
"updated": "2021-05-18 18:35:02"
}

 

What I expected to see in the Klaviyo UI was something like the below. There is a Consent Status listed for *both* the email and phone number. This sample user was updated via the CSV import from a list, not using the API.
 

 

What am I doing wrong?

icon

Best answer by spacedeveloper 18 May 2021, 21:47

Ended up being a data+configuration issue!

The list I was subscribing to had Double Opt-In configured. And the phone number I was using to test the API out was just a junk throw-away number `1234567890`. So after subscribing the user, Klaviyo was sending out the double opt-in to that 1234567890, which obviously was never accepted & replied to.

I used a real phone number and went through the double opt-in process. I can now see the SMS consent added on the user profile.

Thanks, Klaviyo support for walking me through this!


 

View original

2 replies

Badge

Ended up being a data+configuration issue!

The list I was subscribing to had Double Opt-In configured. And the phone number I was using to test the API out was just a junk throw-away number `1234567890`. So after subscribing the user, Klaviyo was sending out the double opt-in to that 1234567890, which obviously was never accepted & replied to.

I used a real phone number and went through the double opt-in process. I can now see the SMS consent added on the user profile.

Thanks, Klaviyo support for walking me through this!


 

Userlevel 6
Badge +4

Hello @spacedeveloper,

Thanks for following up with a resolution! 

I’m sure this insight will help to serve other Community members looking to leverage API to collect SMS consent!

Thanks again for being a part of our Community!

-David

Reply