Skip to main content

Modifying messages

Welcome to the new home of Slack developer docs!

We're still building and not all features are available quite yet. Enjoy this peek into the future!

Not ready for the future? Return to the past at api.slack.com.

A message captures a specific moment in time. But if you're an app, you might want to publish messages that communicate something that changes over time. Perhaps its the progress of a long running database request, or maybe just a message asking a user to wait for the response of an external API request.

In these cases and others, it's useful to have a way to modify messages from their original form. Slack apps are able to update and delete messages via APIs.


Updating messages

Any non-ephemeral message may possibly be updated by an app, by using the chat.update method.

The process for using this API is largely the same as that for sending messages, but there are a few small differences:

  • You can't move a message, so the channel parameter is used as an identifier for the target message to update, not as a way to update the conversation a message is in.
  • Ephemeral messages can't be updated in this way.
  • An app can't just update every message in a conversation - only ones posted by the authenticated user of the token being used, including those posted as the app. The same applies to bot users, where you use a bot user token. Read the API reference for more information.

Updating messages using response_url

When a user interacts with an interactive element in a message, a payload containing a response_url will be sent to the app that published the interactive message.

This response_url can be used to publish new messages. It can also be used to update the original interactive message, regardless of whether it was an ephemeral message or not.

Read our interactive messages guide for more details on how to update messages using response_url.


Deleting messages

The chat.delete API method offers apps the powerful ability to delete messages, using the same permissions as those used to send messages:

POST https://slack.com/api/chat.delete
Content-type: application/json
Authorization: Bearer xoxb-your-token
{
"channel": "PARENT_CHANNEL_ID",
"ts": "MESSAGE_TO_DELETE"
}

The right for an app to delete a message depends on a few caveats:

  • If using a standard user's user token, only messages posted by that user, or those posted as the app, may be deleted.
  • If using a Workspace Admin user's user token, most messages in that workspace can be deleted.
  • If using a bot user token, only messages posted by that bot user, or those posted as the app, may be deleted.
  • Ephemeral messages can't be deleted in this way.

If the message has some threaded replies, then those replies will be left in the conversation, with a placeholder informing viewers about the deleted message:

This message was deleted placeholder, showing orphaned replies

Deleting messages using response_url

When a user interacts with an interactive element in a message, a payload containing a response_url will be sent to the app that published the interactive message.

This response_url can be used to publish new messages in response. It can also be used to delete the original interactive message, regardless of whether it was an ephemeral message or not.

Read our interactive messages guide for more details on how to delete messages using response_url.