Notification Resource
Authorization
Currently notifications are only able to access the API while they are signed into the application. The API requires the access_token
cookie to be present in the request.
Restrictions
There are various restrictions applied to the notification data. The following are some of the important restrictions when creating a notification. Each notification may also have unique values that are not required for others and will be stored in the data
object field.
Platform
- Currently limited to the following platforms:
- Discord
- Slack
- Telegram
- Webhooks
Message Type
- Message type must be one of the following:
- Basic
- Pretty
- Nerdy
Token
- This is the url or authorization token for the notification:
- For Discord this is the webhook url
- For Slack this is the webhook url
- For Telegram this is the bot token
- For Webhooks this is the url
Platform specific requirements
Notification Object
Notification Structure
Field | Type | Description |
---|---|---|
id | string | Unique id for the monitor |
platform | string | One of the following: Discord, Slack, Telegram, Webhooks |
messageType | string | One of the following: basic, pretty, nerdy |
token | string | Token/url for the platform |
string | Email address for the user who created the monitor | |
isEnabled | boolean | Boolean if the notification is enabled |
content | string | Additional content for the notification |
friendlyName | string | Friendly name for the notification |
data | object | Object containing information about the notification (Varies by platform) |
createdAt | date | Timestamp of when the notification was created |
Example Notification
{
"id": "d8a53324-6c1b-410c-be0e-c17a99d862e6",
"platform": "Discord",
"messageType": "basic",
"token": "https://discord.com/api/webhooks/XXXXXXXXX/XXXXXXXXXXXXXXX",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true,
"content": "@everyone Ping! Alert from Lunalytics!",
"friendlyName": "Lunalytics",
"data": {},
"createdAt": "2024-11-03 12:00:00"
}
{
"id": "d8a53324-6c1b-410c-be0e-c17a99d862e6",
"platform": "Slack",
"messageType": "nerdy",
"token": "https://hooks.slack.com/services/XXXXXXX/XXXXXXXXXXX/X43XxxxXX2XxxxXX",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true,
"content": null,
"friendlyName": "Lunalytics",
"data": { "channel": "#general", "username": "Lunalytics" },
"createdAt": "2024-11-03 12:00:00"
}
{
"id": "d8a53324-6c1b-410c-be0e-c17a99d862e6",
"platform": "Telegram",
"messageType": "pretty",
"token": "",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true,
"content": "",
"friendlyName": "Lunalytics",
"data": {},
"createdAt": "2024-11-03 12:00:00"
}
{
"id": "d8a53324-6c1b-410c-be0e-c17a99d862e6",
"platform": "Webhook",
"messageType": "nerdy",
"token": "https://lunalytics.xyz/api/webhook/alert",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true,
"content": null,
"friendlyName": "Lunalytics",
"data": { "requestType": "form-data" },
"createdAt": "2024-11-03 12:00:00"
}
Get all notifications
GET /api/notifications
Returns an array of notifications. Only editors, admins, and owners are allowed to access this endpoint.
HTTP Response Codes
Status Code | Description |
---|---|
200 | Success, returns an array of notifications |
401 | Unauthorized (Missing access_token cookie or API Token) |
curl -X GET \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
'https://lunalytics.xyz/api/notifications'
axios('/api/notifications', {
method: 'GET',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
});
Get a specific notification
GET /api/notifications/id
Returns a notification for the given id. Only editors, admins, and owners are allowed to access this endpoint.
Query Parameters
notificationId
String
HTTP Response Codes
Status Code | Description |
---|---|
200 | Success, returns an object for notification |
401 | Unauthorized (Missing access_token cookie or API Token) |
404 | Notification not found |
curl -X GET \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
-d "notificationId=4d048471-9e85-428b-8050-4238f6033478" \
'https://lunalytics.xyz/api/notifications/id'
axios('/api/notifications/id', {
method: 'GET',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
params: {
notificationId: '4d048471-9e85-428b-8050-4238f6033478',
},
});
Create a new notification
POST /api/notifications/create
Create a new notification and returns the notification object. Only editors, admins, and owners are allowed to access this endpoint.
Payload
{
"platform": "Disord",
"messageType": "pretty",
"friendlyName": "Lunalytics",
"textMessage": "Ping @everyone",
"token": "https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx",
"username": "Lunalytics"
}
{
"platform": "Slack",
"channel": "XXXXXXXXXXXX",
"friendlyName": "Lunalytics",
"messageType": "pretty",
"textMessage": "Ping @here",
"token": "https://hooks.slack.com/services/xxxxxxxxx/xxxxxx/xxxxx",
"username": "Lunalytics"
}
{
"platform": "Telegram",
"chatId": "xxxxxxxxxx",
"disableNotification": false,
"friendlyName": "Lunalytics",
"messageType": "pretty",
"protectContent": false,
"token": "xxxxxxxxxxxxxxx"
}
{
"platform": "Webhook",
"friendlyName": "Lunalytics",
"messageType": "pretty",
"requestType": "application/json",
"showAdditionalHeaders": true,
"additionalHeaders": {},
"token": "https://lunalytics.xyz/api/webhook/alert"
}
HTTP Response Codes
Status Code | Description |
---|---|
201 | Success, returns an object for notification |
401 | Unauthorized (Missing access_token cookie or API Token) |
422 | Return a notification error (Format: {key: 'message'} ) |
curl -X POST \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
--data '{"messageType": "pretty", "friendlyName": "Lunalytics", "textMessage": "Ping @everyone", "token": "https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx", "username": "Lunalytics"}' \
'https://lunalytics.xyz/api/notifications/create'
axios('/api/notifications/create', {
method: 'GET',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
data: {
messageType: 'pretty',
friendlyName: 'Lunalytics',
textMessage: 'Ping @everyone',
token: 'https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx',
username: 'Lunalytics',
},
});
Edit a notification
POST /api/notifications/edit
Edit an existing notification and returns the notification object. Only editors, admins, and owners are allowed to access this endpoint.
Payload
{
"messageType": "pretty",
"friendlyName": "Lunalytics",
"textMessage": "Ping @everyone",
"token": "https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx",
"username": "Lunalytics",
"id": "4d048471-9e85-428b-8050-4238f6033478",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true
}
{
"channel": "XXXXXXXXXXXX",
"friendlyName": "Lunalytics",
"messageType": "pretty",
"textMessage": "Ping @here",
"token": "https://hooks.slack.com/services/xxxxxxxxx/xxxxxx/xxxxx",
"username": "Lunalytics",
"id": "4d048471-9e85-428b-8050-4238f6033478",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true
}
{
"chatId": "xxxxxxxxxx",
"disableNotification": false,
"friendlyName": "Lunalytics",
"messageType": "pretty",
"protectContent": false,
"token": "xxxxxxxxxxxxxxx",
"id": "4d048471-9e85-428b-8050-4238f6033478",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true
}
{
"friendlyName": "Lunalytics",
"messageType": "pretty",
"requestType": "application/json",
"showAdditionalHeaders": true,
"additionalHeaders": {},
"token": "https://lunalytics.xyz/api/webhook/alert",
"id": "4d048471-9e85-428b-8050-4238f6033478",
"email": "KSJaay@lunalytics.xyz",
"isEnabled": true
}
HTTP Response Codes
Status Code | Description |
---|---|
200 | Success, returns an object for notification |
401 | Unauthorized (Missing access_token cookie or API Token) |
422 | Return a notification error (Format: {key: 'message'} ) |
curl -X POST \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
--data '{"messageType": "pretty", "friendlyName": "Lunalytics", "textMessage": "Ping @everyone", "token": "https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx", "username": "Lunalytics"}' \
'https://lunalytics.xyz/api/notifications/edit'
axios('/api/notifications/edit', {
method: 'GET',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
data: {
messageType: 'pretty',
friendlyName: 'Lunalytics',
textMessage: 'Ping @everyone',
token: 'https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx',
username: 'Lunalytics',
},
});
Delete a specific notification
GET /api/notifications/delete
Deletes the notification using the given notificationId. Only editors, admins, and owners are allowed to access this endpoint.
Query Parameters
notificationId
String
HTTP Response Codes
Status Code | Description |
---|---|
200 | Success |
401 | Unauthorized (Missing access_token cookie or API Token) |
422 | No notificationId provided |
curl -X POST \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
-d "notificationId=4d048471-9e85-428b-8050-4238f6033478" \
'https://lunalytics.xyz/api/notifications/delete'
axios('/api/notifications/delete', {
method: 'POST',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
params: {
notificationId: '4d048471-9e85-428b-8050-4238f6033478',
},
});
Toggle a specific notification
GET /api/notifications/toggle
Toggle the notification using the given notificationId and isEnabled query parameter. Only editors, admins, and owners are allowed to access this endpoint.
Query Parameters
notificationId
String
isEnabled
Boolean
HTTP Response Codes
Status Code | Description |
---|---|
200 | Success |
401 | Unauthorized (Missing access_token cookie or API Token) |
422 | No notificationId provided or isEnabled is not a boolean |
curl -X POST \
-H "Content-Type:application/json" \
-H "Authorization:API Token" \
-d "notificationId=4d048471-9e85-428b-8050-4238f6033478&isEnabled=true" \
'https://lunalytics.xyz/api/notifications/toggle'
axios('/api/notifications/toggle', {
method: 'POST',
headers: {
Authorization: 'API Token',
'Content-Type': 'application/json',
},
params: {
notificationId: '4d048471-9e85-428b-8050-4238f6033478',
isEnabled: 'true',
},
});