Skip to main content

Blocks

ActionsBlock

Class

ActionsBlock(elements: 'list[Element] | None' = None, block_id: 'str | None' = None) -> 'None'

A Block that is used to hold interactive elements (normally for users to interface with).

Arguments

ArgumentTypeDescription
elementslist[Element] | Nonea list of Elements
(up to a maximum of 25).
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the items in elements are invalid.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ActionsBlock'

Parse a Slack actions block payload.

Currently raises NotImplementedError because round-tripping depends on parsing nested elements; Element.from_dict will land in Phase 7.4b.

AlertBlock

Class

AlertBlock(text: 'TextLike', level: 'AlertLevel' = 'default', block_id: 'str | None' = None) -> 'None'

A severity-labelled alert displayed in a modal.

See: https://docs.slack.dev/reference/block-kit/blocks/alert-block.

Arguments

ArgumentTypeDescription
textTextLikethe text to display in the alert (max 200 chars). Can be a
string or Text object.
levelAlertLevelthe severity of the alert, one of default, info,
warning, error, or success.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'AlertBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

Block

Class

Block(type_: 'BlockType', block_id: 'str | None' = None) -> 'None'

Basis block containing attributes and behaviour common to all blocks. N.B: Block is an abstract class and cannot be sent directly.

from_dict

from_dict(data: 'dict[str, Any]') -> 'Block'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

CardBlock

Class

CardBlock(hero_image: 'Image | None' = None, icon: 'Image | None' = None, title: 'TextLike | None' = None, subtitle: 'TextLike | None' = None, body: 'TextLike | None' = None, actions: 'Button | list[Button] | None' = None, slack_icon: 'SlackIcon | None' = None, subtext: 'TextLike | None' = None, block_id: 'str | None' = None) -> 'None'

A compact card with text, images, and up to three actions. Cards can stand alone or be grouped in a CarouselBlock.

At least one of hero_image, title, actions, or body must be provided.

See: https://docs.slack.dev/reference/block-kit/blocks/card-block.

Arguments

ArgumentTypeDescription
hero_imageImage | Nonean Image element displayed prominently at the top
of the card.
iconImage | Nonean Image element displayed as the card's icon. Cannot be
combined with slack_icon.
titleTextLike | Nonethe card's title (max 150 chars). Can be a string or Text object.
subtitleTextLike | Nonethe card's subtitle (max 150 chars). Can be a string or Text object.
bodyTextLike | Nonethe card's body text (max 200 chars). Can be a string or Text object.
actionsButton | list[Button] | Noneup to three Button elements presented as card actions.
slack_iconSlackIcon | Nonea SlackIcon naming a Slack-provided icon. Cannot be
combined with icon.
subtextTextLike | Noneadditional text displayed at the bottom of the card
(max 200 chars). Can be a string or Text object.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation,
or both icon and slack_icon are provided.

from_dict

from_dict(data: 'dict[str, Any]') -> 'CardBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

CarouselBlock

Class

CarouselBlock(elements: 'list[CardBlock]', block_id: 'str | None' = None) -> 'None'

A horizontally scrolling group of between 1 and 10 CardBlocks.

See: https://docs.slack.dev/reference/block-kit/blocks/carousel-block.

Arguments

ArgumentTypeDescription
elementslist[CardBlock]a list of between 1 and 10 CardBlock objects.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the items in elements are not
CardBlock objects, or the number of cards is invalid.

from_dict

from_dict(data: 'dict[str, Any]') -> 'CarouselBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

ContainerBlock

Class

ContainerBlock(child_blocks: 'list[Block]', title: 'TextLike | None' = None, rich_text_title: 'RichTextBlock | None' = None, subtitle: 'TextLike | None' = None, width: 'ContainerWidth' = 'standard', icon: 'Image | None' = None, is_collapsible: 'bool' = False, default_collapsed: 'bool' = False, has_header_divider: 'bool' = False, block_id: 'str | None' = None) -> 'None'

A titled container grouping up to ten supported child blocks.

One of title or rich_text_title must be provided.

See: https://docs.slack.dev/reference/block-kit/blocks/container-block.

Arguments

ArgumentTypeDescription
child_blockslist[Block]a list of between 1 and 10 blocks to display inside
the container. Supported child block types are actions, context,
divider, file, header, image, input, rich text, section, table,
and video blocks.
titleTextLike | Nonethe container's title (plaintext only; max 150 chars).
rich_text_titleRichTextBlock | Nonea RichTextBlock used as the container's title in
place of title.
subtitleTextLike | Nonethe container's subtitle (max 150 chars). Can be a string
or Text object.
widthContainerWidththe width of the container, one of narrow, standard,
wide, or full.
iconImage | Nonean Image element displayed alongside the title.
is_collapsibleboolwhether the container can be collapsed by the user.
default_collapsedboolwhether the container is initially collapsed
(requires is_collapsible=True).
has_header_dividerboolwhether a divider is shown under the header
(only valid on non-collapsible containers).
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation,
or an unsupported child block type is provided.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ContainerBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

ContextActionsBlock

Class

ContextActionsBlock(elements: 'list[FeedbackButtons | IconButton]', block_id: 'str | None' = None) -> 'None'

Up to five feedback or icon actions displayed as contextual controls.

See: https://docs.slack.dev/reference/block-kit/blocks/context-actions-block.

Arguments

ArgumentTypeDescription
elementslist[FeedbackButtons | IconButton]a list of between 1 and 5 FeedbackButtons or
IconButton elements.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the items in elements are invalid.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ContextActionsBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

ContextBlock

Class

ContextBlock(elements: 'list[Element | CompositionObject] | None' = None, block_id: 'str | None' = None) -> 'None'

A ContextBlock displays contextul message info, including both images and text.

Arguments

ArgumentTypeDescription
elementslist[Element | CompositionObject] | Nonea list of Text objects and Image elements.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorwhen items in elements are not Text or Image or exceed 10 items.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ContextBlock'

Parse a Slack context block payload.

Text elements within the block are parsed back to Text; image elements raise NotImplementedError because Element.from_dict has not yet shipped (Phase 7.4b).

DataTableBlock

Class

DataTableBlock(rows: 'list[list[RawText | RawNumber | RichTextBlock]]', caption: 'str', page_size: 'int' = 5, row_header_column_index: 'int' = 0, block_id: 'str | None' = None) -> 'None'

A sortable data table containing raw text, raw numbers, or rich text.

The first row is the header row; header cells cannot contain rich text.

See: https://docs.slack.dev/reference/block-kit/blocks/data-table-block.

Arguments

ArgumentTypeDescription
rowslist[list[RawText | RawNumber | RichTextBlock]]a list of between 2 and 201 rows (one header row plus up to
200 data rows), each a list of between 1 and 20 RawText,
RawNumber, or RichTextBlock cells. All rows must have the
same number of columns, and the combined cell text cannot
exceed 20,000 characters.
captionstra description of the table for accessibility purposes.
page_sizeintthe number of rows displayed per page (between 1 and 100).
row_header_column_indexintthe (zero-based) index of the column to
treat as the row header.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'DataTableBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

DataVisualizationBlock

Class

DataVisualizationBlock(title: 'str', chart: 'Chart', block_id: 'str | None' = None) -> 'None'

A pie, bar, area, or line chart rendered by Slack.

See: https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block.

Arguments

ArgumentTypeDescription
titlestrthe title displayed above the chart (max 50 chars).
chartChartthe chart to render, one of PieChart, BarChart,
AreaChart, or LineChart.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'DataVisualizationBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

DividerBlock

Class

DividerBlock(block_id: 'str | None' = None) -> 'None'

A content divider, like an <hr> in HTML, to split up different blocks inside of a message.

Arguments

ArgumentTypeDescription
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

from_dict

from_dict(data: 'dict[str, Any]') -> 'DividerBlock'

Parse a Slack divider block payload.

FileBlock

Class

FileBlock(external_id: 'str', block_id: 'str | None' = None, source: 'str' = 'remote') -> 'None'

Displays a remote file (e.g. a PDF).

For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.

Arguments

ArgumentTypeDescription
external_idstrthe ID assigned to the remote file when it was added to Slack.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.
sourcestralways "remote" as per the Slack API (may change in the future).

from_dict

from_dict(data: 'dict[str, Any]') -> 'FileBlock'

Parse a Slack file block payload.

HeaderBlock

Class

HeaderBlock(text: 'str | Text', block_id: 'str | None' = None) -> 'None'

A Header Block is a plain-text block that displays in a larger, bold font.

Arguments

ArgumentTypeDescription
textstr | Textthe text that will be rendered as a heading.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

from_dict

from_dict(data: 'dict[str, Any]') -> 'HeaderBlock'

Parse a Slack header block payload.

ImageBlock

Class

ImageBlock(image_url: 'str', alt_text: 'str | None' = ' ', title: 'Text | str | None' = None, block_id: 'str | None' = None) -> 'None'

An Image Block contains a single graphic, accessed by URL.

Arguments

ArgumentTypeDescription
image_urlstrthe URL pointing to the image file you want to display.
alt_textstr | Nonealternative text for accessibility purposes and when the image fails to load.
titleText | str | Nonean optional text title to be presented with the image.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorwhen one or more of the provided args fails validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'ImageBlock'

Parse a Slack image block payload.

InputBlock

Class

InputBlock(label: 'TextLike', element: 'Element', dispatch_action: 'bool' = False, block_id: 'str | None' = None, hint: 'TextLike | None' = None, optional: 'bool' = False) -> 'None'

A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.

Arguments

ArgumentTypeDescription
labelTextLikethe name which identifies the input field.
elementElementan interactive Element
(e.g. a text field).
dispatch_actionboolwhether the Element
should trigger the sending of a block_actions payload.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.
hintTextLike | Nonean optional additional guide on what input the user should provide.
optionalboolwhether this input field may be empty when the user submits e.g. the modal.

Errors

ErrorWhen
InvalidUsageErrorwhen any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'InputBlock'

Parse a Slack input block payload.

Currently raises NotImplementedError because the nested element requires Element.from_dict, which lands in Phase 7.4b.

MarkdownBlock

Class

MarkdownBlock(text: 'str', block_id: 'str | None' = None) -> 'None'

Displays formatted Markdown text. Unlike the mrkdwn text style used in SectionBlock, MarkdownBlock uses GitHub-flavored Markdown for richer formatting, including features like tables and code blocks. Added to Slack in 2024 for AI / agentic app outputs.

See: https://api.slack.com/reference/block-kit/blocks#markdown.

Arguments

ArgumentTypeDescription
textstrthe Markdown-formatted text to display (1-12000 characters).
block_idstr | Noneyou can use this field to provide a deterministic identifier
for the block.

Errors

ErrorWhen
LengthErrorif text is empty or longer than 12000 characters.

from_dict

from_dict(data: 'dict[str, Any]') -> 'MarkdownBlock'

Parse a Slack markdown block payload.

PlanBlock

Class

PlanBlock(title: 'str', tasks: 'list[TaskCardBlock] | None' = None, block_id: 'str | None' = None) -> 'None'

A titled sequence of TaskCardBlocks.

See: https://docs.slack.dev/reference/block-kit/blocks/plan-block.

Arguments

ArgumentTypeDescription
titlestrthe title of the plan.
taskslist[TaskCardBlock] | Nonea list of TaskCardBlock objects making up the plan.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'PlanBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

RichTextBlock

Class

RichTextBlock(elements: 'RichTextObject | list[RichTextObject]', block_id: 'str | None' = None) -> 'None'

A RichTextBlock is used to provide easier rich text formatting than standard markdown text (e.g. in a SectionBlock) and access to text formatting features not available in traditional markdown (e.g. strikethrough). See the various rich text elements you can include here.

Arguments

ArgumentTypeDescription
elementsRichTextObject | list[RichTextObject]a single rich text element
or a list of those elements.
block_idstr | Noneyou can use this field to provide a deterministic identifier
for the block.

Errors

ErrorWhen
InvalidUsageErrorif the elements in elements are not valid rich
text elements.

from_dict

from_dict(data: 'dict[str, Any]') -> 'RichTextBlock'

Parse a Slack rich_text block payload.

Currently raises NotImplementedError because the rich-text object hierarchy has a deeply nested element graph; round-tripping is deferred to Phase 7.4c.

SectionBlock

Class

SectionBlock(text: 'TextLike | None' = None, block_id: 'str | None' = None, fields: 'TextLike | list[TextLike] | None' = None, accessory: 'Element | None' = None) -> 'None'

A section is one of the most flexible blocks available - it can be used as a simple text block, or with any of the available block elements.

Section blocks can also optionally be given an "accessory," which is typically one of the interactive Elements.

Arguments

ArgumentTypeDescription
textTextLike | Nonetext to include in the block. Can be a string or Text object (of either
mrkdwn or plaintext variety). Defaults to markdown if unspecified. One of either
text or fields must be provided.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.
fieldsTextLike | list[TextLike] | Nonea list of text objects. One of either text or fields must be provided.
accessoryElement | Nonean optional Element object
that will take a secondary place in the block (after or to the side of text
or fields).

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation checks.

from_dict

from_dict(data: 'dict[str, Any]') -> 'SectionBlock'

Parse a Slack section block payload.

Round-trips text and fields. Raises NotImplementedError if an accessory is present, because the accessory is an Element and Element.from_dict is not yet implemented (Phase 7.4b).

TableBlock

Class

TableBlock(rows: 'list[list[RawText | RichTextObject]]', column_settings: 'list[ColumnSettings] | None' = None, block_id: 'str | None' = None) -> 'None'

A TableBlock displays data in a table format.

Arguments

ArgumentTypeDescription
rowslist[list[RawText | RichTextObject]]a list of lists of RawText or RichTextObject objects.
column_settingslist[ColumnSettings] | Nonea list of ColumnSettings objects.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorwhen items in rows are not RawText or RichTextObject objects.
InvalidUsageErrorwhen the number of column_settings does not match the number of
columns in each row.
InvalidUsageErrorwhen the number of rows is greater than 100.
InvalidUsageErrorwhen the number of columns in a row is greater than 20.
InvalidUsageErrorwhen the number of column_settings is greater than 20.

from_dict

from_dict(data: 'dict[str, Any]') -> 'TableBlock'

Parse a Slack table block payload.

Currently raises NotImplementedError because table cells may contain rich-text objects whose round-trip parser is deferred to Phase 7.4c.

TaskCardBlock

Class

TaskCardBlock(task_id: 'str', title: 'str', details: 'RichTextBlock | None' = None, output: 'RichTextBlock | None' = None, sources: 'list[URLSource] | None' = None, status: 'TaskStatus | None' = None, block_id: 'str | None' = None) -> 'None'

One task, its state, rich-text details or output, and source links. Task cards can stand alone or be grouped in a PlanBlock.

See: https://docs.slack.dev/reference/block-kit/blocks/task-card-block.

Arguments

ArgumentTypeDescription
task_idstra unique identifier for the task.
titlestrthe title of the task.
detailsRichTextBlock | Nonea RichTextBlock describing the task in detail.
outputRichTextBlock | Nonea RichTextBlock containing the output of the task.
sourceslist[URLSource] | Nonea list of URLSource elements linking to the sources
used by the task.
statusTaskStatus | Nonethe state of the task, one of pending, in_progress,
complete, or error.
block_idstr | Noneyou can use this field to provide a deterministic identifier for the block.

Errors

ErrorWhen
InvalidUsageErrorif any of the provided arguments fail validation.

from_dict

from_dict(data: 'dict[str, Any]') -> 'TaskCardBlock'

Parse a Slack block payload back into the appropriate Block subclass.

Reads data["type"] and dispatches to the matching subclass's from_dict.

Block types that currently round-trip: AlertBlock, ContextBlock (text elements only), DividerBlock, FileBlock, HeaderBlock, ImageBlock, MarkdownBlock, SectionBlock (without an accessory), and VideoBlock.

Errors

ErrorWhen
MissingRequiredErrorif data["type"] is absent.
TypeMismatchErrorif data["type"] is not a recognised
block type.
NotImplementedErrorwhen the block type is recognised but its
round-trip parser depends on a part of the API that is not
yet implemented (currently: RichTextBlock and any block
containing nested elements, cards, tasks, charts, or
rich text -- ActionsBlock, InputBlock,
TableBlock, CardBlock, CarouselBlock,
ContainerBlock, ContextActionsBlock,
DataTableBlock, DataVisualizationBlock,
TaskCardBlock, and PlanBlock -- see Phase 7.4b
and 7.4c).

VideoBlock

Class

VideoBlock(alt_text: 'str', thumbnail_url: 'str', title: 'TextLike', video_url: 'str', author_name: 'str | None' = None, block_id: 'str | None' = None, description: 'TextLike | None' = None, provider_icon_url: 'str | None' = None, provider_name: 'str | None' = None, title_url: 'str | None' = None) -> 'None'

Embeds a video. Used to display video content inside a Slack message, modal, or App Home tab.

See: https://api.slack.com/reference/block-kit/blocks#video.

Note: Slack restricts which domains may be embedded. The server-side whitelist (e.g. YouTube, Vimeo) is enforced by Slack on receipt of the payload, not by this library; supplying an unsupported URL will result in a Slack API error rather than an InvalidUsageError at construction.

Arguments

ArgumentTypeDescription
alt_textstra plain-text summary of the video, used for accessibility
and notifications (max 200 chars).
thumbnail_urlstra URL pointing to the preview image shown before
playback. Must be HTTPS in production usage.
titleTextLikethe title shown above the video player (plain text, max 200
chars). A str is coerced to TextType.PLAINTEXT Text.
video_urlstrthe URL of the video to embed. Must point to a
Slack-supported provider (see Slack's documentation).
author_namestr | Noneoptional author name shown beneath the video
(max 50 chars).
block_idstr | Nonean optional deterministic identifier for the block.
descriptionTextLike | Noneoptional plain-text description below the video
(max 200 chars). A str is coerced to TextType.PLAINTEXT.
provider_icon_urlstr | Nonean optional URL to the provider's icon.
provider_namestr | Nonean optional provider name shown alongside the icon
(max 50 chars).
title_urlstr | Nonean optional URL to link the title to.

Errors

ErrorWhen
LengthErrorif any length-constrained string exceeds its limit.

from_dict

from_dict(data: 'dict[str, Any]') -> 'VideoBlock'

Parse a Slack video block payload.