To receive notifications on your device, log in to Alert Hero, follow the prompts to install Alert Hero as an app if desired (this is necessary in order to receive notifications on iOS devices), and enable notifications on the homepage.
To send notifications, create an API key and use it to call the API as in the examples below.
const payload = { title: 'Notification title', body: 'Notification body (optional)' };
const response = await fetch('https://alert-hero.com/api/v1/send-notification', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.ALERT_HERO_API_KEY}`,
},
body: JSON.stringify(payload),
});import requests
import os
import json
payload = {'title': 'Notification title', 'body': 'Notification body (optional)'}
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {os.getenv("ALERT_HERO_API_KEY")}'
}
response = requests.post('https://alert-hero.com/api/v1/send-notification',
headers=headers,
data=json.dumps(payload))$payload = json_encode([
'title' => 'Notification title',
'body' => 'Notification body (optional)',
]);
$ch = curl_init('https://alert-hero.com/api/v1/send-notification');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . getenv('ALERT_HERO_API_KEY'),
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);payload='{"title": "Notification title", "body": "Notification body (optional)"}'
curl "https://alert-hero.com/api/v1/send-notification" -H "Content-Type: application/json" -H "Authorization: Bearer $ALERT_HERO_API_KEY" -d "$payload"