Update User Preferences
Update User Full Preference
API to update user preferences across all channels and categories with translated names and descriptions in the response.
PATCH
/
v1
/
user
/
{distinct_id}
/
preference
/
Update User Full Preference
curl --request PATCH \
--url https://hub.suprsend.com/v1/user/{distinct_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",
"opt_out_channels": [],
"opt_in_channels": [],
"digest_schedule": {
"id": "weekly-on-weekdays",
"time": "10:00"
},
"properties": [
{
"key": "threshold",
"value": "500"
}
]
}
]
}
'import requests
url = "https://hub.suprsend.com/v1/user/{distinct_id}/preference/"
payload = {
"channel_preferences": [
{
"channel": "email",
"is_restricted": False
}
],
"categories": [
{
"category": "weekly-activity-digest",
"preference": "opt_in",
"opt_out_channels": [],
"opt_in_channels": [],
"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',
opt_out_channels: [],
opt_in_channels: [],
digest_schedule: {id: 'weekly-on-weekdays', time: '10:00'},
properties: [{key: 'threshold', value: '500'}]
}
]
})
};
fetch('https://hub.suprsend.com/v1/user/{distinct_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/user/{distinct_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',
'opt_out_channels' => [
],
'opt_in_channels' => [
],
'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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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": "user [distinct_id: 'user1'] not found"
}Authorizations
Body
application/json
⌘I
Update User Full Preference
curl --request PATCH \
--url https://hub.suprsend.com/v1/user/{distinct_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",
"opt_out_channels": [],
"opt_in_channels": [],
"digest_schedule": {
"id": "weekly-on-weekdays",
"time": "10:00"
},
"properties": [
{
"key": "threshold",
"value": "500"
}
]
}
]
}
'import requests
url = "https://hub.suprsend.com/v1/user/{distinct_id}/preference/"
payload = {
"channel_preferences": [
{
"channel": "email",
"is_restricted": False
}
],
"categories": [
{
"category": "weekly-activity-digest",
"preference": "opt_in",
"opt_out_channels": [],
"opt_in_channels": [],
"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',
opt_out_channels: [],
opt_in_channels: [],
digest_schedule: {id: 'weekly-on-weekdays', time: '10:00'},
properties: [{key: 'threshold', value: '500'}]
}
]
})
};
fetch('https://hub.suprsend.com/v1/user/{distinct_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/user/{distinct_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',
'opt_out_channels' => [
],
'opt_in_channels' => [
],
'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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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/user/{distinct_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 \"opt_out_channels\": [],\n \"opt_in_channels\": [],\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": "user [distinct_id: 'user1'] not found"
}