Generate layout preview
Generates a preview for a layout by its unique identifier layoutId
Authorization
Authorization
<token>API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
In: header
Request Body
application/json
RequiredLayout preview generation details
controlValues
objectOptional control values for layout preview
previewPayload
objectOptional payload for layout preview
Path Parameters
layoutId
RequiredstringHeader Parameters
idempotency-key
stringA header for idempotency purposes
Response Body
Created
previewPayloadExample
RequiredobjectPreview payload example
schema
object | nullThe payload schema that was used to generate the preview payload example
result
RequiredobjectPreview result
export interface Response {
/**
* Preview payload example
*/
previewPayloadExample: LayoutPreviewPayloadDto;
/**
* The payload schema that was used to generate the preview payload example
*/
schema?: {
[k: string]: unknown;
} | null;
/**
* Preview result
*/
result: {
type?: "email";
preview?: EmailLayoutRenderOutput;
};
}
export interface LayoutPreviewPayloadDto {
/**
* Partial subscriber information
*/
subscriber?: SubscriberResponseDtoOptional;
}
export interface SubscriberResponseDtoOptional {
/**
* The internal ID generated by Novu for your subscriber. This ID does not match the `subscriberId` used in your queries. Refer to `subscriberId` for that identifier.
*/
_id?: string;
/**
* The first name of the subscriber.
*/
firstName?: string | null;
/**
* The last name of the subscriber.
*/
lastName?: string | null;
/**
* The email address of the subscriber.
*/
email?: string | null;
/**
* The phone number of the subscriber.
*/
phone?: string | null;
/**
* The URL of the subscriber's avatar image.
*/
avatar?: string | null;
/**
* The locale setting of the subscriber, indicating their preferred language or region.
*/
locale?: string | null;
/**
* An array of channel settings associated with the subscriber.
*/
channels?: ChannelSettingsDto[];
/**
* @deprecated
* An array of topics that the subscriber is subscribed to.
*/
topics?: string[];
/**
* Indicates whether the subscriber is currently online.
*/
isOnline?: boolean | null;
/**
* The timestamp indicating when the subscriber was last online, in ISO 8601 format.
*/
lastOnlineAt?: string | null;
/**
* The version of the subscriber document.
*/
__v?: number;
/**
* Additional custom data for the subscriber
*/
data?: {
[k: string]: unknown;
} | null;
/**
* Timezone of the subscriber
*/
timezone?: string | null;
}
export interface ChannelSettingsDto {
/**
* The provider identifier for the credentials
*/
providerId:
| "slack"
| "discord"
| "msteams"
| "mattermost"
| "ryver"
| "zulip"
| "grafana-on-call"
| "getstream"
| "rocket-chat"
| "whatsapp-business"
| "chat-webhook"
| "novu-slack"
| "fcm"
| "apns"
| "expo"
| "one-signal"
| "pushpad"
| "push-webhook"
| "pusher-beams";
/**
* The integration identifier
*/
integrationIdentifier?: string;
/**
* Credentials payload for the specified provider
*/
credentials: ChannelCredentials;
/**
* The unique identifier of the integration associated with this channel.
*/
_integrationId: string;
}
export interface ChannelCredentials {
/**
* Webhook URL used by chat app integrations. The webhook should be obtained from the chat app provider.
*/
webhookUrl?: string;
/**
* Channel specification for Mattermost chat notifications.
*/
channel?: string;
/**
* Contains an array of the subscriber device tokens for a given provider. Used on Push integrations.
*
* @minItems 0
*
* @minItems 0
*/
deviceTokens?: string[];
/**
* Alert UID for Grafana on-call webhook payload.
*/
alertUid?: string;
/**
* Title to be used with Grafana on-call webhook.
*/
title?: string;
/**
* Image URL property for Grafana on-call webhook.
*/
imageUrl?: string;
/**
* State property for Grafana on-call webhook.
*/
state?: string;
/**
* Link to upstream details property for Grafana on-call webhook.
*/
externalUrl?: string;
}
export interface EmailLayoutRenderOutput {
/**
* Content of the email
*/
body: string;
}
curl -X POST "https://api.novu.co/v2/layouts/string/preview" \
-H "idempotency-key: string" \
-H "Authorization: <token>" \
-H "Content-Type: application/json" \
-d '{
"controlValues": {},
"previewPayload": {
"subscriber": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"phone": "string",
"avatar": "string",
"locale": "string",
"channels": [
{
"providerId": "slack",
"integrationIdentifier": "string",
"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": "string"
}
],
"topics": [
"string"
],
"isOnline": true,
"lastOnlineAt": "string",
"__v": 0,
"data": {},
"timezone": "string"
}
}
}'
{
"previewPayloadExample": {
"subscriber": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"phone": "string",
"avatar": "string",
"locale": "string",
"channels": [
{
"providerId": "slack",
"integrationIdentifier": "string",
"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": "string"
}
],
"topics": [
"string"
],
"isOnline": true,
"lastOnlineAt": "string",
"__v": 0,
"data": {},
"timezone": "string"
}
},
"schema": {},
"result": {
"type": "email",
"preview": {
"body": "string"
}
}
}