Go to Slack

Modifying messages

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 simple 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 simple to use APIs.


Updating messages

Any non-ephemeral message may possibly be updated by an app, by using the chat.update API 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, but they can be deleted.
  • 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.

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 YOUR_TOKEN_HERE
{
  "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.

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