Methods to create and manage lists using python SDK
The Lists SDK methods lets you create / manage list of subscribers. You can then send broadcast to all the users in the list or create a workflow that triggers when a new user enters / exits list.
You can use supr_client.subscribers_list.create method to create a new list
from suprsend import SubscriberListBroadcast,SuprsendAPIException,SuprsendValidationErrorfrom suprsend import Suprsend# Initialize SDKsupr_client = Suprsend("workspace_key","workspace_secret")try: data = supr_client.subscriber_lists.create({"list_id":"_list_id_",#Unique identifier for the list"list_name":"_list_name_",#readable name of the list (optional)"list_description":"_some sample description for the list_"})print(data)except(SuprsendAPIException,SuprsendValidationError)as ex:print(ex)
Guidelines on defining the list_id
list_id is case-insensitive. Suprsend first converts list_id to lowercase before storing it or doing any sort of comparison on it.
list_id can be of max 64 characters.
It can contain characters [a-z0-9_-] i.e. alphanumeric characters, _(underscore) and -(hyphen).
If you want to refresh a list completely with a new set of users, you can replace users by creating a draft version of the list and updating users in it.
Use this method only if you want to completely overwrite the list members.
1
Start Sync to create a draft version of the list
This method will create a draft version of the list where you can add the new set of users to replace existing users.
data = supr_client.subscriber_lists.start_sync("_list_id_")
2
Add Subscribers to the draft list
You can use this method to add subscribers to the list’s draft version created in Step-1. You’ll get version_id in the start sync response.
data = supr_client.subscriber_lists.add_to_version("_list_id_","01HHCTXXXXXXXXXXX",["_distinct_id1_","_distinct_id2_"])
3
Remove Subscribers from the draft list
You can use this method to remove subscribers from the list’s draft version created in Step-1. You’ll get version_id in the start sync response.
data = supr_client.subscriber_lists.remove_from_version("_list_id_","01HHCTXXXXXXXXXXX",["_distinct_id1_","_distinct_id2_"])
4
Finish Sync to make the draft version live
Once your subscribers are updated in the list, use this method to finish sync and make the draft version updated in the above steps live.
data = supr_client.subscriber_lists.finish_sync("_list_id_","01HHCTXXXXXXXXXXX")