Solved

How do I get consent status of a single member using API

  • 12 November 2021
  • 4 replies
  • 591 views

Badge +2

How do I get the email consent status of a member by email using the API?

I have tried:

'https://a.klaviyo.com/api/v1/person/PERSON_ID?api_key=PRIVATE_KEY'

but it does not return any email or sms status as suggested in this forum.

 

I also looked int track and identify to see if I could get:

$consent: list of strings; eg: ['sms', 'email', 'web', 'directmail', 'mobile']

but the GET method only returns an integer.

 

icon

Best answer by Dave Watchgang 17 November 2021, 18:37

View original

4 replies

Userlevel 7
Badge +58

Hi there @Dave Watchgang 

Welcome to the Community!

You will want to ensure you are formatting all data points as listed in our API documentation. The image below shows a successful call following our api doc:
?name=inline-1706821810.png

You can also check to see if your list is set to double opt-in. If the list is set to double opt-in the subscription would have to be confirmed by the customer.
To subscribe someone with SMS consent, I believe you'll need to use our POST endpoint detailed on our subscription API documentation under the "Subscribe to list" header. 

 

Let me know if that helped!

Alex

Badge +2

I was not looking for SMS concent status. I was looking for a way to see if the person was opted out of getting emails. I have found nothing in the docs that shows where in a person’s profile that is stored.

 

I ended up using a brute force work around by getting all cancellation events and matching our emails to the event person’s email.

Badge +2

Okay, so I think the answer is to use below with the single email I wish to check:

curl --request POST \--url https://a.klaviyo.com/api/v2/list/LIST_ID/get-list-subscriptions \     --header 'Accept: application/json' \     --header 'Content-Type: application/json' \     --data '{     "api_key": "PRIVATE_KEY",     "emails": [          "desired.email.to@check.com"     ]}

Then if the result is an empty array the email is not in the list AKA “unsubscribed”

 

Userlevel 7
Badge +58

Hey there @Dave Watchgang,

If you’re looking to find people who were opted out of emails, it seems like you would want a list of unsubscribed people. 

To make a note, just because someone is not found from using that API code you posted does not mean they are unsubscribed users. They could be active in a different LIST_ID that was not checked. The person’s profile could also still be active by doing other tasks such as placing orders. Your solution works but does not take into account if that customer is active and subscribed in another list.

I would suggest taking a look at our apidocs regarding global exclusions. This is more likely to aid in what you are trying to achieve in terms of data collection.

 

Thanks!

Alex

Reply