Skip to content

Latest commit

 

History

History
387 lines (264 loc) · 29.1 KB

README.md

File metadata and controls

387 lines (264 loc) · 29.1 KB

Tenants

(tenants)

Overview

A tenant represents a group of users. As a developer, when your apps have organizations, they are referred to as tenants. Tenants in Novu provides the ability to tailor specific notification experiences to users of different groups or organizations. https://docs.novu.co/tenants

Available Operations

create

Create tenant under the current environment Tenants is not supported in code first version of the API.

Example Usage

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

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

async function run() {
  const result = await novu.tenants.create({
    identifier: "<value>",
    name: "<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 { tenantsCreate } from "@novu/api/funcs/tenantsCreate.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 tenantsCreate(novu, {
    identifier: "<value>",
    name: "<value>",
  });

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
request components.CreateTenantRequestDto ✔️ 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.CreateTenantResponseDto>

Errors

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

delete

Deletes a tenant entity from the Novu platform. Tenants is not supported in code first version of the API.

Example Usage

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

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

async function run() {
  await novu.tenants.delete("<value>");
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { tenantsDelete } from "@novu/api/funcs/tenantsDelete.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 tenantsDelete(novu, "<value>");

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

  const { value: result } = res;

  
}

run();

Parameters

Parameter Type Required Description
identifier 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<void>

Errors

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

list

Returns a list of tenants, could paginated using the page and limit query parameter. Tenants is not supported in code first version of the API.

Example Usage

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

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

async function run() {
  const result = await novu.tenants.list();
  
  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { NovuCore } from "@novu/api/core.js";
import { tenantsList } from "@novu/api/funcs/tenantsList.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 tenantsList(novu);

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

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
page number N/A
limit number 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<operations.TenantControllerListTenantsResponse>

Errors

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

retrieve

Get tenant by your internal id used to identify the tenant Tenants is not supported in code first version of the API.

Example Usage

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

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

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

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
identifier 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.GetTenantResponseDto>

Errors

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

update

Update tenant by your internal id used to identify the tenant Tenants is not supported in code first version of the API.

Example Usage

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

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

async function run() {
  const result = await novu.tenants.update("<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 { tenantsUpdate } from "@novu/api/funcs/tenantsUpdate.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 tenantsUpdate(novu, "<value>", {});

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

  const { value: result } = res;

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

run();

Parameters

Parameter Type Required Description
identifier string ✔️ N/A
updateTenantRequestDto components.UpdateTenantRequestDto ✔️ 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.UpdateTenantResponseDto>

Errors

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