Brands API
Guide to create / update brands using go SDK
Brands are used for personalizing communication on behalf of some other entity/organization.
In SuprSend, Brands are workspace level entity. By default, SuprSend creates a brand with brand_id="default"
(representing your organization) in each of your workspaces. You can create more brands using one of our backend SDKs.
Data structure of Brand:
{
"brand_id": "br-01",
"brand_name": "Awesome Brand",
"logo": "https://ik.imagekit.io/l0quatz6utm/suprsend/staging/media/suprsend-only-logo_c8aa27faef118418e8c5bd7b31a1cafc74e09200.png",
"primary_color": "#ff0000",
"secondary_color": "#00ff00",
"tertiary_color": "#0000ff",
"social_links": {
"website": "https://suprsend.com",
"facebook": "",
"linkedin": "",
"twitter": "",
"instagram": "",
"medium": "",
"discord": "",
"telegram": "",
"youtube": "",
},
"properties": {
"prop1": "value1",
"prop2": "value2"
}
}
Field Description:
brand_id (*mandatory)
brand-id can be of max 64 characters. It can contain characters [a-z0-9_-] i.e. alphanumeric characters, _(underscore) and -(hyphen).
brand_id is case-insensitive. Suprsend will first converts brand_id to lowercase before storing it or doing any sort of comparison on it.
brand_name (*mandatory)
Name of the brand
logo (optional)
url of the brand logo
brand colors viz. primary_color, secondary_color, tertiary_color (optional)
brand colors settings are mainly used while designing templates.
If you don't provide any of the colors for the brand, SuprSend will assume you want to use the default values, so color settings will automatically be set to the color settings of default
brand.
social_links: (optional)
urls of social media accounts of the brand
While updating a social link, if you pass its value as null, then SuprSend will ignore it. If you really want to remove the value you must the value="" (instead of null)
e.g. If you want to remove social_link url for facebook
, you must pass facebook=""
{
"social_links": {
"facebook": ""
}
}
properties:
Custom properties associated with the brand.
Update operation on properties works like upsert on 1st-level keys (i.e. if top level key doesn't already exists, then it will added, otherwise its value will be replace by new value. All other key-value pair will remain unchanged).
e.g
1st update: {"properties": {"k1": "v1", "k2": 1.0}}
2nd update:{"properties": {"k1": "v2", "k3": {"nested_k": "v"}}}
after these 2 updates, value for properties will be
{ "k1": "v2", "k2": 1.0, "k3": { "nested_k": "v" } }
Accessing Brand using go
1. Upsert brand (Create a new Brand OR Update an existing Brand)
brandPayload := &suprsend.Brand{
BrandName: suprsend.String("Brand Name"),
Logo: suprsend.String("Brand logo url"),
PrimaryColor: suprsend.String("#FFFFFF"),
SecondaryColor: suprsend.String("#000000"),
TertiaryColor: nil,
SocialLinks: &suprsend.BrandSocialLinks{
Facebook: suprsend.String("https://facebook.com/brand"),
},
Properties: map[string]interface{}{
"k1": "brand settings 1",
"k2": "brand settings 2",
},
}
res, err := suprClient.Brands.Upsert(context.Background(), "__brand_id__", brandPayload)
if err != nil {
log.Fatalln(err)
}
log.Println(res)
2. Get brand data
brand1, err := suprClient.Brands.Get(context.Background(), "__brand_id__")
if err != nil {
log.Fatalln(err)
}
log.Println(brand1)
3. Brands list api
By default limit=20
. Value for limit must be < 1000
brandsList, err := suprClient.Brands.List(context.Background(), &suprsend.BrandListOptions{Limit: 10})
if err != nil {
log.Fatalln(err)
}
log.Println(brandsList)
Updated about 2 years ago