--- 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](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 `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> ##### Returns `", "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](../internal/classes/internal.Notification.mdx)", "description": "The details of the parent notification.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider", "type": "[NotificationProvider](../internal/classes/internal.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](../internal/classes/internal.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 `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> ##### Returns `", "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](../internal/classes/internal.Notification.mdx)", "description": "The details of the parent notification.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "provider", "type": "[NotificationProvider](../internal/classes/internal.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](../internal/classes/internal.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": [] } ] } ] } ] } ]} />