How Suprsend identifies a user

SuprSend identifies users with immutable distinct_id. It’s best to map the same identifier in your DB with distinct_id in SuprSend. Do not use identifiers that can be changed like email or phone number. You can view synced users by searching distinct_id on Users page.

Create user

To create a new user or to update an existing user, you’ll have to fetch user instance. Call supr_client.user.get_instance to instantiate user object.

const user = supr_client.user.get_instance("__distinct_id__"); // create user instance

// user methods mentioned in this docs can be attached to user instance if needed

const response = user.save() // IMP: trigger request
response.then((res) => console.log("response", res));

Edit User

To Edit user, you need to first fetch user instance, call all the update methods and save changes using user.save() method.

// Fetch user instance
const user = suprClient.users.getEditInstance("__distinct_id__");

// Call user update methods
user.setTimezone("America/Los_Angeles");
user.set("name", "John Doe");

// Save Changes
const response = user.save(); // IMP: trigger request
response.then((res) => console.log("response", res));

Here’s a list of all edit methods:


After calling add*/remove*/unset methods, don’t forget to call the user.save() request. the changes will be sent to SuprSend only after calling this method.

Bulk API for updating multiple user profiles

To update multiple user profiles use Bulk API. There isn’t any limit on number-of-records that can be added to bulk_users instance. Use append() on bulk_users instance to add however-many-records to call in bulk.

const { Suprsend } = require("@suprsend/node-sdk");

const supr_client = new Suprsend("workspace_key", "workspace_secret");

const bulk_ins = supr_client.bulk_users.new_instance()

const user1 = supr_client.user.get_instance("_distinct_id_1") // user1 instance
user1.add_email("u1@example.com")
user1.set_preferred_language("en")

const user2 = supr_client.user.get_instance("_distinct_id_2") // user2 instance
user2.remove_email("u2@example.com")

//append users instance to bulk instance
bulk_ins.append(user1)
bulk_ins.append(user2)
// OR
bulk_ins.append(user1, user2)

 // trigger request
const response = bulk_ins.save()
response.then((res) => console.log("response", res));

Get user details

const response = await supr_client.users.get(__distinct_id__);

Delete User

const response = await supr_client.users.delete(__distinct_id__);

Get list of objects subscribed by user

const response = await supr_client.users.get_objects_subscribed_to(__distinct_id__, {limit:20});

You can pass optional query parameters - limit,before,after.

Get lists subscribed by user

const response = await supr_client.users.get_lists_subscribed_to(__distinct_id__, {limit:20});

You can pass optional query parameters - limit,before,after.