Aoba Notification WebSocket API 1.0.0
  • Proprietary

Real-time push notifications via WebSocket for the Aoba messaging platform.

Overview

The notification WebSocket provides real-time push notifications for events that require immediate user attention, such as group invitations. This channel is server-to-client only - clients receive notifications but do not send messages.

Connection

  • Endpoint: /api/v1/notifications
  • Protocol: WebSocket (RFC 6455)
  • Authentication: JWT token via auth_token cookie or ?token= query parameter

Connection Examples

Same-origin (cookie-based):

const ws = new WebSocket('wss://api.example.com/api/v1/notifications');

Cross-origin (token parameter):

const ws = new WebSocket(`wss://api.example.com/api/v1/notifications?token=${jwtToken}`);

Message Direction

  • Server → Client: All notification events (push only)
  • Client → Server: None (keepalive handled via WebSocket ping/pong frames)

Connection Lifecycle

  1. Client connects with valid JWT authentication
  2. Server upgrades connection and registers user
  3. Server sends ping frames every 54 seconds to keep connection alive
  4. Client responds with pong frames (handled automatically by WebSocket)
  5. Server pushes notification events as they occur
  6. Connection closes on logout or network disconnect

Keepalive Behavior

Parameter Value Description
Write timeout 10s Time allowed to write a message
Pong timeout 60s Time allowed for client to respond to ping
Ping interval 54s Server sends ping frames at this interval

Multi-Device Support

When a user connects from multiple devices:

  • Each device gets its own WebSocket connection
  • Notifications are broadcast to all connected devices for the user
  • Disconnecting one device does not affect others

Servers

  • wss://api.example.com/wssproduction

    Production notification server

    Security:
    • HTTP API key
      • Name: auth_token
      • In: cookie

      JWT token stored in HTTP-only cookie named auth_token.

      For cross-origin WebSocket connections, the token can also be passed as a ?token= query parameter.

  • ws://localhost:8080/wsdevelopment

    Development notification server

    Security:
    • HTTP API key
      • Name: auth_token
      • In: cookie

      JWT token stored in HTTP-only cookie named auth_token.

      For cross-origin WebSocket connections, the token can also be passed as a ?token= query parameter.

Operations

  • RECEIVE /api/v1/notifications

    WebSocket channel for receiving real-time push notifications.

    This is a receive-only channel - clients subscribe to receive notifications but do not publish messages.

    Receive push notifications from the server

    Subscribe to this channel to receive real-time notifications.

    Currently supported notification types:

    • invitation_received - Sent to invitee when invited to a group
    • invitation_accepted - Sent to inviter when their invitation is accepted
    • invitation_denied - Sent to inviter when their invitation is denied

    Usage Example

    const ws = new WebSocket('wss://api.example.com/api/v1/notifications');
    
    ws.onmessage = (event) => {
      const notification = JSON.parse(event.data);
    
      switch (notification.type) {
        case 'invitation_received':
          showInvitationPopup(notification.data);
          break;
        case 'invitation_accepted':
          showSuccessToast(`${notification.data.acceptedByUsername} joined the group`);
          break;
        case 'invitation_denied':
          showInfoToast(`Invitation was declined`);
          break;
      }
    };
    
    ws.onclose = () => {
      // Implement reconnection logic
    };
    
    Operation IDreceiveNotification

    Available only on servers:

    Accepts one of the following messages:

    • #0Invitation ReceivedinvitationReceived

      Notification when user receives a group invitation

      Message IDinvitationReceived

      Sent to the invitee when another user invites them to join a group.

      The invitee should display this notification to allow accepting or declining.

      allOf

      Examples

    • #1Invitation AcceptedinvitationAccepted

      Notification when an invitation is accepted

      Message IDinvitationAccepted

      Sent to the inviter when the invitee accepts their group invitation.

      The inviter can update their UI to show the new member has joined.

      allOf

      Examples

    • #2Invitation DeniedinvitationDenied

      Notification when an invitation is denied

      Message IDinvitationDenied

      Sent to the inviter when the invitee declines their group invitation.

      The inviter can optionally show a notification or remove the pending invitation from their UI.

      allOf

      Examples

Messages

  • #1Invitation ReceivedInvitationReceived

    Notification when user receives a group invitation

    Message IDInvitationReceived

    Sent to the invitee when another user invites them to join a group.

    The invitee should display this notification to allow accepting or declining.

    allOf
  • #2Invitation AcceptedInvitationAccepted

    Notification when an invitation is accepted

    Message IDInvitationAccepted

    Sent to the inviter when the invitee accepts their group invitation.

    The inviter can update their UI to show the new member has joined.

    allOf
  • #3Invitation DeniedInvitationDenied

    Notification when an invitation is denied

    Message IDInvitationDenied

    Sent to the inviter when the invitee declines their group invitation.

    The inviter can optionally show a notification or remove the pending invitation from their UI.

    allOf

Schemas

  • string

    The type of notification event

      Allowed values:
    • "invitation_received"
    • "invitation_accepted"
    • "invitation_denied"
  • object

    Base structure for all notification events

  • allOf
  • allOf
  • allOf
  • object

    Data payload for invitation_received notification

  • object

    Data payload for invitation_accepted notification

  • object

    Data payload for invitation_denied notification