In-app Notifications
Add Custom Notification
This process outlines the steps to add custom notifications to our Notifications component through an API.
POST
/
addnotification
To add a notification via the API to our Notifications component, send a POST request to https://api.velt.dev/addnotification
with the following body data.
Sample Post Request:
const options = {method: 'POST', body: JSON.stringify(body)};
fetch('https://api.velt.dev/addnotification', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Sample Body:
{
"data": {
"apiKey": "YOUR_API_KEY",
"authToken": "YOUR_AUTH_TOKEN",
"documentId": "YOUR_DOCUMENT_ID",
"actionUser": {
"email": "actionuseremail@domain", // required
"name": "Action Username", // optional
"photoUrl": "Action User Photo URL", // optional
"userId": "User ID", // required
},
"displayHeadlineMessageTemplate": "This is main template, you can pass variables using curly brackets like this: {actionUser}, {recipientUser}, {yourCustomVariableWithStringValue}",
"displayHeadlineMessageTemplateData": {
"actionUser": {
"email": "actionuseremail@domain", // required
"name": "Action Username", // optional
"photoUrl": "Action User Photo URL", // optional
"userId": "User ID", // required
},
"recipientUser": {
"email": "recipientuseremail@domain", // required
"name": "Recipient Username", // optional
"photoUrl": "Recipient User Photo URL", // optional
"userId": "User ID", // required
},
"yourCustomVariableWithStringValue": "Variable will be replaced with this text"
},
"displayBodyMessage": "This is body message (Secondary message)",
// Pass list of users who should be notified, notification will be shown to all the users in all section in notification panel and notification history panel, but it will be shown in 'forYou' section also to notifyUsers.
"notifyUsers": [
{
"email": "notifyuseremail@domain", // required
"name": "Notify User Name", // optional
"photoUrl": "Notify User Photo URL", // optional
"userId": "User ID", // required
}
]
}
}
Not sure where find your Auth Token? You can follow these steps to generate your Auth Token.
Success Response:
{
"result": {
"status": "success",
"message": "Notification added successfully.",
"data": null
}
}
Failure Response:
{
"error": {
"message": "Invalid Auth token.",
"status": "INVALID_ARGUMENT"
}
}
result
object
Response result
status
string
Status for the response
message
string
Status message for the response
data
N/A
Not used for this API call, should be null.
Was this page helpful?