Tenants (previously named as brands) are used for whitelabelling notifications, personliazing template content or capturing admin preferences for another entity/organization. Tenants are workspace-level entities and by default, a tenant with tenant_id="default" (representing your organization) is created your workspace. Read more about tenants here.

Create / Update Tenant

This method will create a new tenant or update an existing tenant.

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

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

const tenant_payload = {...} // prepare tenant datastructure payload

// ---- Optional Parameters -------
const requestData = {
    secondary_color: "#00ff00",
    tertiary_color: "#0000ff",
    timezone: "America/New_York",
    blocked_channels: ["email"], // These channels will be skipped for sending notifications to recipients when triggering for this tenant.
    social_links: {
        website: "https://suprsend.com",
        facebook: "",
        linkedin: "",
        twitter: "",
        instagram: "",
        medium: "",
        discord: "",
        telegram: "",
        youtube: ""
    },
    embedded_preference_url: "", // In-product Notification center link for capturing user preferences.
    properties: {
        prop1: "value1",
        prop2: { prop3: ["value2"] }
    }
};

const response = supr_client.tenants.upsert(tenant_id, tenant_payload); // create or update tenant
response.then((res) => console.log("response", res));
FieldDescription
tenant_id (mandatory)max 64 characters and should contains alphanumeric characters(a-z, 0-9), hyphen (-) and underscode(_).
tenant_name (mandatory)name of the tenant.
colors (primary, secondary, tertiary)used while designing templates. If not provided default tenant colour will be picked.
social_linkssocial links to your tenant. Pass "" if you want to remove existing link.
propertiesCustom properties associated with the tenant. Update operation is upsert (new properties are added to existing one’s and if key is already present, value is overridden).

All properties of the tenant can be referred as {{$tenant.prop}} (handlebars) or data["tenant"].prop in JSONNET format.

Get Tenant

const response = supr_client.tenants.get(tenant_id)

List Tenants

By default, limit=20. The maximum value for limit is 1000.

const response = supr_client.tenants.list();  // default limit 20
const response = supr_client.tenants.list({limit:20, offset:0}); //  max limit 1000

Add tenant in Workflow

const wf = new Workflow(workflow_body, {tenant_id :  "_tenant_id_"})

Add tenant in Event

const event = new Event(distinct_id, event_name, properties, {tenant_id :  "_tenant_id_"})