Skip to main content

Blocks

Block factories for messages, modals, and App Home tabs.

Every factory accepts camelCase input, returns Slack's snake_case wire shape, and validates the result unless settings.validate is false.

actionsBlock()

actionsBlock(input, settings?): SlackWire<ActionsBlock>

Creates a row of interactive elements.

Input fields

Up to 25 buttons, select menus, or other action elements.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
elementsJsonObject[]Interactive elements displayed in the row.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<ActionsBlock>

A validated Slack actions block.

Throws

InvalidUsageError when an element is unsupported or the limit is exceeded.


alertBlock()

alertBlock(input, settings?): SlackObject<"alert">

Creates a severity-labelled notice for a modal.

Input fields

Alert content, severity, and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
level?AlertLevelVisual severity. Defaults to default.
textTextLikeAlert copy. Strings are converted to mrkdwn text.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"alert">

A validated Slack alert block.

Throws

InvalidUsageError when a field violates Slack's constraints.


AlertLevel

AlertLevel = "default" | "info" | "warning" | "error" | "success"

Severity shown by an alert block.


cardBlock()

cardBlock(input, settings?): SlackObject<"card">

Creates a compact content card with text, imagery, and optional actions.

Input fields

Card fields. At least one visible content field must be supplied.

Input fieldTypeDescription
actions?JsonObject[]Up to three button actions.
blockId?stringDeterministic identifier, up to 255 characters.
body?TextLikeMain card copy, up to 200 characters.
heroImage?JsonObjectLarge image displayed above the card content.
icon?JsonObjectSmall image displayed beside the card heading.
slackIcon?JsonObjectSlack-hosted icon created with slackIcon.
subtext?TextLikeSupporting copy displayed below the body.
subtitle?TextLikeSecondary heading, up to 150 characters.
title?TextLikePrimary heading, up to 150 characters.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"card">

A validated Slack card block.

Throws

InvalidUsageError when content is missing or exceeds Slack's limits.


CardBlockInput

Fields accepted by cardBlock.

Properties

PropertyTypeDescription
actions?JsonObject[]Up to three button actions.
blockId?stringDeterministic identifier, up to 255 characters.
body?TextLikeMain card copy, up to 200 characters.
heroImage?JsonObjectLarge image displayed above the card content.
icon?JsonObjectSmall image displayed beside the card heading.
slackIcon?JsonObjectSlack-hosted icon created with slackIcon.
subtext?TextLikeSupporting copy displayed below the body.
subtitle?TextLikeSecondary heading, up to 150 characters.
title?TextLikePrimary heading, up to 150 characters.

carouselBlock()

carouselBlock(input, settings?): SlackObject<"carousel">

Creates a horizontally scrolling collection of cards.

Input fields

One to ten card blocks and an optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
elementsJsonObject[]Between one and ten objects returned by cardBlock.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"carousel">

A validated Slack carousel block.

Throws

InvalidUsageError when the card count is outside Slack's limits.


containerBlock()

containerBlock(input, settings?): SlackObject<"container">

Creates a titled container that groups related child blocks.

Input fields

Child blocks plus optional heading, width, icon, and collapse behavior.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
childBlocksJsonObject[]Up to ten blocks supported by Slack containers.
defaultCollapsed?booleanWhether a collapsible container starts collapsed.
hasHeaderDivider?booleanWhether Slack draws a divider below the header.
icon?JsonObjectOptional image displayed in the header.
isCollapsible?booleanWhether readers can expand and collapse the container.
richTextTitle?JsonObjectRich-text title block. Mutually exclusive with title.
subtitle?TextLikeOptional supporting copy below the title.
title?TextLikePlain-text title. Mutually exclusive with richTextTitle.
width?ContainerWidthContainer width. Defaults to standard.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"container">

A validated Slack container block.

Throws

InvalidUsageError when child content or collapse options are invalid.


ContainerWidth

ContainerWidth = "narrow" | "standard" | "wide" | "full"

Horizontal width used by a container block.


contextActionsBlock()

contextActionsBlock(input, settings?): SlackObject<"context_actions">

Creates contextual feedback or icon controls.

Input fields

Up to five feedback-buttons or icon-button elements.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
elementsJsonObject[]Feedback-buttons or icon-button elements.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"context_actions">

A validated Slack context_actions block.

Throws

InvalidUsageError when an element is unsupported or the limit is exceeded.


contextBlock()

contextBlock(input, settings?): SlackWire<ContextBlock>

Creates compact contextual text and images.

Input fields

Up to ten text objects or image elements.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
elementsJsonObject[]Text objects and image elements.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<ContextBlock>

A validated Slack context block.

Throws

InvalidUsageError when an element is unsupported or the limit is exceeded.


dataTableBlock()

dataTableBlock(input, settings?): SlackObject<"data_table">

Creates a sortable data table.

Input fields

Caption, rows, pagination size, and row-header configuration.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
captionstringAccessible table caption.
pageSize?numberRows per page, between 1 and 100. Defaults to 5.
rowHeaderColumnIndex?numberZero-based column used as the row header. Defaults to 0.
rowsJsonObject[][]Two to 201 equally sized rows containing raw text, raw numbers, or rich text.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"data_table">

A validated Slack data_table block.

Throws

InvalidUsageError when row dimensions, cells, or pagination are invalid.


dataVisualizationBlock()

dataVisualizationBlock(input, settings?): SlackObject<"data_visualization">

Creates a chart rendered by Slack.

Input fields

Chart title, chart object, and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
chartJsonObjectObject returned by pieChart, barChart, areaChart, or lineChart.
titlestringChart heading, up to 50 characters.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"data_visualization">

A validated Slack data_visualization block.

Throws

InvalidUsageError when chart data or labels violate Slack's limits.


dividerBlock()

dividerBlock(input?, settings?): SlackWire<DividerBlock>

Creates a visual divider between blocks.

Input fields

Optional deterministic block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<DividerBlock>

A validated Slack divider block.

Throws

InvalidUsageError when the block identifier is too long.


fileBlock()

fileBlock(input, settings?): SlackWire<FileBlock>

Creates a block that displays a Slack remote file.

Input fields

Remote-file identifier, source, and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
externalIdstringIdentifier assigned when the remote file was added to Slack.
source?"remote"Remote-file source. Slack currently accepts only remote.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<FileBlock>

A validated Slack file block.

Throws

InvalidUsageError when required file data is missing.


headerBlock()

headerBlock(input, settings?): SlackWire<HeaderBlock>

Creates a prominent plain-text heading.

Input fields

Heading text and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
textTextLikeHeading copy. Strings are converted to plain text.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<HeaderBlock>

A validated Slack header block.

Throws

InvalidUsageError when the heading exceeds Slack's limit.


imageBlock()

imageBlock(input, settings?): SlackWire<ImageBlock>

Creates an image block with optional title text.

Input fields

Image URL, accessible alternative, title, and optional block identifier.

Input fieldTypeDescription
altTextstringAccessible description of the image.
blockId?stringDeterministic identifier, up to 255 characters.
imageUrlstringPublic URL of the image.
title?TextLikeOptional plain-text title.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<ImageBlock>

A validated Slack image block.

Throws

InvalidUsageError when text or URL fields violate Slack's constraints.


inputBlock()

inputBlock(input, settings?): SlackWire<InputBlock>

Creates a labelled form control for a modal or App Home tab.

Input fields

Label, input-compatible element, and optional form behavior.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
dispatchAction?booleanWhether changes dispatch an interaction immediately.
elementJsonObjectInput-compatible element such as a text input, picker, or select menu.
hint?TextLikeOptional plain-text help shown below the control.
labelTextLikePlain-text label displayed above the control.
optional?booleanWhether the user may submit without completing this input.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<InputBlock>

A validated Slack input block.

Throws

InvalidUsageError when the element is unsupported or text exceeds Slack's limits.


markdownBlock()

markdownBlock(input, settings?): SlackWire<MarkdownBlock>

Creates a block rendered from GitHub-flavored Markdown.

Input fields

Markdown source and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
textstringGitHub-flavored Markdown source.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<MarkdownBlock>

A validated Slack markdown block.

Throws

InvalidUsageError when the Markdown source violates Slack's limits.


planBlock()

planBlock(input, settings?): SlackObject<"plan">

Creates a titled sequence of task cards.

Input fields

Plan title, tasks, and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
tasks?JsonObject[]Task-card blocks. Their outer type and block_id fields are omitted in the plan.
titlestringHuman-readable plan title.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"plan">

A validated Slack plan block.

Throws

InvalidUsageError when task content violates Slack's constraints.


richTextBlock()

richTextBlock(input, settings?): SlackWire<RichTextBlock>

Creates a rich-text block from rich-text layout objects.

Input fields

Rich-text sections, lists, quotes, or code blocks.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
elementsJsonObject[]Rich-text layout objects.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<RichTextBlock>

A validated Slack rich_text block.

Throws

InvalidUsageError when an element is not a supported rich-text object.


sectionBlock()

sectionBlock(input, settings?): SlackWire<SectionBlock>

Creates a flexible text block with optional fields or an accessory.

Input fields

Section text, fields, accessory, and optional block identifier.

Input fieldTypeDescription
accessory?JsonObjectOptional interactive or visual element displayed beside the text.
blockId?stringDeterministic identifier, up to 255 characters.
fields?TextLike[]Up to ten text fields displayed in columns.
text?TextLikeMain copy. Strings are converted to mrkdwn text.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<SectionBlock>

A validated Slack section block.

Throws

InvalidUsageError when text is missing or a field exceeds Slack's limits.


SectionBlockInput

Fields accepted by sectionBlock.

Properties

PropertyTypeDescription
accessory?JsonObjectOptional interactive or visual element displayed beside the text.
blockId?stringDeterministic identifier, up to 255 characters.
fields?TextLike[]Up to ten text fields displayed in columns.
text?TextLikeMain copy. Strings are converted to mrkdwn text.

tableBlock()

tableBlock(input, settings?): SlackWire<TableBlock>

Creates a table block from raw-text or rich-text cells.

Input fields

Rows, optional column display settings, and optional block identifier.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
columnSettings?JsonObject[]Optional display settings for each column.
rowsJsonObject[][]Up to 100 equally sized rows of raw-text or rich-text cells.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<TableBlock>

A validated Slack table block.

Throws

InvalidUsageError when dimensions, cells, or column settings are invalid.


taskCardBlock()

taskCardBlock(input, settings?): SlackObject<"task_card">

Creates one task card for a plan.

Input fields

Task identity, title, rich content, sources, and optional status.

Input fieldTypeDescription
blockId?stringDeterministic identifier, up to 255 characters.
details?JsonObjectOptional rich-text task details.
output?JsonObjectOptional rich-text task output.
sources?JsonObject[]Optional source links created with urlSource.
status?TaskStatusCurrent task lifecycle state.
taskIdstringStable task identifier.
titlestringHuman-readable task title.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackObject<"task_card">

A validated Slack task_card block.

Throws

InvalidUsageError when identifiers, content, or source links are invalid.


TaskStatus

TaskStatus = "pending" | "in_progress" | "complete" | "error"

Lifecycle state shown by a task card.


videoBlock()

videoBlock(input, settings?): SlackWire<VideoBlock>

Creates an embedded video block.

Slack, rather than this library, enforces its provider allowlist when the payload is submitted.

Input fields

Video URL, thumbnail, accessible text, title, and optional metadata.

Input fieldTypeDescription
altTextstringAccessible summary, up to 200 characters.
authorName?stringOptional author name, up to 50 characters.
blockId?stringDeterministic identifier, up to 255 characters.
description?TextLikeOptional plain-text description, up to 200 characters.
providerIconUrl?stringOptional provider icon URL.
providerName?stringOptional provider name, up to 50 characters.
thumbnailUrlstringPublic preview-image URL.
titleTextLikePlain-text video title, up to 200 characters.
titleUrl?stringOptional destination when the title is selected.
videoUrlstringURL of a video hosted by a Slack-supported provider.

Settings

SettingTypeDescription
settingsFactorySettingsPer-call validation settings.

Returns

SlackWire<VideoBlock>

A validated Slack video block.

Throws

InvalidUsageError when a text field violates Slack's constraints.