> ## Documentation Index
> Fetch the complete documentation index at: https://v0.x-docs.novu.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Messages

> Learn about messages in Novu

Each [workflow](/workflows/notification-workflows) has one or more than one step. Each step is either a `channel` (in\_app, email, push, chat) or an `action` (digest, delay).

Within the workflow, every channel has a separate template. Email channel step content can be different than `in_app` channel step content. When a workflow is triggered, Novu generates separate messages for every channel step and sends that message to the recipient.

A triggered event (`notification`) is a collection of step information, its message, and job execution details.

## List messages

Messages can be listed using these SDK methods. These methods support pagination using page and limit field and filters using channel, subscriberId and transactionId field.

<Info>Novu will throw 404 error if requested subscriberId is not a valid subscriberId of any existing subscriber.</Info>

<Tabs>
  <Tab title="Node.js">
    ```javascript theme={null}
    import { Novu, ChannelTypeEnum } from '@novu/node';

    const novu = new Novu('<NOVU_API_KEY>');

    await novu.messages.list({
      page: 0,
      limit: 30,
      channel: ChannelTypeEnum.IN_APP,
      subscriberId: '<SUBSCRIBER_ID>'
      transactionIds: ['transactionId1', 'transactionId2'],
    });
    ```
  </Tab>
</Tabs>

### List messages example response

```javascript theme={null}
{
  "page": 0,
  "totalCount": 987,
  "hasMore": true,
  "pageSize": 30,
  "data": [
    ....
    {
      "cta": {
          "action": {
              "buttons": []
          },
          "type": "redirect",
          "data": {
              "url": ""
          }
      },
      "_id": "messageId",
      "_templateId": "workflowId",
      "_environmentId": "environmentId",
      "_messageTemplateId": "messageTemplateId",
      "_notificationId": "notificationId",
      "_organizationId": "organisationId",
      "_subscriberId": "_subscriberId",
      "_jobId": "jobId",
      "templateIdentifier": "workflowIdentifier",
      "_feedId": "feedId",
      "channel": "in_app",
      "content": "Message Content",
      "deviceTokens": [],
      "seen": false,
      "read": false,
      "status": "sent",
      "transactionId": "d5218a6c-4b08-4617-b176-2d2271f34e42",
      "payload": {
          "key": "value"
          "__source": "test-workflow"
      },
      "expireAt": "2024-06-17T08:18:29.871Z",
      "deleted": false,
      "createdAt": "2023-06-17T08:18:29.871Z",
      "updatedAt": "2023-06-17T08:24:34.888Z",
      "__v": 0,
      "subscriber": {
          "_id": "_subscriberId",
          "subscriberId": "subscriberId",
          "id": "_subscriberId"
      },
      "actorSubscriber": 'actorSubscriberId',
      "id": "messageId"
    }
    ....
  ]
}
```

## Delete a message

A single message can be deleted by messageId using these SDK methods. messageId should be a valid objectId parsed as a string.

<Tabs>
  <Tab title="Node.js">
    ```javascript theme={null}
    import { Novu } from '@novu/node';

    const novu = new Novu('<NOVU_API_KEY>');

    const messageId = '64452b58ec0dbb9e41b4dccf';

    await novu.messages.deleteById(messageId);
    ```
  </Tab>
</Tabs>

### Delete a message example response

```javascript theme={null}
{
  data: {
    acknowledged: true,
    status: 'deleted'
  }
};
```

## API Reference Links

* [List Messages API](/api-reference/messages/get-messages/)
* [Delete a Message API](/api-reference/messages/delete-message/)
