Skip to main content
PATCH
/
v1
/
object
/
{object_type}
/
{id}
/
preference
/
Update Object Full Preference
curl --request PATCH \
  --url https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/ \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "channel_preferences": [
    {
      "channel": "email",
      "is_restricted": false
    }
  ],
  "categories": [
    {
      "category": "weekly-activity-digest",
      "preference": "opt_in",
      "digest_schedule": {
        "id": "weekly-on-weekdays",
        "time": "10:00"
      },
      "properties": [
        {
          "key": "threshold",
          "value": "500"
        }
      ]
    }
  ]
}
'
import requests

url = "https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/"

payload = {
"channel_preferences": [
{
"channel": "email",
"is_restricted": False
}
],
"categories": [
{
"category": "weekly-activity-digest",
"preference": "opt_in",
"digest_schedule": {
"id": "weekly-on-weekdays",
"time": "10:00"
},
"properties": [
{
"key": "threshold",
"value": "500"
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
channel_preferences: [{channel: 'email', is_restricted: false}],
categories: [
{
category: 'weekly-activity-digest',
preference: 'opt_in',
digest_schedule: {id: 'weekly-on-weekdays', time: '10:00'},
properties: [{key: 'threshold', value: '500'}]
}
]
})
};

fetch('https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'channel_preferences' => [
[
'channel' => 'email',
'is_restricted' => false
]
],
'categories' => [
[
'category' => 'weekly-activity-digest',
'preference' => 'opt_in',
'digest_schedule' => [
'id' => 'weekly-on-weekdays',
'time' => '10:00'
],
'properties' => [
[
'key' => 'threshold',
'value' => '500'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/"

payload := strings.NewReader("{\n \"channel_preferences\": [\n {\n \"channel\": \"email\",\n \"is_restricted\": false\n }\n ],\n \"categories\": [\n {\n \"category\": \"weekly-activity-digest\",\n \"preference\": \"opt_in\",\n \"digest_schedule\": {\n \"id\": \"weekly-on-weekdays\",\n \"time\": \"10:00\"\n },\n \"properties\": [\n {\n \"key\": \"threshold\",\n \"value\": \"500\"\n }\n ]\n }\n ]\n}")

req, _ := http.NewRequest("PATCH", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.patch("https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"channel_preferences\": [\n {\n \"channel\": \"email\",\n \"is_restricted\": false\n }\n ],\n \"categories\": [\n {\n \"category\": \"weekly-activity-digest\",\n \"preference\": \"opt_in\",\n \"digest_schedule\": {\n \"id\": \"weekly-on-weekdays\",\n \"time\": \"10:00\"\n },\n \"properties\": [\n {\n \"key\": \"threshold\",\n \"value\": \"500\"\n }\n ]\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://hub.suprsend.com/v1/object/{object_type}/{id}/preference/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channel_preferences\": [\n {\n \"channel\": \"email\",\n \"is_restricted\": false\n }\n ],\n \"categories\": [\n {\n \"category\": \"weekly-activity-digest\",\n \"preference\": \"opt_in\",\n \"digest_schedule\": {\n \"id\": \"weekly-on-weekdays\",\n \"time\": \"10:00\"\n },\n \"properties\": [\n {\n \"key\": \"threshold\",\n \"value\": \"500\"\n }\n ]\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "sections": [
    {
      "name": null,
      "slug": null,
      "subcategories": [
        {
          "name": "Weekly Activity Digest",
          "category": "weekly-activity-digest",
          "description": "Summary of recent activity in your workspace",
          "original_preference": "opt_in",
          "preference": "opt_in",
          "is_editable": true,
          "channels": [
            {
              "channel": "email",
              "preference": "opt_in",
              "is_editable": true
            }
          ],
          "digest_schedule": {
            "id": "weekly-on-weekdays",
            "label": "Every week on Mon–Fri · time set by recipient (default: 9:00 AM)",
            "frequency": "weekly_mo2fr",
            "interval": 1,
            "time": "10:00",
            "weekdays": [
              "mo",
              "tu",
              "we",
              "th",
              "fr"
            ],
            "is_default": false,
            "is_user_selected": true
          },
          "properties": [
            {
              "key": "threshold",
              "label": "Minimum activity count",
              "value_type": "string",
              "default_value": "100",
              "is_optional": false,
              "edit_policy": "editable",
              "is_overridden": true,
              "value": "500"
            }
          ]
        }
      ]
    }
  ],
  "channel_preferences": [
    {
      "channel": "email",
      "is_restricted": false
    }
  ]
}
{
"code": 404,
"message": "object 'object_type/id' not found"
}

Authorizations

Authorization
string
header
required

Pass as Bearer <API_KEY>. Get API Key from SuprSend dashboard Developers -> API Keys section.

Path Parameters

object_type
string
required

Used to group similar objects together. Give plural namespace like teams, organizations, and roles.

id
string
required

Unique identifier of the object in your system

Query Parameters

tenant_id
string

to update object preferences for a particular tenant

Body

application/json
channel_preferences
object[]

Use this to update channel level object preferences. Set is_restricted - true if the channel is opted_out. This will only send critical notifications which can't be opted out

categories
object[]

Use this to update object preference across categories and channels inside a category.

Response

200

sections
object[]
channel_preferences
object[]