/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
docs/framework/payload.mdx
62 строки
2 KB
mintlify[bot]
docs(docs): Apply SEO and metadata best practices (#11903)
13 июл 2026, 11:22
Не верифицирован
13 июл 2026, 11:22
01f36ae
Код
Авторство
О чём код?
--- title: 'Payload' description: "Define and validate workflow payload schemas in Novu Framework with Zod or JSON Schema to ensure type safety on data passed to novu.trigger." --- Workflow payload is the data passed during the `novu.trigger` method. This is useful for ensuring that the payload is correctly formatted and that the data is valid. ## Payload Schema Payload schema is defining the payload passed during the `novu.trigger` method. This is useful for ensuring that the payload is correctly formatted and that the data is valid. ```tsx import { render } from '@react-email/components'; import { ReactEmailContent } from './ReactEmailContent'; workflow( 'comment-on-post', async ({ step, payload }) => { await step.email('send-email', async () => { return { subject: `You have a new comment from: ${payload.author_name}.`, body: render(<ReactEmailContent comment={payload.comment} />), }; }); }, { payloadSchema: { // Always `object` type: 'object', // Specify the properties to validate. Supports deep nesting. properties: { post_id: { type: 'number' }, author_name: { type: 'string' }, comment: { type: 'string', maxLength: 200 }, }, // Specify the array of which properties are required. required: ['post_id', 'comment'], // Used to enforce full type strictness, with no rogue properties. additionalProperties: false, // The `as const` is important to let Typescript know that this // type won't change, enabling strong typing on `inputs` via type // inference of the provided JSON Schema. } as const, } ); ``` ## Passing Payload Here is an example of the validated payload during trigger: ```typescript novu.trigger({ workflowId: "workflowId", to: { subscriberId: 'subscriber_id' }, payload: { post_id: 1234, author_name: 'John Doe', comment: 'Looks good!', }, }); ```