Workflows
Generate a step preview
Generates a preview for a specific workflow step by its unique identifier stepId
POST
/
v2
/
workflows
/
{workflowId}
/
step
/
{stepId}
/
preview
PHP
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$generatePreviewRequestDto = new Components\GeneratePreviewRequestDto(
previewPayload: new Components\PreviewPayloadDto(
subscriber: new Components\SubscriberResponseDtoOptional(
channels: [
new Components\ChannelSettingsDto(
providerId: Components\ChatOrPushProviderEnum::NovuSlack,
credentials: new Components\ChannelCredentials(
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>',
),
],
),
context: [
'key' => 'org-acme',
],
),
);
$response = $sdk->workflows->steps->generatePreview(
workflowId: '<id>',
stepId: '<id>',
generatePreviewRequestDto: $generatePreviewRequestDto
);
if ($response->generatePreviewResponseDto !== null) {
// handle response
}{
"previewPayloadExample": {
"subscriber": {
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"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>",
"integrationIdentifier": "<string>"
}
],
"topics": [
"<string>"
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123,
"data": {},
"timezone": "<string>"
},
"payload": {},
"steps": {},
"context": {},
"env": {}
},
"result": {},
"schema": {},
"novuSignature": "<string>"
}Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
Headers
A header for idempotency purposes
Body
application/json
Preview generation details
Response
Created
Preview payload example
Show child attributes
Show child attributes
Preview result
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
The payload schema that was used to generate the preview payload example
Sample novu-signature header value for HTTP request steps
Was this page helpful?
⌘I
PHP
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$generatePreviewRequestDto = new Components\GeneratePreviewRequestDto(
previewPayload: new Components\PreviewPayloadDto(
subscriber: new Components\SubscriberResponseDtoOptional(
channels: [
new Components\ChannelSettingsDto(
providerId: Components\ChatOrPushProviderEnum::NovuSlack,
credentials: new Components\ChannelCredentials(
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>',
),
],
),
context: [
'key' => 'org-acme',
],
),
);
$response = $sdk->workflows->steps->generatePreview(
workflowId: '<id>',
stepId: '<id>',
generatePreviewRequestDto: $generatePreviewRequestDto
);
if ($response->generatePreviewResponseDto !== null) {
// handle response
}{
"previewPayloadExample": {
"subscriber": {
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"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>",
"integrationIdentifier": "<string>"
}
],
"topics": [
"<string>"
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123,
"data": {},
"timezone": "<string>"
},
"payload": {},
"steps": {},
"context": {},
"env": {}
},
"result": {},
"schema": {},
"novuSignature": "<string>"
}