> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/building-in-app-notification-inbox.md).

# Building an In-App Notification Inbox

This recipe shows how to store push notifications in a per-user inbox, list them in your own app screen with read and unread filters, and update their status when the user opens or deletes a message. An inbox keeps important messages available after the push has left the notification tray.

## When to Use

This recipe fits apps that show a notification center, where users can review past offers, order updates, or announcements and see an unread count. All reads and updates run from your backend, so the inbox screen of the app uses your own API.

## Prerequisites

* REST API key of the application
* The external ID (`extId`) of the users, so that messages and requests can be matched to a user

## Step 1: Send a Push That Is Stored in the Inbox

Set `inbox` to `true` in the `message` object of the send request. The push is delivered as usual and a copy is stored in the inbox of each recipient.

```bash
curl https://restapi.netmera.com/rest/3.0/sendBulkNotification \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "message": {
    "title": "Weekend Offer",
    "text": "Free shipping on all orders until Sunday.",
    "platforms": ["IOS", "ANDROID"],
    "inbox": true
  },
  "target": {
    "tag": "loyalty-gold"
  }
}'
```

The same `inbox` flag is available in notification definitions created with `createNotificationDefinition`.

**Expected result:** HTTP 200 with a `notificationKey`.

## Step 2: List the Inbox Messages of a User

Fetch the messages with `getAllInbox`. `status` filters by read state: `1` for read, `2` for unread, `3` for read and unread, `4` for deleted, and `7` for all. `numberOfNotification` sets the page size and defaults to 20.

```bash
curl https://restapi.netmera.com/rest/3.0/inbox/getAllInbox \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "extId": "user_1001",
  "status": 2,
  "numberOfNotification": 20
}'
```

The response contains the messages in `msgs`, each with a `pushInstanceId`, `title`, `message` and `status`, and the message counts per status in `cnts`. Use `cnts` for the unread badge of the inbox icon.

To fetch the next page, send the `prms.index` value of the response, which is the `pushInstanceId` of the last message, as `prms.index` in the next request. A response without a `prms` block is the last page.

```json
{
  "extId": "user_1001",
  "status": 2,
  "numberOfNotification": 20,
  "prms": { "index": 1234567890 }
}
```

**Expected result:** A page of unread messages with their push instance IDs.

## Step 3: Open a Single Message

When the user taps a message, fetch its full content with `getInboxMessage`, using the `pushInstanceId` as `piid`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/inbox/get?piid=1234567890' \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response includes the `deeplink`, media URLs, and `customParams` of the message, which the app can use to navigate.

**Expected result:** The full message object.

## Step 4: Update the Message Status

Mark messages as read, or delete them, with `inbox/statusChange`. `piids` lists the messages to update and `st` is the target status, for example `1` for read and `4` for deleted.

```bash
curl https://restapi.netmera.com/rest/3.0/inbox/statusChange \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "extId": "user_1001",
  "piids": [1234567890],
  "st": 1
}'
```

**Expected result:** HTTP 200 with no response body. The next `getAllInbox` call with `status` set to `2` no longer returns these messages.

## Verification Checklist

* The push was sent with `inbox` set to `true`
* The `extId` in inbox requests is the same value that the SDK or `registerUsers` assigned to the user
* The unread badge reads the `cnts` object of `getAllInbox`
* Pagination sends the `prms.index` value of the previous response
* `statusChange` receives `pushInstanceId` values in `piids`

## Related Pages

For all filters of the inbox listing, such as date range and category, see the List inbox messages page in the REST API documentation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/building-in-app-notification-inbox.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
