Skip to main content
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

Authorization
string
header
required

API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".

Headers

idempotency-key
string

A header for idempotency purposes

Path Parameters

workflowId
string
required
stepId
string
required

Body

application/json

Preview generation details

controlValues
object

Optional control values

previewPayload
object

Optional payload for preview generation

Response

Created

previewPayloadExample
object
required

Preview payload example

result
object
required

Preview result

schema
object

The payload schema that was used to generate the preview payload example

novuSignature
string

Sample novu-signature header value for HTTP request steps