Documentation
API Reference
Push Notifications

Push Notifications API

Send push notifications via FCM. 100% free and unlimited.

Base URL

https://api.moontraze.com/api

Permission Model

RoleSendReceive
Owner
User

Enable FCM for Project (Owner)

POST /api/notifications/toggle-fcm
Authorization: Bearer <owner-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "projectId": "YOUR_PROJECT_ID",
  "enabled": true
}

Register FCM Token

POST /api/notifications/register
Authorization: Bearer <user-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "token": "FCM_TOKEN",
  "deviceInfo": { "platform": "android" }
}

Unregister FCM Token

POST /api/notifications/unregister
Authorization: Bearer <user-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "token": "FCM_TOKEN"
}

Send to Project (Owner Only)

POST /api/notifications/send-to-project/:projectId
Authorization: Bearer <owner-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "title": "Hello",
  "body": "World",
  "data": { "screen": "home" }
}

Send to User (Owner Only)

POST /api/notifications/send-to-user/:userId
Authorization: Bearer <owner-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "title": "Order Shipped",
  "body": "Your order is on the way",
  "data": { "orderId": "1234" }
}

Send to Topic (Owner Only)

POST /api/notifications/send-to-topic
Authorization: Bearer <owner-token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "topic": "premium_users",
  "title": "Premium Feature",
  "body": "Exclusive for premium users"
}

Schedule

POST /api/notifications/schedule
Authorization: Bearer <token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "title": "Reminder",
  "body": "Don't forget!",
  "sendAt": "2026-12-31T10:00:00Z"
}

Get History

GET /api/notifications/history?limit=50
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Get Preferences

GET /api/notifications/preferences
Authorization: Bearer <token>
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY

Update Preferences

PUT /api/notifications/preferences
Authorization: Bearer <token>
Content-Type: application/json
X-Project-Id: YOUR_PROJECT_ID
X-API-Key: YOUR_API_KEY
 
{
  "pushEnabled": true,
  "emailEnabled": false,
  "marketingEnabled": true,
  "securityEnabled": true,
  "quietHoursEnabled": true,
  "quietHoursStart": "22:00",
  "quietHoursEnd": "08:00",
  "timezone": "Asia/Kolkata"
}

SDK Example

await moon.notifications.registerToken(fcmToken, { platform: 'android' });
await moon.notifications.unregisterToken(fcmToken);
 
await moon.notifications.sendToProject(projectId, {
  title: 'Hello',
  body: 'World',
});
 
await moon.notifications.sendToUser('user_id', {
  title: 'Order Shipped',
  body: 'Your order is on the way',
});
 
await moon.notifications.sendToTopic({
  topic: 'premium_users',
  title: 'Premium Feature',
  body: 'Exclusive for premium users',
});
 
await moon.notifications.schedule(
  { title: 'Reminder', body: "Don't forget!" },
  new Date('2026-12-31T10:00:00Z'),
);
 
const history = await moon.notifications.getHistory(50);
const prefs = await moon.notifications.getPreferences();
await moon.notifications.updatePreferences({ pushEnabled: true });