Skip to main content

Manage subscriptions overview

These APIs are useful for managing subscriptions for specific channels including subscribing to a channel, indicating settings for a channel or unsubscribing from a channel.

Subscribe channel API

Channel is any protocol that has activated themselves to send notifications. User needs to subscribe to a channel to enable that channel notifications to come to their inbox (and not land in spam). User can also setup settings along with a channel subscription though it's upto the channel to honor those.

// userAlice.notification.subscribe(channel, {settings?})
const response = await userAlice.notification.subscribe(
`eip155:11155111:${channelAddress}`
);

// Another example but with settings
const response = await userAlice.notification.subscribe(
`eip155:11155111:${channelAddress}`,
{
settings: [
// settings are dependent on channel
{ enabled: true, value: '1' }, // setting 1
{ enabled: false }, // setting 2
{ enabled: true, value: '50' }, // setting 3
],
}
);

Subscribe channel parameters

ParamTypeSubtypeDefaultRemarks
channelstring--Channel/Alias address in chain specific wallet format
settingsarray of objects--Contain array of individual setting object

Note: Parameters in this style are mandatory.

Individual setting object

ParamTypeSubtypeDefaultRemarks
settingobject--Individual setting object
-enabledbooleantrueIndicates if setting is enabled or disabled
-valuestring-The value set by the user
Expected response
{ status: 204, message: 'successfully opted into channel' }

Unsubscribe channel API

// userAlice.notification.unsubscribe(channel)
const unsubscribeResponse = await userAlice.notification.unsubscribe(
`eip155:11155111:${channelAddress}` // channel to unsubscribe
);

Unsubscribe channel parameters

ParamTypeSubtypeDefaultRemarks
channelstring--Channel/Alias address in CAIP format

Note: Parameters in this style are mandatory.

Expected response
{ status: 204, message: 'successfully opted out channel' }