(layouts)
Novu allows the creation of layouts - a specific HTML design or structure to wrap content of email notifications. Layouts can be manipulated and assigned to new or existing workflows within the Novu platform, allowing users to create, manage, and assign these layouts to workflows, so they can be reused to structure the appearance of notifications sent through the platform. https://docs.novu.co/content-creation-design/layouts
- create - Layout creation
- delete - Delete layout
- list - Filter layouts
- retrieve - Get layout
- setAsDefault - Set default layout
- update - Update a layout
Create a layout
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.layouts.create();
// Handle the result
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({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await layoutsCreate(novu);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
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<components.CreateLayoutResponseDto>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Execute a soft delete of a layout given a certain ID.
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
await novu.layouts.delete("<value>");
}
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({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await layoutsDelete(novu, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
layoutId |
string | ✔️ | The layout id |
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<void>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Returns a list of layouts that can be paginated using the page
query parameter and filtered by the environment where it is executed from the organization the user belongs to.
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
await novu.layouts.list({});
}
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({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await layoutsList(novu, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.LayoutsControllerListLayoutsRequest | ✔️ | 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<void>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Get a layout by its ID
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.layouts.retrieve("<value>");
// Handle the result
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({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await layoutsRetrieve(novu, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
layoutId |
string | ✔️ | The layout id |
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<components.GetLayoutResponseDto>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Sets the default layout for the environment and updates to non default to the existing default layout (if any).
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
await novu.layouts.setAsDefault("<value>");
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { layoutsSetAsDefault } from "@novu/api/funcs/layoutsSetAsDefault.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 layoutsSetAsDefault(novu, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
layoutId |
string | ✔️ | The layout id |
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<void>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Update the name, content and variables of a layout. Also change it to be default or no.
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.layouts.update("<value>", {
identifier: "<value>",
});
// Handle the result
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({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await layoutsUpdate(novu, "<value>", {
identifier: "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
layoutId |
string | ✔️ | The layout id |
updateLayoutRequestDto |
components.UpdateLayoutRequestDto | ✔️ | 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. |
Promise<components.UpdateLayoutResponseDto>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |