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)
| Parameter | Description |
|---|---|
blocks | The attachment's blocks in display order. |
color | The attachment's left border color: a six-digit hex color or good, warning, or danger. |
fallback | Plain-text summary shown in clients that cannot display attachments. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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)
| Parameter | Description |
|---|---|
blocks | The blocks shown on the App Home tab, in display order. Required. Must contain between 1 and 100 items. |
privateMetadata | Application-defined data returned in view payloads. Slack allows at most 3000 characters. |
callbackId | An identifier returned in view payloads so your app can recognize the view. Slack allows at most 255 characters. |
externalId | A workspace-unique identifier you can use to update the view later. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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)
| Parameter | Description |
|---|---|
channel | The ID of the channel, private group, or conversation that receives the message. Required. Must not be empty. |
blocks | The message blocks in display order. Slack allows at most 50 items. |
attachments | Legacy attachments in display order. Slack allows at most 100 items. |
text | The fallback text used in notifications and by clients that cannot display blocks. |
mrkdwn | Whether Slack formats the top-level text as mrkdwn. |
unfurlLinks | Whether Slack unfurls text-based links. |
unfurlMedia | Whether Slack unfurls media links. |
metadata | Message metadata as a JSON-compatible map, such as event_type and event_payload. Values must be strings, numbers, booleans, lists, dictionaries, or JSON nodes. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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; }
UnfurlLinks
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)
| Parameter | Description |
|---|---|
blocks | The response blocks in display order. Slack allows at most 50 items. |
attachments | Legacy attachments in display order. Slack allows at most 100 items. |
text | The fallback text used in notifications and by clients that cannot display blocks. |
mrkdwn | Whether Slack formats the top-level text as mrkdwn. |
replaceOriginal | Whether the response replaces the message that triggered it. |
responseType | Who can see the response. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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)
| Parameter | Description |
|---|---|
title | The title in the modal's top bar. Required. Slack allows at most 24 characters. A string is sent as a plain_text text object. |
blocks | The blocks shown in the modal, in display order. Required. Must contain between 1 and 100 items. |
close | The label of the button that closes the modal. Slack allows at most 24 characters. A string is sent as a plain_text text object. |
submit | The label of the button that submits the modal. Slack allows at most 24 characters. A string is sent as a plain_text text object. |
privateMetadata | Application-defined data returned in view payloads. Slack allows at most 3000 characters. |
callbackId | An identifier returned in view payloads so your app can recognize the view. Slack allows at most 255 characters. |
clearOnClose | Whether closing this modal closes every view in its stack. |
notifyOnClose | Whether Slack sends a view_closed event when the user closes the modal. |
externalId | A workspace-unique identifier you can use to update the view later. |
submitDisabled | Whether the submit button starts disabled. Only valid in workflow configuration modals. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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.
| Constant | Slack value | Meaning |
|---|---|---|
InChannel | in_channel | Visible to everyone in the channel. |
Ephemeral | ephemeral | Visible 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)
| Parameter | Description |
|---|---|
blocks | The message blocks in display order. Slack allows at most 50 items. |
attachments | Legacy attachments in display order. Slack allows at most 100 items. |
text | The fallback text used in notifications and by clients that cannot display blocks. |
responseType | Who can see the response. |
replaceOriginal | Whether the response replaces the message that triggered it. |
deleteOriginal | Whether the response deletes the message that triggered it. |
unfurlLinks | Whether Slack unfurls text-based links. |
unfurlMedia | Whether Slack unfurls media links. |
metadata | Message metadata as a JSON-compatible map, such as event_type and event_payload. Values must be strings, numbers, booleans, lists, dictionaries, or JSON nodes. |
additionalFields | Slack 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. |
| Throws | When |
|---|---|
ValidationException | The value breaks a Block Kit rule, such as a missing required field or an exceeded length limit. |
ArgumentException | A 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; }
UnfurlLinks
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; }