This section will walk you through sending notifications to your users and retrieving notifications sent to a user to familiarize your with the API before you explore all available API endpoints.
The examples below utilize the curl
command line tool to send HTTP requests. If you'd like to see examples in a different programming language, please contact us at [email protected]
Firstly, sign up for MagicBell at magicbell.io and obtain your MagicBell Project's API Key and API Secret. The API Key and API Secret are available in your MagicBell Project's "Project Settings" page.
Send a notification
Send a notification to one user
The Create Notification API endpoint can be utilized to send a notification to a user.
Copy the example below and paste it in a Terminal on your machine. Be sure to replace the words yourmagicbellapikey
and yourmagicbellapisecret
with your actual API Key and API Secret
curl https://api.magicbell.io/notifications \
--request POST \
--header 'X-MAGICBELL-API-KEY: yourmagicbellapikey' \
--header 'X-MAGICBELL-API-SECRET: yourmagicbellapisecret' \
--data '{
"notification": {
"title": "Task assigned to you: Upgrade to Startup plan",
"content": "Hello, can you upgrade us to the Startup plan. Thank you.",
"category": "new_message",
"action_url": "https://magicbell.io/pricing",
"recipients": [{
"email": "[email protected]"
}]
}
}'
Now, visit MagicBell in your browser and click on the "Embed" section in the left sidebar. You should see the notification that you just sent to [email protected]
in the Embeddable Notification Inbox.
Send a notification to many users
The Create Notification can also be utilized to send a notification to many users.
Copy the example below and paste in your Terminal. Be sure to replace the words yourmagicbellapikey
and yourmagicbellapisecret
with your actual API Key and API Secret
curl https://api.magicbell.io/notifications \
--request POST \
--header 'X-MAGICBELL-API-KEY: yourmagicbellapikey' \
--header 'X-MAGICBELL-API-SECRET: yourmagicbellapisecret' \
--data '{
"notification": {
"title": "Task assigned to you: Upgrade to Startup plan",
"content": "Hello, can you upgrade us to the Startup plan. Thank you.",
"category": "new_message",
"action_url": "https://magicbell.io/pricing",
"recipients": [{
"email": "[email protected]"
},
{
"email": "[email protected]"
}
]
}
}'
Now, visit MagicBell in your browser and click on the "Embed" section in the left sidebar. You should see the notification that you just sent to [email protected]
in the Embeddable Notification Inbox. [email protected]
will also see the notification in their Embeddable Notification Inbox.
Retrieve sent notifications
Most of our customers embed the Embeddable Notification Inbox in their web applications. The Notification Inbox is fairly customizable and you can customize the icon color, unseen notifications badge color, text color and background color to suit your brand. However, few of our customers have gone further utilized our API to build a custom Notification Inbox specific to their application. If you intend to do the same, you likely want your custom Notification Inbox to retrieve a user's notifications. The Fetch User Notifications API endpoint can be utilized to retrieve notifications sent to a user.
Copy the example below and paste it in a Terminal on your machine to retrieve the notification you sent previously. Be sure to replace the words yourmagicbellapikey
with your actual API key
curl https://api.magicbell.io/notifications \
--request GET \
--header 'X-MAGICBELL-API-KEY: yourmagicbellapikey' \
--header 'X-MAGICBELL-USER-EMAIL: [email protected]'
Updated about a month ago