cURL
curl -X PATCH https://api.bodhveda.com/recipients/recipient_123/preferences \
-H "Authorization: Bearer bv_xxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"target": {
"channel": "posts",
"topic": "post_id_123",
"event": "new_comment"
},
"medium": "email",
"state": {
"enabled": false
}
}'import { Bodhveda } from "@bodhveda/js";
const bodhveda = new Bodhveda("bv_xxxxxxxxx");
const pref = await bodhveda.recipients.preferences.set("recipient_123", {
target: { channel: "posts", topic: "post_id_123", event: "new_comment" },
medium: "email",
state: { enabled: false },
});import (
"context"
bodhveda "github.com/MudgalLabs/bodhveda/sdk/go"
)
ctx := context.Background()
client := bodhveda.NewClient("bv_xxxxxxxxx", nil)
req := &bodhveda.SetPreferenceRequest{
Target: bodhveda.Target{Channel: "posts", Topic: "post_id_123", Event: "new_comment"},
Medium: bodhveda.MediumEmail,
}
req.State.Enabled = false
pref, _ := client.Recipients.Preferences.Set(ctx, "recipient_123", req)import { useUpdatePreference } from "@bodhveda/react";
// Requires a <BodhvedaProvider recipientID="recipient_123"> higher in the tree.
function Toggle() {
const { mutate } = useUpdatePreference();
return (
<button
onClick={() =>
mutate({
target: { channel: "posts", topic: "post_id_123", event: "new_comment" },
medium: "email",
state: { enabled: false },
})
}
>
Unsubscribe
</button>
);
}{
"data": {
"target": {
"channel": "posts",
"topic": "post_id_123",
"event": "new_comment",
"medium": "email"
},
"state": {
"enabled": false,
"inherited": false
}
}
}Preferences
Set preference
Set a recipient’s subscription state for a specific target.
PATCH
/
recipients
/
{recipient_id}
/
preferences
cURL
curl -X PATCH https://api.bodhveda.com/recipients/recipient_123/preferences \
-H "Authorization: Bearer bv_xxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"target": {
"channel": "posts",
"topic": "post_id_123",
"event": "new_comment"
},
"medium": "email",
"state": {
"enabled": false
}
}'import { Bodhveda } from "@bodhveda/js";
const bodhveda = new Bodhveda("bv_xxxxxxxxx");
const pref = await bodhveda.recipients.preferences.set("recipient_123", {
target: { channel: "posts", topic: "post_id_123", event: "new_comment" },
medium: "email",
state: { enabled: false },
});import (
"context"
bodhveda "github.com/MudgalLabs/bodhveda/sdk/go"
)
ctx := context.Background()
client := bodhveda.NewClient("bv_xxxxxxxxx", nil)
req := &bodhveda.SetPreferenceRequest{
Target: bodhveda.Target{Channel: "posts", Topic: "post_id_123", Event: "new_comment"},
Medium: bodhveda.MediumEmail,
}
req.State.Enabled = false
pref, _ := client.Recipients.Preferences.Set(ctx, "recipient_123", req)import { useUpdatePreference } from "@bodhveda/react";
// Requires a <BodhvedaProvider recipientID="recipient_123"> higher in the tree.
function Toggle() {
const { mutate } = useUpdatePreference();
return (
<button
onClick={() =>
mutate({
target: { channel: "posts", topic: "post_id_123", event: "new_comment" },
medium: "email",
state: { enabled: false },
})
}
>
Unsubscribe
</button>
);
}{
"data": {
"target": {
"channel": "posts",
"topic": "post_id_123",
"event": "new_comment",
"medium": "email"
},
"state": {
"enabled": false,
"inherited": false
}
}
}The
target here can be used to set a project pereference (global-level) or a (resource-level) preference.
You can use this API to :
- Allow recipient to update their project preference on the “Notification’s setting” screen.
- Allow recipient to subscribe to something. Example, “Subscribe a channel on YouTube” via
targetlikeyt_channel:mr_beast:new_videowithsubscribed: true.
Authorizations
Bearer authentication header of the form Bearer bv_xxxxxxxxx, where bv_xxxxxxxxx is your API Key with Full access or Recipient acess scope.
Path Parameters
The unique identifier of the recipient.
Body
application/json
A target is the structure used to describe who should get a notification and how it should be categorized.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
The medium this preference applies to. In-app and email are toggled independently for the same target. Defaults to in_app when omitted.
Available options:
in_app, email Response
200 - application/json
Updated subscription state for the target