1HOUSE API Documentation

Notifications

Manage push notifications, emails, and SMS

Manage user notifications across multiple channels.

Multi-Channel Delivery

Send notifications via push, email, and SMS with priority-based routing, user preference management, and delivery tracking.

Overview

The Notification Service supports:

  • Push notifications
  • Email notifications
  • SMS notifications (coming soon)
  • In-app notifications
  • Notification preferences

Base Path: /v1/notifications

Get Notifications

Get All Notifications

GET /v1/notifications
ParameterTypeDescription
pagenumberPage number
limitnumberResults per page (max: 50)
typestringFilter by type
readbooleanFilter by read status
{
  "success": true,
  "status": 200,
  "data": [
    {
      "id": "notif_123",
      "userId": "user_456",
      "type": "trade_update",
      "title": "Trade Target Reached",
      "message": "Your EUR/USD trade hit the target price of 1.0950",
      "priority": "high",
      "read": false,
      "channels": ["push", "email"],
      "metadata": {
        "tradeId": "trade_789",
        "symbol": "EUR/USD",
        "profitLoss": 100.00
      },
      "createdAt": "2025-10-21T12:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 45,
    "pages": 3
  }
}

Get Unread Count

GET /v1/notifications/unread-count
{
  "success": true,
  "status": 200,
  "data": {
    "count": 12
  }
}

Mark as Read

Mark Single Notification

PUT /v1/notifications/:notificationId/read

Mark All as Read

PUT /v1/notifications/read-all
{
  "success": true,
  "status": 200,
  "message": "15 notifications marked as read",
  "data": {
    "count": 15
  }
}

Delete Notification

DELETE /v1/notifications/:notificationId

Send Notification (Admin)

Send Single Notification

POST /v1/notifications/send
{
  "userId": "user_456",
  "type": "announcement",
  "title": "New Feature Released!",
  "message": "Check out our new AI trading assistant",
  "priority": "medium",
  "channels": ["push", "email"],
  "metadata": {
    "featureId": "ai-assistant",
    "url": "/intelligence"
  }
}

Send Bulk Notifications

POST /v1/notifications/send-bulk
{
  "userIds": ["user_123", "user_456", "user_789"],
  "notification": {
    "type": "announcement",
    "title": "Platform Maintenance",
    "message": "Scheduled maintenance on Sunday 2AM-4AM UTC",
    "priority": "high",
    "channels": ["push", "email"]
  }
}

Notification Types

TypeDescriptionDefault PriorityDefault Channels
welcomeWelcome messagemediumemail, push
trade_updateTrade status changeshighpush, email
achievementMilestones reachedlowpush
course_updateCourse/lesson updatesmediumemail
comment_replyComment on postmediumpush
announcementPlatform announcementshighpush, email
reminderScheduled remindersmediumpush
alertImportant alertscriticalpush, email, sms

Priority Levels

PriorityDeliveryExamples
criticalImmediate, all channelsAccount security, payment issues
highWithin 5 minutesTrade alerts, target reached
mediumWithin 30 minutesCourse updates, new comments
lowBatched hourlyAchievements, milestones

Channels

Push Notifications

Delivered to:

  • Mobile apps (iOS, Android)
  • Web browsers (with permission)
  • Desktop applications

Format:

{
  "title": "Trade Target Reached",
  "body": "EUR/USD hit 1.0950",
  "icon": "https://cdn.yourdomain.com/icons/trade.png",
  "badge": "https://cdn.yourdomain.com/badge.png",
  "data": {
    "tradeId": "trade_789",
    "action": "view_trade"
  }
}

Email Notifications

Delivered to user's registered email.

Templates:

  • Welcome email
  • Trade alerts
  • Course notifications
  • Weekly summaries
  • Platform announcements

SMS Notifications (Coming Soon)

For critical alerts only.

Notification Preferences

Users can configure preferences:

{
  "preferences": {
    "email": {
      "enabled": true,
      "types": ["trade_update", "announcement"]
    },
    "push": {
      "enabled": true,
      "types": ["trade_update", "comment_reply", "alert"]
    },
    "sms": {
      "enabled": false,
      "types": ["alert"]
    }
  }
}

Code Examples

React Notification Bell

function NotificationBell() {
  const [notifications, setNotifications] = useState([]);
  const [unreadCount, setUnreadCount] = useState(0);

  useEffect(() => {
    fetchNotifications();
    fetchUnreadCount();
    
    // Poll for new notifications
    const interval = setInterval(fetchUnreadCount, 30000);
    return () => clearInterval(interval);
  }, []);

  const fetchNotifications = async () => {
    const response = await fetch('/v1/notifications?limit=10', {
      headers: {
        'X-API-Key': apiKey,
        'Authorization': `Bearer ${token}`
      }
    });

    const { data } = await response.json();
    setNotifications(data);
  };

  const fetchUnreadCount = async () => {
    const response = await fetch('/v1/notifications/unread-count', {
      headers: {
        'X-API-Key': apiKey,
        'Authorization': `Bearer ${token}`
      }
    });

    const { data } = await response.json();
    setUnreadCount(data.count);
  };

  const markAsRead = async (notificationId) => {
    await fetch(`/v1/notifications/${notificationId}/read`, {
      method: 'PUT',
      headers: {
        'X-API-Key': apiKey,
        'Authorization': `Bearer ${token}`
      }
    });

    fetchNotifications();
    fetchUnreadCount();
  };

  return (
    <div>
      <button>
        🔔 {unreadCount > 0 && <span>{unreadCount}</span>}
      </button>
      
      <div className="dropdown">
        {notifications.map(notif => (
          <div 
            key={notif.id}
            onClick={() => markAsRead(notif.id)}
            className={notif.read ? '' : 'unread'}
          >
            <strong>{notif.title}</strong>
            <p>{notif.message}</p>
            <small>{formatTime(notif.createdAt)}</small>
          </div>
        ))}
      </div>
    </div>
  );
}