Skip to main content
Version: 1.0.0

Using API to send notifications

In the previous chapter, we learned how to send a notification directly from the Engagespot dashboard. But that is not always the best solution. In most cases, notifications should be sent programatically from your code.

For example, if you're building a social network and you want to notify your users when another user comments on their photo, you need to integrate Engagespot API in your program, right?

Well, luckily, it's simple. Let's quickly learn how to send the below notification via Engagespot REST API.

img

info

Before sending notifications via the REST API, make sure you have sent your users information to Engagespot through front-end or backend SDKs / APIs. Read more about Users here.

Notifications sent to a recipient who has not yet identified by Engagespot will be discarded.

Consuming the REST API

To send notifications, you should send a POST request to https://api.engagespot.co/v3/notifications API with the following details.

var axios = require('axios');

axios.post(
'https://api.engagespot.co/v3/notifications',
{
notification: {
title: 'Rose accepted your friend request',
},
recipients: ['unique-user-identifier'],
},
{
headers: {
'X-ENGAGESPOT-API-KEY': 'YOUR_ENGAGESPOT_API_KEY',
'X-ENGAGESPOT-API-SECRET': 'YOUR_ENGAGESPOT_API_SECRET',
},
},
);

Where recipients is the list of users's unique id who should receive this notification.

What is unique-user-identifier?

Read more about Users here.

Detailed API Guide

There are other parameters you can pass to this send Notification API. You can learn more about them from the REST API reference page.

SDKs

We currently have wrappers in the following languages for communicatung with the REST API.