Solved

Cannot add SMS consent via API

  • 4 January 2022
  • 6 replies
  • 819 views

Badge +2

Hi! I’m trying to set up an API call that would subscribe user and create consents for both e-mail and SMS. My JSON looks like this:

{
"profiles": [
{
"email": "m***@z******s.**",
"phone_number": "+38631******",
"sms_consent": true,
"$consent": ["sms"]
}
]
}

and API url is structured like this:

{{URL}}/list/{{LIST_ID}}/subscribe

I tried both Single and Double opt-in and it’s not working. Both e-mail and phone number are saved to profile, but only e-mail consent is displayed.

 I think I tried everything, but it’s still not working. Does anyone have an idea what I’m doing wrong?

Thank you!

icon

Best answer by alex.hong 4 January 2022, 19:52

View original

6 replies

Badge +2

It’s very likely that sms consent is not displayed in Klaviyo, because SMS are currently not available in EU. :disappointed_relieved:

Userlevel 7
Badge +58

Hi there @mihamajetic,

Welcome to the Community and thank you for sharing your findings with us!

Since it looks like you are using an international calling code 386, which indicates it may be a Slovenian number, that is why you are currently experiencing the issue you are running into. At this time, Klaviyo SMS is not available everywhere. Currently, you can only collect SMS consent and send text messages in: 

  • *United States
  • Canada
  • UK
  • Australia

*The United States only includes the 50 US states and not Puerto Rico or other territories.

More info regarding this can be found in the related help center article!

Have a good day!

Alex

Badge +2

Hi, I also have the exact same problem (consent is not showing up properly in the profile) and the “consented to receive sms” event is not triggered, and I cannot build an automation on top of it.

I’ve tried hungarian, USA and australian numbers. Same API call, same non-Klaviyo popup, different - real - mobile numbers.

List is single opt-in!

  • Hungarian numbers are not getting consent. Because SMS is not available? OK, fine...
  • USA numbers are getting consent. Great!
  • Australian numbers not getting consent. Why?

Can you help please?

Userlevel 7
Badge +58

Hi there @nandorhargita,

I saw you received an answer on:

Hope others can find the solution there as well.

Thank you!
Alex

Badge +1

Check for Prior Consent

The get-members List API endpoint can be leveraged to confirm that a contact number has or has not already consented to receiving SMS. To do so, make a POST request to https://a.klaviyo.com/api/v2/list/LIST_ID/get-members?api_key=API_KEY and include the phone numbers you wish to check for SMS consent in your payload. The example below uses Python. This method can also be used to check for email consent. 

If the phone number passed to the endpoint is not returned in the response, the number has not consented to receive SMS communications from you.

 

import requests

url = "https://a.klaviyo.com/api/v2/list/LIST_ID/get-members?api_key=API_KEY"

payload = {
    "phone_numbers": ["+13239169023", "+12028837032"]
}
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

Userlevel 2
Badge +6

SMS subscription is handled by list API not profile API.  You need to submit $consent AND list API endpoint. 

Reply