Layouts are reusable wrappers for your email notifications. https://docs.novu.co/platform/workflow/layouts
- create - Create a layout
- list - List all layouts
- update - Update a layout
- retrieve - Retrieve a layout
- delete - Delete a layout
- duplicate - Duplicate a layout
- generatePreview - Generate layout preview
- usage - Get layout usage
Creates a new layout in the Novu Cloud environment
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.create({
layoutId: "<id>",
name: "<value>",
});
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsCreate } from "@novu/api/funcs/layoutsCreate.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsCreate(novu, {
layoutId: "<id>",
name: "<value>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
createLayoutDto |
components.CreateLayoutDto | ✔️ | Layout creation details |
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. |
Promise<operations.LayoutsControllerCreateResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Retrieves a list of layouts with optional filtering and pagination
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.list({
limit: 10,
offset: 0,
});
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsList } from "@novu/api/funcs/layoutsList.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsList(novu, {
limit: 10,
offset: 0,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LayoutsControllerListRequest | ✔️ | 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. |
Promise<operations.LayoutsControllerListResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Updates the details of an existing layout, here layoutId is the identifier of the layout
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.update({
name: "<value>",
}, "<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsUpdate } from "@novu/api/funcs/layoutsUpdate.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsUpdate(novu, {
name: "<value>",
}, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | N/A |
updateLayoutDto |
components.UpdateLayoutDto | ✔️ | Layout update details |
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. |
Promise<operations.LayoutsControllerUpdateResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Fetches details of a specific layout by its unique identifier layoutId
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.retrieve("<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsRetrieve } from "@novu/api/funcs/layoutsRetrieve.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsRetrieve(novu, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsRetrieve failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | 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. |
Promise<operations.LayoutsControllerGetResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Removes a specific layout by its unique identifier layoutId
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.delete("<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsDelete } from "@novu/api/funcs/layoutsDelete.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsDelete(novu, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | The unique identifier of the layout |
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. |
Promise<operations.LayoutsControllerDeleteResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Duplicates a layout by its unique identifier layoutId. This will create a new layout with the content of the original layout.
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.duplicate({
name: "<value>",
}, "<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsDuplicate } from "@novu/api/funcs/layoutsDuplicate.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsDuplicate(novu, {
name: "<value>",
}, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsDuplicate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | N/A |
duplicateLayoutDto |
components.DuplicateLayoutDto | ✔️ | 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. |
Promise<operations.LayoutsControllerDuplicateResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Generates a preview for a layout by its unique identifier layoutId
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.generatePreview({
previewPayload: {
subscriber: {
channels: [
{
providerId: "mattermost",
credentials: {
webhookUrl: "https://example.com/webhook",
channel: "general",
deviceTokens: [
"token1",
"token2",
"token3",
],
alertUid: "12345-abcde",
title: "Critical Alert",
imageUrl: "https://example.com/image.png",
state: "resolved",
externalUrl: "https://example.com/details",
},
integrationId: "<id>",
},
],
},
},
}, "<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsGeneratePreview } from "@novu/api/funcs/layoutsGeneratePreview.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsGeneratePreview(novu, {
previewPayload: {
subscriber: {
channels: [
{
providerId: "mattermost",
credentials: {
webhookUrl: "https://example.com/webhook",
channel: "general",
deviceTokens: [
"token1",
"token2",
"token3",
],
alertUid: "12345-abcde",
title: "Critical Alert",
imageUrl: "https://example.com/image.png",
state: "resolved",
externalUrl: "https://example.com/details",
},
integrationId: "<id>",
},
],
},
},
}, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsGeneratePreview failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | N/A |
layoutPreviewRequestDto |
components.LayoutPreviewRequestDto | ✔️ | Layout preview generation details |
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. |
Promise<operations.LayoutsControllerGeneratePreviewResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Retrieves information about workflows that use the specified layout by its unique identifier layoutId
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.layouts.usage("<id>");
console.log(result);
}
run();The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsUsage } from "@novu/api/funcs/layoutsUsage.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const res = await layoutsUsage(novu, "<id>");
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("layoutsUsage failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
layoutId |
string | ✔️ | 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. |
Promise<operations.LayoutsControllerGetUsageResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorDto | 414 | application/json |
| errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
| errors.ValidationErrorDto | 422 | application/json |
| errors.ErrorDto | 500 | application/json |
| errors.SDKError | 4XX, 5XX | */* |