Skip to main content

I have a Ruby (web) app that collects a user’s email and phone number. They can then optionally opt into email and sms marketing. I have tried passing consent through the “sms_consent”: true attribute as well as via API, but the profile still shows as “NEVER_SUBSCRIBED” in my list.

 

Using revision: 2023-07-15, I create a profile if one doesn’t already exist.

self.class.post("/profiles/", body: body, headers: headers)
{ "data":
{
"type": "profile",
"attributes": {
"properties": {
"$first_name": "Jane",
"$last_name": "Doe",
"sms_consent": true
},
"email": "janedoe@example.com",
"phone_number": "+447911128888"
}
}
}

Then, I post to the subscribe endpoint

self.class.post("/profile-subscription-bulk-create-jobs/", body: body, headers: headers)
{
"data": {
"type": "profile-subscription-bulk-create-job",
"attributes": {
"profiles": {
"data":
{
"type": "profile",
"id": "01H7A7T1TS*************",
"attributes": {
"phone_number": "+447911128888",
"email": "janedoe@example.com",
"subscriptions": {
"email":
"MARKETING"
],
"sms":
"MARKETING"
]
}
}
}
]
}
},
"relationships": {
"list": {
"data": {
"type": "list",
"id": "kdjalkd"
}
}
}
}
}

 

However, when I get the profile from my list I get:

 

"properties": {
"$source": -9,
"$consent": /
"email",
"sms"
],
"$consent_timestamp": "2023-08-07T11:37:48.409Z"
},
"subscriptions": null

When I get the profile, I get:

"properties": {
"$source": -9,
"$consent": >
"email",
"sms"
],
"$consent_timestamp": "2023-08-07T11:37:48.409Z"
},
"subscriptions": {
"email": {
"marketing": {
"consent": "SUBSCRIBED",
"timestamp": "2023-08-07T11:37:48.695806+00:00",
"method": "API",
"method_detail": "35cd",
"custom_method_detail": null,
"double_optin": false,
"suppressions": "],
"list_suppressions": _]
}
},
"sms": {
"marketing": null
}

Although I have SMS set up for the UK and I am not receiving any errors, would the issue be that our account cannot grant SMS consent? Or am I not properly sending the sms consent?

Hi @gleamdev!

I’m going to check on this with our API team and I’ll update the thread ASAP!

 

Best,

Brian


Hi @Brian Turcotte any chance you have an update on this?


Hi @gleamdev!

My apologies for the delay here - would you be willing to share a screenshot of the profile’s consent status feed in the Klaviyo UI after you make this call?

 

This may help myself and other Community members understand the issue better.

 

Best,

Brian


Hi @Brian Turcotte thanks for getting back to me. No problem! This is what I’m seeing in the UI after the call above. Note: I changed the list id to a fake one.

 


Hey @gleamdev, I’d recommend checking out  our guide to collecting email and SMS consent via API. You should be able to do this just by creating the profile and then making the Subscribe Profiles call as you have it. You shouldn’t need to update $sms_consent additionally. 

Question for you: 
Is the list you’re subscribing the profile to single- or double-opt-in? We always recommend double opt-in for SMS and that should be the default. If the profile hasn’t confirmed their subscription over text, they may stay in this “Never subscribed” state. 
 
Can you share the Klaviyo ID for the profile in question (the one from your screenshot)? We can share this with the team to take a look
 


Hi, thank you for the clarification on the $sms_consent. I will make sure to leave it out since I’m sending the consent via API.

The list I’m using is single-opt-in. I thought this would be better for testing purposes. The Klaviyo ID for this user is 01H7A7T1TS9ZSWAP08PNFVQ3DA.


Hey @gleamdev, the UK sending number on your account appears to not be a valid phone number for the UK. Given that, I think we are unable to create consent records for UK numbers as you do not have a valid sending number for that country.Can you try setting up a new UK sending number? That should help here. 


@Kim Strauch Yes! Ahh I just on a whim tested another number and it went through. Thank you for your time in figuring out the issue. Is there an error message somewhere in the UI that I missed stating that it was an invalid number?


@Kim Strauch

I am experiencing a similar issue. When testing this endpoint, the email subscription comes through fine but I can never get the sms subscription to subscribe.

 

Here is an example profile id where I experienced this issue. 01H9VA7W5X6B145NEWK0BFKYWS

Here is the screenshot of the profile page. 

 

Here is the request data being sent: 

{
"data": {
"type": "profile-subscription-bulk-create-job",
"attributes": {
"profiles": {
"data": t
{
"type": "profile",
"attributes": {
"email": "testing@newtest.com",
"phone_number": "+18017740296"
}
}
]
}
},
"relationships": {
"list": {
"data": {
"type": "list",
"id": "Yn5v2h"
}
}
}
}
}

As a side note, I have attempted to add the subscriptions object to the profile object but get the same result.

 

The list I am testing on is a single opt in list as well.  


Make sure to confirm SMS is enabled on your account and you have a sending number configured for the US. You can check that here: https://www.klaviyo.com/settings/sms. If either of those are not true, you will not be able to record consent for US phone numbers.


I’d recommend following up with Support f you’re still running into problems here.


@Kim Strauch Looks like my account does not have SMS enabled. Thank you for the help!


Reply