AppMage

Notifications

This endpoint group provides methods for managing user notifications, including retrieving, deleting, and marking notifications as read. It delegates most of its functionality to the NotificationService and uses the GenericCrudHelper for standard data operations.

Endpoints

POST /api/rpc (Method: NotificationRpc.getSchema)

  • Description: Returns notification schema

  • Request Body:

    {
      "method": "NotificationRpc.getSchema",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
  • Response:

    {
      "success": true,
      "data": {
        // Zod schema object for notifications
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.getSchema",
        "params": {}
      }'

POST /api/rpc (Method: NotificationRpc.delete)

  • Description: Deletes a notification

  • Request Body:

    {
      "method": "NotificationRpc.delete",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The ID of the notification to delete.
  • Response:

    {
      "success": true,
      "data": true
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.delete",
        "params": {
          "_id": "654321098765432109876543"
        }
      }'

POST /api/rpc (Method: NotificationRpc.getData)

  • Description: Retrieves a list of notifications

  • Request Body:

    {
      "method": "NotificationRpc.getData",
      "params": {
        "page": 1,
        "pageSize": 25,
        "filter": {},
        "sort": {}
      }
    }
  • Parameters:

    Name Type Required Description
    page Number No The page number for pagination (defaults to 1).
    pageSize Number No The number of items per page (defaults to 25).
    filter Object No An object to filter the notifications.
    sort Object No An object to define the sort order (e.g., { timestamp: -1 }).
  • Response:

    {
      "success": true,
      "data": {
        "data": [
          {
            "_id": "654321098765432109876543",
            "title": "New Message",
            "message": "You have a new message from Support.",
            "read": false,
            "timestamp": "2023-10-27T10:00:00.000Z",
            "userId": "user123"
          }
        ],
        "totalCount": 1
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.getData",
        "params": {
          "page": 1,
          "pageSize": 10,
          "filter": {
            "read": false
          },
          "sort": {
            "timestamp": -1
          }
        }
      }'

POST /api/rpc (Method: NotificationRpc.findById)

  • Description: Retrieves a specific notification by ID

  • Request Body:

    {
      "method": "NotificationRpc.findById",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The ID of the notification to retrieve.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "654321098765432109876543",
        "title": "New Message",
        "message": "You have a new message from Support.",
        "read": false,
        "timestamp": "2023-10-27T10:00:00.000Z",
        "userId": "user123"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.findById",
        "params": {
          "_id": "654321098765432109876543"
        }
      }'

POST /api/rpc (Method: NotificationRpc.markAsRead)

  • Description: Marks a notification as read

  • Request Body:

    {
      "method": "NotificationRpc.markAsRead",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The ID of the notification to mark as read.
  • Response:

    {
      "success": true,
      "data": true
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.markAsRead",
        "params": {
          "_id": "654321098765432109876543"
        }
      }'

POST /api/rpc (Method: NotificationRpc.markAllAsRead)

  • Description: Marks all notifications for a user as read

  • Request Body:

    {
      "method": "NotificationRpc.markAllAsRead",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
  • Response:

    {
      "success": true,
      "data": 5
    }

    (Returns the count of notifications marked as read.)

  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.markAllAsRead",
        "params": {}
      }'

POST /api/rpc (Method: NotificationRpc.deleteAll)

  • Description: Deletes all notifications for a user

  • Request Body:

    {
      "method": "NotificationRpc.deleteAll",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
  • Response:

    {
      "success": true,
      "data": 5
    }

    (Returns the count of notifications deleted.)

  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "NotificationRpc.deleteAll",
        "params": {}
      }'