Skip to main content

Basic Example

{
  "type": "button",
  "text": "Submit",
  "action_id": "submit_btn",
  "style": "primary"
}

Complete Example

Example Code
[
  {
    "type": "actions",
    "action_url": "https://api.example.com/actions",
    "elements": [
      {
        "type": "button",
        "text": "Approve",
        "action_id": "approve_btn",
        "value": "approved",
        "style": "primary"
      },
      {
        "type": "button",
        "text": "Reject",
        "action_id": "reject_btn",
        "value": "rejected",
        "style": "danger",
        "confirm": {
          "title": "Are you sure?",
          "text": "This action cannot be undone.",
          "confirm_text": "Yes, reject",
          "deny_text": "Cancel"
        }
      },
      {
        "type": "button",
        "text": "View Details",
        "action_id": "view_btn",
        "url": "https://example.com/details"
      }
    ]
  }
]

Properties

type
string
required
Identifies this as a button blockMust be button
text
string
required
The visible label text displayed on the button
action_id
string
required
A unique identifier for the button action. Included in the action payload when the button is clicked.
value
string
required
An optional value sent with the action payload when clicked. Useful for passing data to the action handler.
style
string
default:"default"
required
The visual style of the buttonAllowed values: primary, danger, default
url
string
required
A URL to open when the button is clicked. When set, the button acts as a link instead of triggering an action POST.
action_url
string
required
The endpoint URL to POST the action payload to when clicked. If not set, the parent actions block’s action_url is used.
confirm
object
required
An optional confirmation dialog shown before the action is executed.
PropertyTypeDescription
titlestringDialog title
textstringConfirmation message
confirm_textstringText for the confirm button
deny_textstringText for the cancel button
disabled
boolean
default:"false"
required
When true, the button is rendered in a disabled state and cannot be clicked.

Action Payload

When a button is clicked, the following payload is POSTed to the action_url:
{
  "type": "button_click",
  "action_id": "approve_btn",
  "value": "approved",
  "block_id": "actions_123"
}

Server Response

The server can respond with one of these action types:
Response TypeDescription
replaceReplace the entire block with new BlockKit content
updateUpdate specific properties of the block
appendAppend new blocks after the current block
errorsDisplay validation errors
{
  "action": "replace",
  "blocks": [
    {
      "type": "alert",
      "severity": "success",
      "text": "Request approved successfully!"
    }
  ]
}

Usage Notes

  • Buttons are typically placed inside an Actions block
  • Buttons can also be placed inside Section and Column Layout blocks
  • When url is set, the button opens the URL instead of sending an action POST
  • The confirm dialog provides a safety net for destructive or irreversible actions