Skip to content

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

FieldTypeDescription
idstringUnique id for the monitor
platformstringOne of the following: Discord, Slack, Telegram, Webhooks
messageTypestringOne of the following: basic, pretty, nerdy
tokenstringToken/url for the platform
emailstringEmail address for the user who created the monitor
isEnabledbooleanBoolean if the notification is enabled
contentstringAdditional content for the notification
friendlyNamestringFriendly name for the notification
dataobjectObject containing information about the notification (Varies by platform)
createdAtdateTimestamp of when the notification was created

Example Notification

json
{
  "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"
}
json
{
  "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"
}
json
{
  "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"
}
json
{
  "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 CodeDescription
200Success, returns an array of notifications
401Unauthorized (Missing access_token cookie or API Token)
curl -X GET \
  -H "Content-Type:application/json" \
  -H "Authorization:API Token" \
    'https://lunalytics.xyz/api/notifications'
js
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 CodeDescription
200Success, returns an object for notification
401Unauthorized (Missing access_token cookie or API Token)
404Notification 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'
js
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

json
{
  "platform": "Disord",
  "messageType": "pretty",
  "friendlyName": "Lunalytics",
  "textMessage": "Ping @everyone",
  "token": "https://discord.com/api/webhook/xxxxxxxxxx/xxxxxxx",
  "username": "Lunalytics"
}
json
{
  "platform": "Slack",
  "channel": "XXXXXXXXXXXX",
  "friendlyName": "Lunalytics",
  "messageType": "pretty",
  "textMessage": "Ping @here",
  "token": "https://hooks.slack.com/services/xxxxxxxxx/xxxxxx/xxxxx",
  "username": "Lunalytics"
}
json
{
  "platform": "Telegram",
  "chatId": "xxxxxxxxxx",
  "disableNotification": false,
  "friendlyName": "Lunalytics",
  "messageType": "pretty",
  "protectContent": false,
  "token": "xxxxxxxxxxxxxxx"
}
json
{
  "platform": "Webhook",
  "friendlyName": "Lunalytics",
  "messageType": "pretty",
  "requestType": "application/json",
  "showAdditionalHeaders": true,
  "additionalHeaders": {},
  "token": "https://lunalytics.xyz/api/webhook/alert"
}

HTTP Response Codes

Status CodeDescription
201Success, returns an object for notification
401Unauthorized (Missing access_token cookie or API Token)
422Return 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'
js
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

json
{
  "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
}
json
{
  "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
}
json
{
  "chatId": "xxxxxxxxxx",
  "disableNotification": false,
  "friendlyName": "Lunalytics",
  "messageType": "pretty",
  "protectContent": false,
  "token": "xxxxxxxxxxxxxxx",
  "id": "4d048471-9e85-428b-8050-4238f6033478",
  "email": "KSJaay@lunalytics.xyz",
  "isEnabled": true
}
json
{
  "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 CodeDescription
200Success, returns an object for notification
401Unauthorized (Missing access_token cookie or API Token)
422Return 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'
js
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 CodeDescription
200Success
401Unauthorized (Missing access_token cookie or API Token)
422No 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'
js
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 CodeDescription
200Success
401Unauthorized (Missing access_token cookie or API Token)
422No 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'
js
axios('/api/notifications/toggle', {
  method: 'POST',
  headers: {
    Authorization: 'API Token',
    'Content-Type': 'application/json',
  },
  params: {
    notificationId: '4d048471-9e85-428b-8050-4238f6033478',
    isEnabled: 'true',
  },
});