Set preferences of an account (admin)
curl --request PUT \
--url https://api.bbrands.io/api/v3/notification/preference \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"account": "6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40",
"channel": "email",
"category": "marketing",
"is_enabled": false,
"reason": "Customer asked by phone to stop marketing emails"
}
'import requests
url = "https://api.bbrands.io/api/v3/notification/preference"
payload = {
"account": "6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40",
"channel": "email",
"category": "marketing",
"is_enabled": False,
"reason": "Customer asked by phone to stop marketing emails"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account: '6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40',
channel: 'email',
category: 'marketing',
is_enabled: false,
reason: 'Customer asked by phone to stop marketing emails'
})
};
fetch('https://api.bbrands.io/api/v3/notification/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://api.bbrands.io/api/v3/notification/preference",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'account' => '6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40',
'channel' => 'email',
'category' => 'marketing',
'is_enabled' => false,
'reason' => 'Customer asked by phone to stop marketing emails'
]),
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://api.bbrands.io/api/v3/notification/preference"
payload := strings.NewReader("{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.bbrands.io/api/v3/notification/preference")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bbrands.io/api/v3/notification/preference")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"category": "marketing",
"channel": "email",
"is_enabled": true,
"user": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"is_actived": true,
"is_deleted": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"message": "<string>",
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}Preferences
Set Account Preferences (Admin)
Admin write of the preferences of any account, with a mandatory reason recorded in the audit log. Rows record the source horizon-enterprise-admin and the admin as user. Requires notification-preference:update.
- Without
accountin the query: one(channel, category)cell, or an event × channel override withnotification_event, of theaccountin the body. Answers the stored row. - With
?account=: a batch of up to 100changeswith onereason, as the Enterprise module sends it. Answers the new matrix of the account (category cells, event overrides and the preference history).
Only marketing can be switched off at category level; disabling a mandatory category, overriding an event that is not opt-out-able, or a category that does not match the event answers 400.
PUT
/
notification
/
preference
Set preferences of an account (admin)
curl --request PUT \
--url https://api.bbrands.io/api/v3/notification/preference \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"account": "6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40",
"channel": "email",
"category": "marketing",
"is_enabled": false,
"reason": "Customer asked by phone to stop marketing emails"
}
'import requests
url = "https://api.bbrands.io/api/v3/notification/preference"
payload = {
"account": "6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40",
"channel": "email",
"category": "marketing",
"is_enabled": False,
"reason": "Customer asked by phone to stop marketing emails"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account: '6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40',
channel: 'email',
category: 'marketing',
is_enabled: false,
reason: 'Customer asked by phone to stop marketing emails'
})
};
fetch('https://api.bbrands.io/api/v3/notification/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://api.bbrands.io/api/v3/notification/preference",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'account' => '6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40',
'channel' => 'email',
'category' => 'marketing',
'is_enabled' => false,
'reason' => 'Customer asked by phone to stop marketing emails'
]),
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://api.bbrands.io/api/v3/notification/preference"
payload := strings.NewReader("{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.bbrands.io/api/v3/notification/preference")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bbrands.io/api/v3/notification/preference")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account\": \"6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40\",\n \"channel\": \"email\",\n \"category\": \"marketing\",\n \"is_enabled\": false,\n \"reason\": \"Customer asked by phone to stop marketing emails\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"document_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"category": "marketing",
"channel": "email",
"is_enabled": true,
"user": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"is_actived": true,
"is_deleted": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
},
"message": "<string>",
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
"<unknown>"
],
"message": "<string>"
},
"meta": {
"correlation": "<string>",
"status": 123,
"timestamp": "2023-11-07T05:31:56Z",
"version": "<string>"
}
}Authorizations
bearerAuthapiKeyAuth
Query Parameters
Body
application/json
- Option 1
- Option 2
Single form (no account in the query).
Was this page helpful?