Skip to main content

Builder

block_kit_builder_url

Function

block_kit_builder_url(payload: 'Block | list[Block] | Resolvable | dict[str, Any]', team_id: 'str | None' = None) -> 'str'

Build a URL that opens payload in Slack's Block Kit Builder.

Use this to preview a message, view, or list of blocks in the browser without manually copying JSON into the Builder.

Arguments

ArgumentTypeDescription
payloadBlock | list[Block] | Resolvable | dict[str, Any]any of:

- A single Block -- wrapped in {"blocks": [block]}.
- A list of Block -- wrapped in {"blocks": [...]}.
- Anything with a _resolve method (Message,
WebhookMessage, MessageResponse, View,
ModalView, HomeTabView, etc.) -- used as-is.
- A raw dict -- used as-is. This is the escape hatch for
callers building payloads outside the type hierarchy.
team_idstr | Noneoptional Slack team ID. When supplied, produces a
workspace-specific Builder URL of the form
https://app.slack.com/block-kit-builder/T0123#<JSON>.
When None (the default), produces the generic URL.

Returns

TypeDescription
strA fully-formed Block Kit Builder URL.

Examples

Single block::

from slackblocks import SectionBlock, block_kit_builder_url

url = block_kit_builder_url(SectionBlock("Hi"))

Multiple blocks::

url = block_kit_builder_url([ SectionBlock("Heading"), DividerBlock(), ])

Existing message::

url = block_kit_builder_url(my_message)

Targeting a specific workspace::

url = block_kit_builder_url(my_message, team_id="T0123ABCD")