Set topic subscriptions
Upserts explicit subscribed or unsubscribed status for one channel.
POST
Upserts explicit subscribed or unsubscribed status for one channel. Each contact is named by ID, email, or phone. New addresses create contacts in the topic's namespace. Repeating the same status is idempotent. On email, setting subscribed never overrides a contact's explicit unsubscribe: those contacts are counted in kept, and only the recipient can resubscribe them.
apiKeyheader
x-api-key<token>id*stringMatch
^tpc_[0-9a-hjkmnp-tv-z]{16,24}$application/json- body
contacts*array<||>Items
1 <= items <= 1000channel*stringValue in
"sms""whatsapp""email"status*stringValue in
"subscribed""unsubscribed"source?|nullTopicSetSubscriptionsResult
application/json- response
updated*integerRange
0 <= value <= 9007199254740991kept*integerEmail contacts left unsubscribed because they explicitly unsubscribed from this topic. Only the recipient can resubscribe them, through the preference page or double opt-in.
Range
0 <= value <= 9007199254740991import { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.topics.setSubscriptions({
"id": "example",
"contacts": [
{
"contactId": "example"
}
],
"channel": "sms",
"status": "subscribed"
});Example Response
{
"updated": 0,
"kept": 0
}