---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminNotificationsResource
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# AdminNotificationsResource

This class is used to send requests to [Admin Notification API Routes](https://docs.medusajs.com/api/admin#notifications). All its method
are available in the JS Client under the `medusa.admin.notifications` property.

All methods in this class require [user authentication](js_client.AdminAuthResource.mdx#createsession).

Notifications are sent to customers to inform them of new updates. For example, a notification can be sent to the customer when their order is place or its state is updated.
The notification's type, such as an email or SMS, is determined by the notification provider installed on the Medusa backend.

## Methods

### list

Retrieve a list of notifications. The notifications can be filtered by fields such as `event_name` or `resource_type` passed in the `query` parameter.
The notifications can also be paginated.

#### Example

To list notifications:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list()
.then(({ notifications }) => {
  console.log(notifications.length);
})
```

To specify relations that should be retrieved within the notifications:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
  expand: "provider"
})
.then(({ notifications }) => {
  console.log(notifications.length);
})
```

By default, only the first `50` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list({
  expand: "provider",
  limit,
  offset
})
.then(({ notifications }) => {
  console.log(notifications.length);
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "query",
    "type": "[AdminGetNotificationsParams](../../medusa/classes/medusa.AdminGetNotificationsParams.mdx)",
    "description": "Filters and pagination configurations applied to the retrieved notifications.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "event_name",
        "type": "`string`",
        "description": "Event name to filter notifications by.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "expand",
        "type": "`string`",
        "description": "Comma-separated relations that should be expanded in the returned data.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "fields",
        "type": "`string`",
        "description": "Comma-separated fields that should be included in the returned data.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "include_resends",
        "type": "`string`",
        "description": "Whether to include resends in the results.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "limit",
        "type": "`number`",
        "description": "Limit the number of items returned in the list.",
        "optional": true,
        "defaultValue": "50",
        "expandable": false,
        "children": []
      },
      {
        "name": "offset",
        "type": "`number`",
        "description": "The number of items to skip when retrieving a list.",
        "optional": true,
        "defaultValue": "0",
        "expandable": false,
        "children": []
      },
      {
        "name": "resource_id",
        "type": "`string`",
        "description": "Resource ID to filter notifications by.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "resource_type",
        "type": "`string`",
        "description": "Resource type to filter notifications by.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "to",
        "type": "`string`",
        "description": "Filter notifications by their `to` field.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "`Record<string, any>`",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "ResponsePromise&#60;AdminNotificationsListRes&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the list of notifications with pagination fields.",
    "expandable": false,
    "children": [
      {
        "name": "AdminNotificationsListRes",
        "type": "[PaginatedResponse](../../medusa/types/medusa.PaginatedResponse-1.mdx) & `object`",
        "description": "",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "count",
            "type": "`number`",
            "description": "",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "limit",
            "type": "`number`",
            "description": "",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "offset",
            "type": "`number`",
            "description": "",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "notifications",
            "type": "[Notification](../../entities/classes/entities.Notification.mdx)[]",
            "description": "an array of notifications",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "customer",
                "type": "[Customer](../../entities/classes/entities.Customer.mdx)",
                "description": "The details of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "customer_id",
                "type": "`null` \\| `string`",
                "description": "The ID of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "data",
                "type": "`Record<string, unknown>`",
                "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "event_name",
                "type": "`string`",
                "description": "The name of the event that the notification was sent for.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The notification's ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_id",
                "type": "`string`",
                "description": "The notification's parent ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_notification",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)",
                "description": "The details of the parent notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider",
                "type": "[NotificationProvider](../../entities/classes/entities.NotificationProvider.mdx)",
                "description": "The notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider_id",
                "type": "`string`",
                "description": "The ID of the notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resends",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)[]",
                "description": "The details of all resends of the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "resource_id",
                "type": "`string`",
                "description": "The ID of the resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resource_type",
                "type": "`string`",
                "description": "The type of resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "to",
                "type": "`string`",
                "description": "The address that the Notification was sent to. This will usually be an email address, but can represent other addresses such as a chat bot user ID.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### resend

Resend a previously sent notifications, with the same data but optionally to a different address.

#### Example

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.resend(notificationId)
.then(({ notification }) => {
  console.log(notification.id);
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "The notification's ID.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "payload",
    "type": "[AdminPostNotificationsNotificationResendReq](../../medusa/classes/medusa.AdminPostNotificationsNotificationResendReq.mdx)",
    "description": "The details necessary to resend the notification.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "to",
        "type": "`string`",
        "description": "A new address or user identifier that the Notification should be sent to. If not provided, the previous `to` field of the notification will be used.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "`Record<string, any>`",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} expandUrl="https://docs.medusajs.com/js-client/overview#expanding-fields"/>

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "ResponsePromise&#60;AdminNotificationsRes&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the notification's details.",
    "expandable": false,
    "children": [
      {
        "name": "notification",
        "type": "[Notification](../../entities/classes/entities.Notification.mdx)",
        "description": "Notification details",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "created_at",
            "type": "`Date`",
            "description": "The date with timezone at which the resource was created.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "customer",
            "type": "[Customer](../../entities/classes/entities.Customer.mdx)",
            "description": "The details of the customer that this notification was sent to.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": [
              {
                "name": "billing_address",
                "type": "[Address](../../entities/classes/entities.Address.mdx)",
                "description": "The details of the billing address associated with the customer.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "billing_address_id",
                "type": "`null` \\| `string`",
                "description": "The customer's billing address ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "`null` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "email",
                "type": "`string`",
                "description": "The customer's email",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "first_name",
                "type": "`string`",
                "description": "The customer's first name",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "groups",
                "type": "[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)[]",
                "description": "The customer groups the customer belongs to.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "has_account",
                "type": "`boolean`",
                "description": "Whether the customer has an account or not",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The customer's ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "last_name",
                "type": "`string`",
                "description": "The customer's last name",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "metadata",
                "type": "`Record<string, unknown>`",
                "description": "An optional key-value map with additional details",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "orders",
                "type": "[Order](../../entities/classes/entities.Order.mdx)[]",
                "description": "The details of the orders this customer placed.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "password_hash",
                "type": "`string`",
                "description": "",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "phone",
                "type": "`string`",
                "description": "The customer's phone number",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "shipping_addresses",
                "type": "[Address](../../entities/classes/entities.Address.mdx)[]",
                "description": "The details of the shipping addresses associated with the customer.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          },
          {
            "name": "customer_id",
            "type": "`null` \\| `string`",
            "description": "The ID of the customer that this notification was sent to.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "data",
            "type": "`Record<string, unknown>`",
            "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "event_name",
            "type": "`string`",
            "description": "The name of the event that the notification was sent for.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "id",
            "type": "`string`",
            "description": "The notification's ID",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "parent_id",
            "type": "`string`",
            "description": "The notification's parent ID",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "parent_notification",
            "type": "[Notification](../../entities/classes/entities.Notification.mdx)",
            "description": "The details of the parent notification.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": [
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "customer",
                "type": "[Customer](../../entities/classes/entities.Customer.mdx)",
                "description": "The details of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "customer_id",
                "type": "`null` \\| `string`",
                "description": "The ID of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "data",
                "type": "`Record<string, unknown>`",
                "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "event_name",
                "type": "`string`",
                "description": "The name of the event that the notification was sent for.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The notification's ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_id",
                "type": "`string`",
                "description": "The notification's parent ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_notification",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)",
                "description": "The details of the parent notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider",
                "type": "[NotificationProvider](../../entities/classes/entities.NotificationProvider.mdx)",
                "description": "The notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider_id",
                "type": "`string`",
                "description": "The ID of the notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resends",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)[]",
                "description": "The details of all resends of the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "resource_id",
                "type": "`string`",
                "description": "The ID of the resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resource_type",
                "type": "`string`",
                "description": "The type of resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "to",
                "type": "`string`",
                "description": "The address that the Notification was sent to. This will usually be an email address, but can represent other addresses such as a chat bot user ID.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          },
          {
            "name": "provider",
            "type": "[NotificationProvider](../../entities/classes/entities.NotificationProvider.mdx)",
            "description": "The notification provider used to send the notification.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": [
              {
                "name": "id",
                "type": "`string`",
                "description": "The ID of the notification provider as given by the notification service.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "is_installed",
                "type": "`boolean`",
                "description": "Whether the notification service is installed in the current version. If a notification service is no longer installed, the `is\\_installed` attribute is set to `false`.",
                "optional": false,
                "defaultValue": "true",
                "expandable": false,
                "children": []
              }
            ]
          },
          {
            "name": "provider_id",
            "type": "`string`",
            "description": "The ID of the notification provider used to send the notification.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "resends",
            "type": "[Notification](../../entities/classes/entities.Notification.mdx)[]",
            "description": "The details of all resends of the notification.",
            "optional": false,
            "defaultValue": "",
            "expandable": true,
            "children": [
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "customer",
                "type": "[Customer](../../entities/classes/entities.Customer.mdx)",
                "description": "The details of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "customer_id",
                "type": "`null` \\| `string`",
                "description": "The ID of the customer that this notification was sent to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "data",
                "type": "`Record<string, unknown>`",
                "description": "The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "event_name",
                "type": "`string`",
                "description": "The name of the event that the notification was sent for.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The notification's ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_id",
                "type": "`string`",
                "description": "The notification's parent ID",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "parent_notification",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)",
                "description": "The details of the parent notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider",
                "type": "[NotificationProvider](../../entities/classes/entities.NotificationProvider.mdx)",
                "description": "The notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "provider_id",
                "type": "`string`",
                "description": "The ID of the notification provider used to send the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resends",
                "type": "[Notification](../../entities/classes/entities.Notification.mdx)[]",
                "description": "The details of all resends of the notification.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "resource_id",
                "type": "`string`",
                "description": "The ID of the resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "resource_type",
                "type": "`string`",
                "description": "The type of resource that the Notification refers to.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "to",
                "type": "`string`",
                "description": "The address that the Notification was sent to. This will usually be an email address, but can represent other addresses such as a chat bot user ID.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          },
          {
            "name": "resource_id",
            "type": "`string`",
            "description": "The ID of the resource that the Notification refers to.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "resource_type",
            "type": "`string`",
            "description": "The type of resource that the Notification refers to.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "to",
            "type": "`string`",
            "description": "The address that the Notification was sent to. This will usually be an email address, but can represent other addresses such as a chat bot user ID.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "updated_at",
            "type": "`Date`",
            "description": "The date with timezone at which the resource was updated.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      }
    ]
  }
]} />
