Skip to content

Latest commit

 

History

History
266 lines (194 loc) · 23.1 KB

README.md

File metadata and controls

266 lines (194 loc) · 23.1 KB

NovuSubscribers

(topics.subscribers)

Overview

Available Operations

assign

Add subscribers to a topic by key

Example Usage

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

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

async function run() {
  const result = await novu.topics.subscribers.assign({
    subscribers: [
      "<value>",
      "<value>",
      "<value>",
    ],
  }, "<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 { topicsSubscribersAssign } from "@novu/api/funcs/topicsSubscribersAssign.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 topicsSubscribersAssign(novu, {
    subscribers: [
      "<value>",
      "<value>",
      "<value>",
    ],
  }, "<value>");

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
topicKey string ✔️ The topic key
addSubscribersRequestDto components.AddSubscribersRequestDto ✔️ N/A
idempotencyKey string A header for idempotency purposes
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<operations.TopicsControllerAssignResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ErrorDto 414 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*

retrieve

Check if a subscriber belongs to a certain topic

Example Usage

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

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

async function run() {
  const result = await novu.topics.subscribers.retrieve("<id>", "<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 { topicsSubscribersRetrieve } from "@novu/api/funcs/topicsSubscribersRetrieve.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 topicsSubscribersRetrieve(novu, "<id>", "<value>");

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
externalSubscriberId string ✔️ The external subscriber id
topicKey string ✔️ The topic key
idempotencyKey string A header for idempotency purposes
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<operations.TopicsControllerGetTopicSubscriberResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ErrorDto 414 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*

remove

Remove subscribers from a topic

Example Usage

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

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

async function run() {
  const result = await novu.topics.subscribers.remove({
    subscribers: [
      "<value>",
      "<value>",
    ],
  }, "<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 { topicsSubscribersRemove } from "@novu/api/funcs/topicsSubscribersRemove.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 topicsSubscribersRemove(novu, {
    subscribers: [
      "<value>",
      "<value>",
    ],
  }, "<value>");

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
topicKey string ✔️ The topic key
removeSubscribersRequestDto components.RemoveSubscribersRequestDto ✔️ N/A
idempotencyKey string A header for idempotency purposes
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<operations.TopicsControllerRemoveSubscribersResponse>

Errors

Error Type Status Code Content Type
errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
errors.ErrorDto 414 application/json
errors.ValidationErrorDto 422 application/json
errors.ErrorDto 500 application/json
errors.SDKError 4XX, 5XX */*