Skip to main content
Solved

Looking up sms consent details with api

  • January 3, 2021
  • 8 replies
  • 601 views

Forum|alt.badge.img+2

Hi, does anyone know if it’s possible for me to lookup whether a user has consented to sms or not with the api using just the email address?

 

Thanks

Best answer by k.mcevoy

Hi there, 

Thanks for being a member of the Community!

 

You should be able to retrieve a profile’s SMS consent using this endpoint: 

GET https://a.klaviyo.com/api/v1/person/{{ PERSON_ID }}

As outlined in this documentation.  The endpoint requires the person_id and if the retrieved payload includes “sms_consent”: True they have opted into SMS. More information on that here

 

Kelsey

8 replies

k.mcevoy
Klaviyo Employee
Forum|alt.badge.img+6
  • Klaviyo Employee
  • Answer
  • January 4, 2021

Hi there, 

Thanks for being a member of the Community!

 

You should be able to retrieve a profile’s SMS consent using this endpoint: 

GET https://a.klaviyo.com/api/v1/person/{{ PERSON_ID }}

As outlined in this documentation.  The endpoint requires the person_id and if the retrieved payload includes “sms_consent”: True they have opted into SMS. More information on that here

 

Kelsey


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • January 4, 2021

Thanks for the reply. The issue I’m having is that in our db we don’t have the person_id stored, just information from shopify (customer info, email etc). Is there a way to do this with the email address instead of the id? If not is there a way to retreive the person_id via api using the email address to lookup?

 

Thanks


k.mcevoy
Klaviyo Employee
Forum|alt.badge.img+6
  • Klaviyo Employee
  • January 4, 2021

Got it! 

 

If you just have email address you should be able to make the following request: 

curl -X GET \  https://a.klaviyo.com/api/v2/people/search \  -H 'api-key: 'YOUR_PRIVATE_KEY' \  -d '{"email":"EMAIL_ADDRESS"}'

 

Just as a reminder we have an API limit of 3 calls/second. 

 

Kelsey 


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • January 5, 2021

Hi, thanks. The lookup works great. However once I get the person_id on the one I’m testing when I look it up with GET https://a.klaviyo.com/api/v1/person/{{ PERSON_ID }} 

 

I don’t see “sms_consent”:true even though the person signed up through a klaivyo sms form and I see consent when I look them up in klaviyo :/

 

 


k.mcevoy
Klaviyo Employee
Forum|alt.badge.img+6
  • Klaviyo Employee
  • January 5, 2021

Hi @AR99  

Would you mind passing along an example request so I can take a closer look? 

Thanks so much!

Kelsey 


Forum|alt.badge.img+2
  • Contributor II
  • May 16, 2021

Got it! 

 

If you just have email address you should be able to make the following request: 

curl -X GET \  https://a.klaviyo.com/api/v2/people/search \  -H 'api-key: 'YOUR_PRIVATE_KEY' \  -d '{"email":"EMAIL_ADDRESS"}'

 

Just as a reminder we have an API limit of 3 calls/second. 

 

Kelsey 

I tried this api but I’m getting only person id in return: 
https://a.klaviyo.com/api/v2/people/search?api_key={{APIKey}}&email={{email}}

So after getting personId from above API, I tried to call GET https://a.klaviyo.com/api/v1/person/{{ PERSON_ID }} API. But I’m not getting sms consent status even though passed person Id has this value as true. There is no consent related field in API response.


Forum|alt.badge.img+2
  • Contributor II
  • May 16, 2021

Hi, thanks. The lookup works great. However once I get the person_id on the one I’m testing when I look it up with GET https://a.klaviyo.com/api/v1/person/{{ PERSON_ID }} 

 

I don’t see “sms_consent”:true even though the person signed up through a klaivyo sms form and I see consent when I look them up in klaviyo :/

 

 

Hi, did you manage to get sms_consent status using this api? Because I’m receiving only personId in response.


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • May 18, 2021

Hello @AR99 and @himalay,

Adding to @k.mcevoy, I would recommend try using the Check List Subscriptions endpoint below. 

https://a.klaviyo.com/api/v2/list/LIST_ID/subscribe

Using this endpoint will allow you to list out emails, phone numbers, or push tokens in the body of the request.

If the request returns a response with their phone number; this would indicate that the profile has consented to receive SMS. Invalid requests will be accompanied by an error message.

From the example above, we can see that the "phone_number" is included in the customer object in the response. You may also want to reference our API Documentation surrounding this endpoint here: https://apidocs.klaviyo.com/reference/lists-segments#check-subscriptions

Hope this helps!

-David