Send notifications via our API
Last updated
Last updated
Owners of decentralized apps (dApps) want to send notifications to their users, to be displayed in the FE of their respective dApps.
CNS will be used as a platform for dApps to send notifications and CNS will be responsible for streaming these notifications to the FE of their dApps.
A REST API endpoint will be exposed by CNS for dApps to send notifications to our platform.
We would have separate endpoints for different media platforms, for example, POST /channel/{channelId}/message
for in-app notifications and POST /channel/{channelId}/message/telegram
for telegram notifications. Most of the fields in the request body are identical for both endpoints, except platform-specific fields, such as parse_mode
for telegram notifications.
POST /channel/{channelId}/message
- Send in-app notification
Request Component | Name | Type | Description | isRequired |
---|---|---|---|---|
Note:
Infra setup will be in place to restrict API access to selected dApps using the API (Kaching would be our first dApp partner). API Authentication using mechanisms like API keys might be considered in the future but not supported in MVP.
Example Request:
Copy
Copy
Response Body:
No JSON response body needed to be returned
Successful response will return status code 204
POST /channel/{channelId}/message/telegram
- Send telegram notification
Example Request:
Copy
Copy
Response Body:
No JSON response body needed to be returned
A successful response will return status code 204
Request Component | Name | Type | Description | isRequired |
---|---|---|---|---|
Request Headers
CNS-Api-Key
String
API Key required to call the API
Yes
Path Variable
channelId
String
Channel ID associated with the dApp
Yes
Request Body
delivery_type
String
BROADCAST
- send to all users, UNICAST
- send to selected user
Yes
receiver_address
String
Can be omitted if delivery_type
is BROADCAST
, else wallet address of recipient
No/Yes
title
String
Title of the notification (max 1024 chars), no restrictions on the format
Yes
body
String
Body of the notification (max 4096 chars), no restrictions on the format
Yes
type
String
Type the notification (max 50 chars)
Yes
chain_id
Int
Chain ID of the notification to send
Yes
event_timestamp
Timestamp
Timestamp when the notification is triggered on DApp, if not set it'll be the time when CNS got the request
No
Request Headers
CNS-Api-Key
String
API Key required to call the API
Yes
Path Variable
channelId
String
Channel ID associated with the dApp
Yes
Request Body
delivery_type
String
BROADCAST
- send to all users, UNICAST
- send to selected user
Yes
receiver_address
String
Can be omitted if delivery_type
is BROADCAST
, else wallet address of recipient
No/Yes
body
String
Body of the notification (max 4096 chars), no restriction on the format
Yes
type
String
Type the notification (max 50 chars)
Yes
parse_mode
String
Content format options of Telegram, available options are: MarkdownV2, HTML, Markdown, by default there'll be no format
No