Skip to main content

Send notification overview

This section covers all APIs related to sending notifications from a created channel.

Send notification API

// userAlice.channel.send([recipients], {options?})
const sendNotifRes = await userAlice.channel.send(['*'], {
notification: { title: 'test', body: 'test' },
});

Send notification parameters

ParamTypeSubtypeDefaultRemarks
recipientsstring[]--An array of recipient addresses passed in any supported wallet address format. Possible values are: Broadcast -> [*], Targeted -> [0xA], Subset -> [0xA, 0xB], see types of notifications for more info.
optionsNotificationOptions--Configuration options for sending notifications.
-options.notificationINotification-An object containing the notification's title and body. (Mandatory)
-options.notification.titlestring-The title for the notification. If not provided, it is taken from notification.title.
-options.notification.bodystring-The body of the notification. If not provided, it is taken from notification.body.
-options.secretstring-Type of encryption standard to use for sending encrypted notification. Accepts eitherPGPV1 or LITV1.
-options.payloadIPayload-An object containing additional payload information for the notification.
-options.payload.titlestring-The title for the notification. If not provided, it is taken from notification.title.
-options.payload.bodystring-The body of the notification. If not provided, it is taken from notification.body.
-options.payload.ctastring-Call to action for the notification.
-options.payload.embedstring-Media information like image/video links
-options.payload.categorystring-Don't pass category if you are sending a generic notification. Notification category represents index point of each individual settings. Pass this if you want to indicate what category of notification you are sending (If channel has settings enabled). For example, if a channel has 10 settings, then a notification of category 7 indicates it's a notification sent for setting 7, if user has turned setting 7 off then Push ndoes will stop notif from getting to the user.
-options.payload.meta{ domain?: string, type: string, data: string }-Metadata for the notification, including domain, type, and data.
-options.configIConfig-An object containing configuration options for the notification.
-options.config.expirynumber-Expiry time for the notification in seconds
-options.config.silentboolean-Indicates whether the notification is silent.
-options.config.hiddenboolean-Indicates whether the notification is hidden.
-options.advancedIAdvance-An object containing advanced options for the notification.
-options.advanced.graph{ id: string, counter: number }-Advanced options related to the graph based notification.
-options.advanced.ipfsstring-IPFS information for the notification.
-options.advanced.minimalstring-Minimal Payload type notification.
-options.advanced.chatidstring-For chat based notification.
-options.advanced.pgpPrivateKeystring-PGP private key for chat based notification.
-options.channelstring-Channel address in CAIP. Mostly used when a delegator sends a notification on behalf of the channel

Note: Parameters in this style are mandatory.

Expected response
// PushAPI.payloads.sendNotification | Response - 204 OK

Send notification interface

interface INotification {
title: string;
body: string;
}

interface IPayload {
title?: string;
body?: string;
cta?: string;
embed?: string;
category?: number;
meta?: {
domain?: string;
type: string;
data: string;
};
}

interface IConfig {
expiry?: number;
silent?: boolean;
hidden?: boolean;
}

interface IAdvanced {
graph?: {
id: string;
counter: number;
};
ipfs?: string;
minimal?: string;
chatid?: string;
pgpPrivateKey?: string;
}

interface NotificationOptions = {
notification: INotification;
payload?: IPayload;
config?: IConfig;
advanced?: IAdvance;
channel?: string;
};

// Usage example:
const apiResponse: ApiResponse = await userAlice.channel.send(recipients, {
// NotificationOptions - as per your given object structure
});

Encrypted notification example

Push Protocol supports sending encrypted notifications, which can only be decrypted by the intended recipients. You can send encrypted notifications to targeted/subsets of users. Currently, Push Notification supports two encryption standards: PGPV1 and LITV1. Use LITV1 to use Lit Protocol encryption and PGPV1 to use PGP_V1 encryption.

// userAlice.channel.send([recipients], {options?})
const sendNotifRes = await userAlice.channel.send(['AliceWalletAddress'], {
notification: { title: 'test', body: 'test' },
secret: 'PGPV1', // or "LITV1"
});