Skip to main content

Payloads and Views

Generated from actual PHP reflection and PHPDoc. Names live in the Slackblocks namespace. Use named arguments and declare(strict_types=1); values validate before construction returns.

Attachment​

A legacy message attachment containing blocks and an optional color bar. Only blocks supported in messages are accepted. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$blocks​

Adds the attachment's blocks in display order.

/** @var list<Block> */
public readonly array $blocks;

Related types: Block

$color​

Sets the attachment's left border color: a six-digit hex color or good, warning, or danger.

public readonly ?string $color;

$fallback​

Sets plain-text summary shown in clients that cannot display attachments.

public readonly ?string $fallback;

__construct​

Construct a validated immutable value.

public function __construct(array $blocks, ?string $color = NULL, ?string $fallback = NULL, ?JsonObject $extensions = NULL)
ParameterDescription
blockslist<Block> — Adds the attachment's blocks in display order.
colorstring|null — Sets the attachment's left border color: a six-digit hex color or good, warning, or danger.
fallbackstring|null — Sets plain-text summary shown in clients that cannot display attachments.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject

HomeTabView​

The payload for publishing an App Home tab with views.publish. Only blocks supported on the App Home tab are accepted. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$blocks​

Adds the blocks shown on the App Home tab, in display order.

/** @var list<Block> */
public readonly array $blocks;

Related types: Block

$privateMetadata​

Sets application-defined data returned in view payloads.

public readonly ?string $privateMetadata;

$callbackId​

Sets an identifier returned in view payloads so your app can recognize the view.

public readonly ?string $callbackId;

$externalId​

Sets a workspace-unique identifier you can use to update the view later.

public readonly ?string $externalId;

__construct​

Construct a validated immutable value.

public function __construct(array $blocks, ?string $privateMetadata = NULL, ?string $callbackId = NULL, ?string $externalId = NULL, ?JsonObject $extensions = NULL)
ParameterDescription
blockslist<Block> — Adds the blocks shown on the App Home tab, in display order.
privateMetadatastring|null — Sets application-defined data returned in view payloads.
callbackIdstring|null — Sets an identifier returned in view payloads so your app can recognize the view.
externalIdstring|null — Sets a workspace-unique identifier you can use to update the view later.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject

MessagePayload​

A complete payload for chat.postMessage and related Web API methods. Only blocks supported in messages are accepted. Markdown block text is limited to 12,000 characters, and data table cell text to 20,000 characters, across the whole message. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$channel​

Sets the ID of the channel, private group, or conversation that receives the message.

public readonly string $channel;

$blocks​

Adds the message blocks in display order.

/** @var list<Block>|null */
public readonly ?array $blocks;

Related types: Block

$attachments​

Adds legacy attachments in display order.

/** @var list<Attachment>|null */
public readonly ?array $attachments;

Related types: Attachment

$text​

Sets the fallback text used in notifications and by clients that cannot display blocks.

public readonly ?string $text;

$mrkdwn​

Sets whether Slack formats the top-level text as mrkdwn.

public readonly ?bool $mrkdwn;

Sets whether Slack unfurls text-based links.

public readonly ?bool $unfurlLinks;

$unfurlMedia​

Sets whether Slack unfurls media links.

public readonly ?bool $unfurlMedia;

$metadata​

Sets message metadata as a JSON-compatible map, such as event_type and event_payload.

public readonly ?JsonObject $metadata;

Related types: JsonObject

__construct​

Construct a validated immutable value.

public function __construct(string $channel, ?array $blocks = NULL, ?array $attachments = NULL, ?string $text = '', ?bool $mrkdwn = true, ?bool $unfurlLinks = NULL, ?bool $unfurlMedia = NULL, ?JsonObject $metadata = NULL, ?JsonObject $extensions = NULL)
ParameterDescription
channelstring — Sets the ID of the channel, private group, or conversation that receives the message.
blockslist<Block>|null — Adds the message blocks in display order.
attachmentslist<Attachment>|null — Adds legacy attachments in display order.
textstring|null — Sets the fallback text used in notifications and by clients that cannot display blocks.
mrkdwnbool|null — Sets whether Slack formats the top-level text as mrkdwn.
unfurlLinksbool|null — Sets whether Slack unfurls text-based links.
unfurlMediabool|null — Sets whether Slack unfurls media links.
metadataJsonObject|null — Sets message metadata as a JSON-compatible map, such as event_type and event_payload.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject

MessageResponse​

A response body for slash commands and interaction response URLs. Only blocks supported in messages are accepted. Markdown block text is limited to 12,000 characters, and data table cell text to 20,000 characters, across the whole message. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$blocks​

Adds the response blocks in display order.

/** @var list<Block>|null */
public readonly ?array $blocks;

Related types: Block

$attachments​

Adds legacy attachments in display order.

/** @var list<Attachment>|null */
public readonly ?array $attachments;

Related types: Attachment

$text​

Sets the fallback text used in notifications and by clients that cannot display blocks.

public readonly ?string $text;

$mrkdwn​

Sets whether Slack formats the top-level text as mrkdwn.

public readonly ?bool $mrkdwn;

$replaceOriginal​

Sets whether the response replaces the message that triggered it.

public readonly ?bool $replaceOriginal;

$responseType​

Sets who can see the response.

public readonly ?ResponseType $responseType;

Related types: ResponseType

__construct​

Construct a validated immutable value.

public function __construct(?array $blocks = NULL, ?array $attachments = NULL, ?string $text = '', ?bool $mrkdwn = true, ?bool $replaceOriginal = false, ?ResponseType $responseType = ResponseType::InChannel, ?JsonObject $extensions = NULL)
ParameterDescription
blockslist<Block>|null — Adds the response blocks in display order.
attachmentslist<Attachment>|null — Adds legacy attachments in display order.
textstring|null — Sets the fallback text used in notifications and by clients that cannot display blocks.
mrkdwnbool|null — Sets whether Slack formats the top-level text as mrkdwn.
replaceOriginalbool|null — Sets whether the response replaces the message that triggered it.
responseTypeResponseType|null — Sets who can see the response.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject, ResponseType

ModalView​

The view payload for views.open, views.push, and views.update. Only blocks supported in modals are accepted. A modal that contains an input block must have a submit label. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$title​

Sets the title in the modal's top bar.

public readonly PlainText $title;

Related types: PlainText

$blocks​

Adds the blocks shown in the modal, in display order.

/** @var list<Block> */
public readonly array $blocks;

Related types: Block

$close​

Sets the label of the button that closes the modal.

public readonly ?PlainText $close;

Related types: PlainText

$submit​

Sets the label of the button that submits the modal.

public readonly ?PlainText $submit;

Related types: PlainText

$privateMetadata​

Sets application-defined data returned in view payloads.

public readonly ?string $privateMetadata;

$callbackId​

Sets an identifier returned in view payloads so your app can recognize the view.

public readonly ?string $callbackId;

$clearOnClose​

Sets whether closing this modal closes every view in its stack.

public readonly ?bool $clearOnClose;

$notifyOnClose​

Sets whether Slack sends a view_closed event when the user closes the modal.

public readonly ?bool $notifyOnClose;

$externalId​

Sets a workspace-unique identifier you can use to update the view later.

public readonly ?string $externalId;

$submitDisabled​

Sets whether the submit button starts disabled. Only valid in workflow configuration modals.

public readonly ?bool $submitDisabled;

__construct​

Construct a validated immutable value.

public function __construct(PlainText|string $title, array $blocks, PlainText|string|null $close = NULL, PlainText|string|null $submit = NULL, ?string $privateMetadata = NULL, ?string $callbackId = NULL, ?bool $clearOnClose = NULL, ?bool $notifyOnClose = NULL, ?string $externalId = NULL, ?bool $submitDisabled = NULL, ?JsonObject $extensions = NULL)
ParameterDescription
titlePlainText|string — Sets the title in the modal's top bar.
blockslist<Block> — Adds the blocks shown in the modal, in display order.
closePlainText|string|null — Sets the label of the button that closes the modal.
submitPlainText|string|null — Sets the label of the button that submits the modal.
privateMetadatastring|null — Sets application-defined data returned in view payloads.
callbackIdstring|null — Sets an identifier returned in view payloads so your app can recognize the view.
clearOnClosebool|null — Sets whether closing this modal closes every view in its stack.
notifyOnClosebool|null — Sets whether Slack sends a view_closed event when the user closes the modal.
externalIdstring|null — Sets a workspace-unique identifier you can use to update the view later.
submitDisabledbool|null — Sets whether the submit button starts disabled. Only valid in workflow configuration modals.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject, PlainText

WebhookMessage​

A payload for incoming webhooks. Only blocks supported in messages are accepted. Markdown block text is limited to 12,000 characters, and data table cell text to 20,000 characters, across the whole message. Readonly properties contain normalized values. See Value for inherited with(), fromArray(), fromJson(), toArray(), toJson() and jsonSerialize().

See the Slack reference.

$blocks​

Adds the message blocks in display order.

/** @var list<Block>|null */
public readonly ?array $blocks;

Related types: Block

$attachments​

Adds legacy attachments in display order.

/** @var list<Attachment>|null */
public readonly ?array $attachments;

Related types: Attachment

$text​

Sets the fallback text used in notifications and by clients that cannot display blocks.

public readonly ?string $text;

$responseType​

Sets who can see the response.

public readonly ?ResponseType $responseType;

Related types: ResponseType

$replaceOriginal​

Sets whether the response replaces the message that triggered it.

public readonly ?bool $replaceOriginal;

$deleteOriginal​

Sets whether the response deletes the message that triggered it.

public readonly ?bool $deleteOriginal;

Sets whether Slack unfurls text-based links.

public readonly ?bool $unfurlLinks;

$unfurlMedia​

Sets whether Slack unfurls media links.

public readonly ?bool $unfurlMedia;

$metadata​

Sets message metadata as a JSON-compatible map, such as event_type and event_payload.

public readonly ?JsonObject $metadata;

Related types: JsonObject

__construct​

Construct a validated immutable value.

public function __construct(?array $blocks = NULL, ?array $attachments = NULL, ?string $text = NULL, ?ResponseType $responseType = NULL, ?bool $replaceOriginal = NULL, ?bool $deleteOriginal = NULL, ?bool $unfurlLinks = NULL, ?bool $unfurlMedia = NULL, ?JsonObject $metadata = NULL, ?JsonObject $extensions = NULL)
ParameterDescription
blockslist<Block>|null — Adds the message blocks in display order.
attachmentslist<Attachment>|null — Adds legacy attachments in display order.
textstring|null — Sets the fallback text used in notifications and by clients that cannot display blocks.
responseTypeResponseType|null — Sets who can see the response.
replaceOriginalbool|null — Sets whether the response replaces the message that triggered it.
deleteOriginalbool|null — Sets whether the response deletes the message that triggered it.
unfurlLinksbool|null — Sets whether Slack unfurls text-based links.
unfurlMediabool|null — Sets whether Slack unfurls media links.
metadataJsonObject|null — Sets message metadata as a JSON-compatible map, such as event_type and event_payload.
extensionsJsonObject|null — Additional JSON fields; modeled names and type are reserved.
ThrowsWhen
ValidationErrorA content or contextual rule fails. PHP rejects incompatible call signatures with native errors.

Related types: JsonObject, ResponseType