---
title: "Handle Notifications"
method: POST
path: "/api/mdm/notifications"
tags: ["MDM"]
---

# Handle Notifications

`POST /api/mdm/notifications`

**Function**: `handle_notifications`
**Type**: API Endpoint (POST)

**Purpose**:
This endpoint handles different types of notifications such as fetching notifications, setting read status, clearing notifications, etc.

**URL**:
`POST /api/notifications`

**Request Parameters**:
- `App_Code` (Header, required): Encoded application code.
- `User_Code` (Header, required): Encoded user code.
- `Customer_Key` (Header, required): Encoded customer key.
- `data` (JSON, required): Data containing the type of notification action and other relevant details.

**Process**:
1. Decodes the `Customer_Key` to extract `lscode` and `firmcode`.
2. Validates the customer key.
3. Handles different types of notifications based on the `data.type` parameter:
    - `getNotifications`: Fetches all notifications for the user and returns them in a JSON response.
    - `setReadStatus`: Updates the status of a notification to 'read' (1).
    - `clearone`: Updates the status of a notification to 'cleared' (2).
    - `setAllReadStatus`: Updates the status of all notifications for the user to 'read' (1).
    - `clearAll`: Updates the status of all notifications for the user to 'cleared' (2).

**Request Body**:
- **For Listing Notifications or Getting Count**:

- `type` (string, required): Type of notification action (e.g., `getNotifications`, `getCount`).

```json
{
    "type": "<type>"
}
```

- **For Status Updations**:

- `type` (string, required): Type of notification action (e.g., `setReadStatus`, `clearone`, `setAllReadStatus`, `clearAll`).
- `id` (integer, optional): ID of the notification to be updated.

```json
{
    "type": "<type>",
    "id": <id>
}
```

- **For create or update notofications**:

```json
{
    "flag": 0 | 1,
    "values": {
        "application_code": "<application_code>",
        "LSCode": "<LSCode>",
        "firm_code": "<firm_code>",
        "Id": "<Id>",
        "Trigger_Type": <Trigger_Type>,
        "Status": <Status>,
        "Action": <Action>,
        "Created_User": "<Created_User>",
        "Date_Of_Creation": "<Date_Of_Creation>",
        "Modified_User": "<Modified_User>",
        "Date_Of_Modification": "<Date_Of_Modification>",
        "Parameter": "<Parameter>",
        "Message": "<Message>",
        "Button_Name_1": "<Button_Name_1>",
        "Button_Value_1": "<Button_Value_1>",
        "Button_Name_2": "<Button_Name_2>",
        "Button_Value_2": "<Button_Value_2>",
        "Button_Name_3": "<Button_Name_3>",
        "Button_Value_3": "<Button_Value_3>",
        "Icon": "<Icon>",
        "Body_Image": "<Body_Image>"
    }
}

**Response**:
- JSON response containing the list of notifications or the result of the notification action.
- Indicates success or failure for each step, including any errors encountered.

**Exceptions**:
- Handles exceptions related to database operations and invalid customer key formats, providing appropriate error messages.

## Headers

- `App-Code` string, required
- `User-Code` string, required
- `Customer-Key` string, required

## Request body

- NotificationRequest
  - `type` string, nullable
  - `id` string, nullable
  - `values` object, nullable
  - `flag` integer, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi.md) · [All operations](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/leapsurgebi/leapsurgeapi/revisions/5a6b1464bfeb/schema)
