Skip to main content

Payloads And Views

This page documents the public C# API for payloads and views, generated from the XML documentation of the compiled library. Values are immutable, constructors take named arguments and validate them, and read-only properties return what was passed.

Attachment

A legacy message attachment containing blocks and an optional color bar.

  • Only blocks supported in messages are accepted.

See the Slack reference.

Attachment

Creates and validates a Attachment.

public Attachment(IEnumerable<IBlock>? blocks = null, string? color = null, string? fallback = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
blocksThe attachment's blocks in display order.
colorThe attachment's left border color: a six-digit hex color or good, warning, or danger.
fallbackPlain-text summary shown in clients that cannot display attachments.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: Attachment, IBlock

Blocks

Gets the attachment's blocks in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

Color

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

The value, or null when it was not set.

public string? Color { get; }

Fallback

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

The value, or null when it was not set.

public string? Fallback { get; }

HomeTabView

The payload for publishing an App Home tab with views.publish.

  • Required: blocks.
  • Only blocks supported on the App Home tab are accepted.

See the Slack reference.

HomeTabView

Creates and validates a HomeTabView.

public HomeTabView(IEnumerable<IBlock> blocks, string? privateMetadata = null, string? callbackId = null, string? externalId = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
blocksThe blocks shown on the App Home tab, in display order. Required. Must contain between 1 and 100 items.
privateMetadataApplication-defined data returned in view payloads. Slack allows at most 3000 characters.
callbackIdAn identifier returned in view payloads so your app can recognize the view. Slack allows at most 255 characters.
externalIdA workspace-unique identifier you can use to update the view later.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: HomeTabView, IBlock

Blocks

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

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

PrivateMetadata

Gets application-defined data returned in view payloads.

The value, or null when it was not set.

public string? PrivateMetadata { get; }

CallbackId

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

The value, or null when it was not set.

public string? CallbackId { get; }

ExternalId

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

The value, or null when it was not set.

public string? ExternalId { get; }

MessagePayload

A complete payload for chat.postMessage and related Web API methods.

  • Required: channel.
  • Only blocks supported in messages are accepted.

See the Slack reference.

MessagePayload

Creates and validates a MessagePayload.

public MessagePayload(string channel, IEnumerable<IBlock>? blocks = null, IEnumerable<Attachment>? attachments = null, string? text = null, bool? mrkdwn = null, bool? unfurlLinks = null, bool? unfurlMedia = null, IReadOnlyDictionary<string, object?>? metadata = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
channelThe ID of the channel, private group, or conversation that receives the message. Required. Must not be empty.
blocksThe message blocks in display order. Slack allows at most 50 items.
attachmentsLegacy attachments in display order. Slack allows at most 100 items.
textThe fallback text used in notifications and by clients that cannot display blocks.
mrkdwnWhether Slack formats the top-level text as mrkdwn.
unfurlLinksWhether Slack unfurls text-based links.
unfurlMediaWhether Slack unfurls media links.
metadataMessage metadata as a JSON-compatible map, such as event_type and event_payload. Values must be strings, numbers, booleans, lists, dictionaries, or JSON nodes.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: Attachment, IBlock, MessagePayload

Channel

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

public string Channel { get; }

Blocks

Gets the message blocks in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

Attachments

Gets legacy attachments in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<Attachment> Attachments { get; }

Related types: Attachment

Text

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

public string? Text { get; }

Related types: Text

Mrkdwn

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

public bool? Mrkdwn { get; }

Gets whether Slack unfurls text-based links.

The value, or null when it was not set.

public bool? UnfurlLinks { get; }

UnfurlMedia

Gets whether Slack unfurls media links.

The value, or null when it was not set.

public bool? UnfurlMedia { get; }

Metadata

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

The value, or null when it was not set.

public IReadOnlyDictionary<string, object?>? Metadata { get; }

MessageResponse

A response body for slash commands and interaction response URLs.

  • Only blocks supported in messages are accepted.

See the Slack reference.

MessageResponse

Creates and validates a MessageResponse.

public MessageResponse(IEnumerable<IBlock>? blocks = null, IEnumerable<Attachment>? attachments = null, string? text = null, bool? mrkdwn = null, bool? replaceOriginal = null, ResponseType? responseType = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
blocksThe response blocks in display order. Slack allows at most 50 items.
attachmentsLegacy attachments in display order. Slack allows at most 100 items.
textThe fallback text used in notifications and by clients that cannot display blocks.
mrkdwnWhether Slack formats the top-level text as mrkdwn.
replaceOriginalWhether the response replaces the message that triggered it.
responseTypeWho can see the response.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: Attachment, IBlock, MessageResponse, ResponseType

Blocks

Gets the response blocks in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

Attachments

Gets legacy attachments in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<Attachment> Attachments { get; }

Related types: Attachment

Text

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

public string? Text { get; }

Related types: Text

Mrkdwn

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

public bool? Mrkdwn { get; }

ReplaceOriginal

Gets whether the response replaces the message that triggered it.

public bool? ReplaceOriginal { get; }

ResponseType

Gets who can see the response.

public ResponseType? ResponseType { get; }

Related types: ResponseType

ModalView

The view payload for views.open, views.push, and views.update.

  • Required: title, blocks.
  • Only blocks supported in modals are accepted.
  • A modal that contains an input block must have a submit label.

See the Slack reference.

ModalView

Creates and validates a ModalView.

public ModalView(PlainText title, IEnumerable<IBlock> blocks, PlainText? close = null, PlainText? submit = null, string? privateMetadata = null, string? callbackId = null, bool? clearOnClose = null, bool? notifyOnClose = null, string? externalId = null, bool? submitDisabled = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
titleThe title in the modal's top bar. Required. Slack allows at most 24 characters. A string is sent as a plain_text text object.
blocksThe blocks shown in the modal, in display order. Required. Must contain between 1 and 100 items.
closeThe label of the button that closes the modal. Slack allows at most 24 characters. A string is sent as a plain_text text object.
submitThe label of the button that submits the modal. Slack allows at most 24 characters. A string is sent as a plain_text text object.
privateMetadataApplication-defined data returned in view payloads. Slack allows at most 3000 characters.
callbackIdAn identifier returned in view payloads so your app can recognize the view. Slack allows at most 255 characters.
clearOnCloseWhether closing this modal closes every view in its stack.
notifyOnCloseWhether Slack sends a view_closed event when the user closes the modal.
externalIdA workspace-unique identifier you can use to update the view later.
submitDisabledWhether the submit button starts disabled. Only valid in workflow configuration modals.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: IBlock, ModalView, PlainText

Title

Gets the title in the modal's top bar.

public PlainText Title { get; }

Related types: PlainText

Blocks

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

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

Close

Gets the label of the button that closes the modal.

The value, or null when it was not set.

public PlainText? Close { get; }

Related types: PlainText

Submit

Gets the label of the button that submits the modal.

The value, or null when it was not set.

public PlainText? Submit { get; }

Related types: PlainText

PrivateMetadata

Gets application-defined data returned in view payloads.

The value, or null when it was not set.

public string? PrivateMetadata { get; }

CallbackId

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

The value, or null when it was not set.

public string? CallbackId { get; }

ClearOnClose

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

The value, or null when it was not set.

public bool? ClearOnClose { get; }

NotifyOnClose

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

The value, or null when it was not set.

public bool? NotifyOnClose { get; }

ExternalId

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

The value, or null when it was not set.

public string? ExternalId { get; }

SubmitDisabled

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

The value, or null when it was not set.

public bool? SubmitDisabled { get; }

ResponseType

Visibility of a slash-command or interaction response.

ToWireValue() returns the value Slack expects in JSON.

ConstantSlack valueMeaning
InChannelin_channelVisible to everyone in the channel.
EphemeralephemeralVisible only to the user who triggered the response.

WebhookMessage

A payload for incoming webhooks.

  • Only blocks supported in messages are accepted.

See the Slack reference.

WebhookMessage

Creates and validates a WebhookMessage.

public WebhookMessage(IEnumerable<IBlock>? blocks = null, IEnumerable<Attachment>? attachments = null, string? text = null, ResponseType? responseType = null, bool? replaceOriginal = null, bool? deleteOriginal = null, bool? unfurlLinks = null, bool? unfurlMedia = null, IReadOnlyDictionary<string, object?>? metadata = null, IReadOnlyDictionary<string, object?>? additionalFields = null)
ParameterDescription
blocksThe message blocks in display order. Slack allows at most 50 items.
attachmentsLegacy attachments in display order. Slack allows at most 100 items.
textThe fallback text used in notifications and by clients that cannot display blocks.
responseTypeWho can see the response.
replaceOriginalWhether the response replaces the message that triggered it.
deleteOriginalWhether the response deletes the message that triggered it.
unfurlLinksWhether Slack unfurls text-based links.
unfurlMediaWhether Slack unfurls media links.
metadataMessage metadata as a JSON-compatible map, such as event_type and event_payload. Values must be strings, numbers, booleans, lists, dictionaries, or JSON nodes.
additionalFieldsSlack fields that have no named parameter yet, such as a field Slack introduced after this release. Values must be strings, numbers, booleans, lists, dictionaries, JSON nodes, or slackblocks values, and are validated with the rest of the object. Typed properties do not reflect them, and a field cannot be set both here and through its named parameter.
ThrowsWhen
ValidationExceptionThe value breaks a Block Kit rule, such as a missing required field or an exceeded length limit.
ArgumentExceptionA collection contains null, or an additional field cannot be written as JSON or repeats a named parameter.

Related types: Attachment, IBlock, ResponseType, WebhookMessage

Blocks

Gets the message blocks in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<IBlock> Blocks { get; }

Related types: IBlock

Attachments

Gets legacy attachments in display order.

The values in order, or an empty list when none were set.

public IReadOnlyList<Attachment> Attachments { get; }

Related types: Attachment

Text

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

The value, or null when it was not set.

public string? Text { get; }

Related types: Text

ResponseType

Gets who can see the response.

The value, or null when it was not set.

public ResponseType? ResponseType { get; }

Related types: ResponseType

ReplaceOriginal

Gets whether the response replaces the message that triggered it.

The value, or null when it was not set.

public bool? ReplaceOriginal { get; }

DeleteOriginal

Gets whether the response deletes the message that triggered it.

The value, or null when it was not set.

public bool? DeleteOriginal { get; }

Gets whether Slack unfurls text-based links.

The value, or null when it was not set.

public bool? UnfurlLinks { get; }

UnfurlMedia

Gets whether Slack unfurls media links.

The value, or null when it was not set.

public bool? UnfurlMedia { get; }

Metadata

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

The value, or null when it was not set.

public IReadOnlyDictionary<string, object?>? Metadata { get; }