Solved

How to unsubscribe a user from all lists via the API?

  • 13 January 2022
  • 3 replies
  • 753 views

Badge +2

How to unsubscribe a user from all lists via the API?

 

We’ve got hundreds of mailing lists, so cannot loop around each one unsubscribing hoping they’re in it.

 

How can we get a list of Lists that the user is subscribed to, to unsubscribe them via the API

 

or

 

An API call that unsubscribes the user from all lists they’re members of?

 

Thanks

icon

Best answer by sourabh 20 January 2022, 00:14

View original

3 replies

Userlevel 2
Badge +9

Hey @owen_fnatic,

A user once unsubscribed from a list gets unsubscribed everywhere since that detail gets attached to his profile in Klaviyo and consent is removed globally for that user. 

The best way to bulk unsubscribe users from mailing lists is to create a separate list of users that you want to unsubscribe and then unsubscribe them all from that list via API. Once that is done, they will be unsubscribed from everywhere and get suppressed. 

 

curl --request DELETE \
--url 'https://a.klaviyo.com/api/v2/list/LIST_ID/subscribe?api_key=API_KEY' \
--header 'Content-Type: application/json' \
--data '
{
"emails": [
"email1@example.com",
"email2@example.com"
]
}
'

 

Badge +3

Hey @owen_fnatic,

A user once unsubscribed from a list gets unsubscribed everywhere since that detail gets attached to his profile in Klaviyo and consent is removed globally for that user. 

The best way to bulk unsubscribe users from mailing lists is to create a separate list of users that you want to unsubscribe and then unsubscribe them all from that list via API. Once that is done, they will be unsubscribed from everywhere and get suppressed. 

 

curl --request DELETE \
--url 'https://a.klaviyo.com/api/v2/list/LIST_ID/subscribe?api_key=API_KEY' \
--header 'Content-Type: application/json' \
--data '
{
"emails": [
"email1@example.com",
"email2@example.com"
]
}
'

 

Wait wat???

So a user can’t unsubscribe from a single list!?
So if a user would not want to be part of a list the correct way would be to remove them from the list and not unsubscribe?

Badge +3

Okay, so that is the case. You should really add a note about that in the API documentation for the DELETE call.

Reply