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
| Argument | Type | Description |
|---|---|---|
elements | list[Element] | None | a list of Elements (up to a maximum of 25). |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Argument | Type | Description |
|---|---|---|
text | TextLike | the text to display in the alert (max 200 chars). Can be a string or Text object. |
level | AlertLevel | the severity of the alert, one of default, info,warning, error, or success. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 7.4c). |
AlertLevel
Type alias
AlertLevel = Literal['default', 'info', 'warning', 'error', 'success']
Accepted wire values. Use one of these strings; this alias is not a constructor.
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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
hero_image | Image | None | an Image element displayed prominently at the topof the card. |
icon | Image | None | an Image element displayed as the card's icon. Cannot becombined with slack_icon. |
title | TextLike | None | the card's title (max 150 chars). Can be a string or Text object. |
subtitle | TextLike | None | the card's subtitle (max 150 chars). Can be a string or Text object. |
body | TextLike | None | the card's body text (max 200 chars). Can be a string or Text object. |
actions | Button | list[Button] | None | up to three Button elements, serialized in the supplied order.Slack right-aligns buttons with primary last. With two buttons, danger precedes the other button in that group; with three, danger sits at the card's far left. |
slack_icon | SlackIcon | None | a SlackIcon naming a Slack-provided icon. Cannot becombined with icon. |
subtext | TextLike | None | additional text displayed at the bottom of the card (max 200 chars). Can be a string or Text object. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
elements | list[CardBlock] | a list of between 1 and 10 CardBlock objects. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if any of the items in elements are notCardBlock 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
child_blocks | list[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, layout, and video blocks. |
title | TextLike | None | the container's title (plaintext only; max 150 chars). |
rich_text_title | RichTextBlock | None | a RichTextBlock used as the container's title inplace of title. |
subtitle | TextLike | None | the container's subtitle (max 150 chars). Can be a string or Text object. |
width | ContainerWidth | the width of the container, one of narrow, standard,wide, or full. |
icon | Image | None | an Image element displayed alongside the title. |
is_collapsible | bool | whether the container can be collapsed by the user. |
default_collapsed | bool | whether the container is initially collapsed (requires is_collapsible=True). |
has_header_divider | bool | whether a divider is shown under the header (only valid on non-collapsible containers). |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 7.4c). |
ContainerWidth
Type alias
ContainerWidth = Literal['narrow', 'standard', 'wide', 'full']
Accepted wire values. Use one of these strings; this alias is not a constructor.
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
| Argument | Type | Description |
|---|---|---|
elements | list[FeedbackButtons | IconButton] | a list of between 1 and 5 FeedbackButtons orIconButton elements. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
elements | list[Element | CompositionObject] | None | a list of Text objects and Image elements. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when 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
| Argument | Type | Description |
|---|---|---|
rows | list[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 thesame number of columns, and the combined cell text cannot exceed 20,000 characters. |
caption | str | a description of the table for accessibility purposes. |
page_size | int | the number of rows displayed per page (between 1 and 100). |
row_header_column_index | int | the (zero-based) index of the column to treat as the row header. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
title | str | the title displayed above the chart (max 50 chars). |
chart | Chart | the chart to render, one of PieChart, BarChart,AreaChart, or LineChart. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
block_id | str | None | you 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'
A retrieved remote-file representation (e.g. a PDF), not an outgoing message block. Register and share remote files with the Files API, then read back this representation.
For details on how remote files are exposed to Slack, see https://api.slack.com/messaging/files#adding.
Arguments
| Argument | Type | Description |
|---|---|---|
external_id | str | the ID assigned to the remote file when it was added to Slack. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
source | str | always "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
| Argument | Type | Description |
|---|---|---|
text | str | Text | the text that will be rendered as a heading. |
block_id | str | None | you 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 | None' = None, alt_text: 'str | None' = ' ', title: 'Text | str | None' = None, block_id: 'str | None' = None, slack_file: 'SlackFile | None' = None) -> 'None'
An Image Block contains a single graphic, accessed by URL or hosted in Slack.
Exactly one of image_url or slack_file must be provided.
Arguments
| Argument | Type | Description |
|---|---|---|
image_url | str | None | the URL pointing to the image file you want to display. |
alt_text | str | None | alternative text for accessibility purposes and when the image fails to load. |
title | Text | str | None | an optional text title to be presented with the image (max 2000 chars). |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
slack_file | SlackFile | None | a SlackFileto display in place of image_url. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when one or more of the provided args fails validation, or both/neither of image_url and slack_file are provided. |
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
| Argument | Type | Description |
|---|---|---|
label | TextLike | the name which identifies the input field. |
element | Element | an interactive Element (e.g. a text field). |
dispatch_action | bool | whether the Element should trigger the sending of a block_actions payload. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
hint | TextLike | None | an optional additional guide on what input the user should provide. |
optional | bool | whether this input field may be empty when the user submits e.g. the modal. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when 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.
LayoutAlignment
Type alias
LayoutAlignment = Literal['start', 'center', 'end']
Accepted wire values. Use one of these strings; this alias is not a constructor.
LayoutBlock
Class
LayoutBlock(label: 'str', rows: 'list[LayoutRow]', *, is_label_visible: 'bool | None' = None, grid_lines: 'LayoutGridLines | None' = None, fallback: 'list[LayoutFallback] | None' = None, block_id: 'str | None' = None) -> 'None'
A visual grid of one to five rows on messages, modals, and App Home.
The label is required (1–150 Unicode characters). Slack hides it by default; a visible label is bold text without heading semantics. Rows retain source order when wrapping, and stack on mobile. Supply stable fallback blocks for older clients: Slack never synthesizes them. Omitted optional fields remain omitted on input; Slack normalizes an omitted fallback to an empty array.
See: https://docs.slack.dev/reference/block-kit/blocks/layout-block.
from_dict
from_dict(data: 'dict[str, Any]') -> 'LayoutBlock'
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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 7.4c). |
LayoutChild
Value
LayoutChild
Represent a union type
E.g. for int | str
LayoutFallback
Value
LayoutFallback
Represent a union type
E.g. for int | str
LayoutGridLines
Type alias
LayoutGridLines = Literal['none', 'rows', 'outer']
Accepted wire values. Use one of these strings; this alias is not a constructor.
LayoutItem
Class
LayoutItem(block: 'LayoutChild', width: 'LayoutWidth | None' = None, horizontal_alignment: 'LayoutAlignment | None' = None) -> 'None'
One layout cell containing a supported block.
Widths are relative weights: narrow 1, standard 2, wide 3. Alignment is direction-aware; omit it for fill behavior. The child must also be allowed on the enclosing message, modal, or Home surface.
See: https://docs.slack.dev/reference/block-kit/blocks/layout-block.
LayoutRow
Class
LayoutRow(items: 'list[LayoutItem]') -> 'None'
One to three items in source order, with at most one wide-content block.
A carousel, data table, or data visualization cannot share a row with another such block. A data visualization requires more than half the total row weight. Alignment belongs to each item, never to the row itself.
LayoutWidth
Type alias
LayoutWidth = Literal['narrow', 'standard', 'wide']
Accepted wire values. Use one of these strings; this alias is not a constructor.
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
| Argument | Type | Description |
|---|---|---|
text | str | the Markdown-formatted text to display (max 12000 characters). |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
LengthError | if text is 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
| Argument | Type | Description |
|---|---|---|
title | str | the title of the plan. |
tasks | list[TaskCardBlock] | None | a list of up to 50 TaskCardBlock objects making up the plan(required). Each task's task_id must be unique within the plan. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 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
| Argument | Type | Description |
|---|---|---|
elements | RichTextObject | list[RichTextObject] | a single rich text element or a list of those elements. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if the elements in elements are not valid richtext 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
| Argument | Type | Description |
|---|---|---|
text | TextLike | None | text to include in the block. Can be a string or Text object (of eithermrkdwn or plaintext variety). Defaults to markdown if unspecified. One of eithertext or fields must be provided. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
fields | TextLike | list[TextLike] | None | a list of text objects. One of either text or fields must be provided. |
accessory | Element | None | an optional Element object that will take a secondary place in the block (after or to the side of textor fields). |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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 | RawNumber | RichTextObject]]', column_settings: 'list[ColumnSettings | None] | None' = None, block_id: 'str | None' = None) -> 'None'
A TableBlock displays data in a table format.
Arguments
| Argument | Type | Description |
|---|---|---|
rows | list[list[RawText | RawNumber | RichTextObject]] | a list of lists of RawText, RawNumber or RichTextObject objects. |
column_settings | list[ColumnSettings | None] | None | settings for leading columns; omitted trailing columns use Slack defaults. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | when items in rows are not RawText, RawNumber or RichTextObject objects. |
InvalidUsageError | when the number of rows is greater than 100. |
InvalidUsageError | when the number of columns in a row is greater than 20. |
InvalidUsageError | when the number of column_settings is greater than 20. |
LengthError | when displayed cell text exceeds 10,000 Unicode code points. |
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
| Argument | Type | Description |
|---|---|---|
task_id | str | a unique identifier for the task. |
title | str | the title of the task. |
details | RichTextBlock | None | a RichTextBlock describing the task in detail. |
output | RichTextBlock | None | a RichTextBlock containing the output of the task. |
sources | list[URLSource] | None | a list of URLSource elements linking to the sourcesused by the task. |
status | TaskStatus | None | the state of the task (required), one of pending, in_progress,complete, or error. Only tasks in a PlanBlock can be pending;a standalone task card with pending status is rejected when placedin a message or attachment. |
block_id | str | None | you can use this field to provide a deterministic identifier for the block. |
Errors
| Error | When |
|---|---|
InvalidUsageError | if 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
| Error | When |
|---|---|
MissingRequiredError | if data["type"] is absent. |
TypeMismatchError | if data["type"] is not a recognisedblock type. |
NotImplementedError | when 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 blockcontaining nested elements, cards, tasks, charts, or rich text -- ActionsBlock, InputBlock,TableBlock, CardBlock, CarouselBlock,ContainerBlock, LayoutBlock, ContextActionsBlock,DataTableBlock, DataVisualizationBlock,TaskCardBlock, and PlanBlock -- see Phase 7.4band 7.4c). |
TaskStatus
Type alias
TaskStatus = Literal['pending', 'in_progress', 'complete', 'error']
Accepted wire values. Use one of these strings; this alias is not a constructor.
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
| Argument | Type | Description |
|---|---|---|
alt_text | str | a plain-text summary of the video, used for accessibility and notifications (max 2000 chars; may be empty). |
thumbnail_url | str | a URL pointing to the preview image shown before playback. Must be HTTPS in production usage. |
title | TextLike | the title shown above the video player (plain text, max 200 chars). A str is coerced to TextType.PLAINTEXT Text. |
video_url | str | the URL of the video to embed. Must point to a Slack-supported provider (see Slack's documentation). |
author_name | str | None | optional author name shown beneath the video (max 50 chars). |
block_id | str | None | an optional deterministic identifier for the block. |
description | TextLike | None | optional plain-text description below the video (max 200 chars). A str is coerced to TextType.PLAINTEXT. |
provider_icon_url | str | None | an optional URL to the provider's icon. |
provider_name | str | None | an optional provider name shown alongside the icon (max 50 chars). |
title_url | str | None | an optional URL to link the title to. |
Errors
| Error | When |
|---|---|
LengthError | if any length-constrained string exceeds its limit. |
from_dict
from_dict(data: 'dict[str, Any]') -> 'VideoBlock'
Parse a Slack video block payload.