Skip to content

Latest commit

 

History

History
182 lines (132 loc) · 11.3 KB

README.md

File metadata and controls

182 lines (132 loc) · 11.3 KB

Notifications

(notifications)

Overview

Available Operations

list

Get notifications

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.notifications.list({
    channels: [
      "chat",
    ],
    templates: [
      "<value>",
    ],
    emails: [
      "<value>",
    ],
    search: "<value>",
    subscriberIds: [
      "<value>",
    ],
  });
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { notificationsList } from "@novu/api/funcs/notificationsList.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await notificationsList(novu, {
    channels: [
      "sms",
    ],
    templates: [
      "<value>",
    ],
    emails: [
      "<value>",
    ],
    search: "<value>",
    subscriberIds: [
      "<value>",
    ],
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.NotificationsControllerListNotificationsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.ActivitiesResponseDto>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

retrieve

Get notification

Example Usage

import { Novu } from "@novu/api";

const novu = new Novu({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await novu.notifications.retrieve("<value>");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { notificationsRetrieve } from "@novu/api/funcs/notificationsRetrieve.js";

// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await notificationsRetrieve(novu, "<value>");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
notificationId string ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.ActivityNotificationResponseDto>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /