You must enable javascript in order to use the Slack API Documentation. You can do this in your browser settings.
Go to Slack


You're not signed into any teams. Sign in to test authentication.

This method posts a message to a public channel, private channel, or direct message/IM channel.


Argument Example Required Description
token xxxx-xxxxxxxxx-xxxx Required

Authentication token bearing required scopes.

channel C1234567890 Required

Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name. See below for more details.

text Hello world Required

Text of the message to send. See below for an explanation of formatting. This field is usually required, unless you're providing only attachments instead.

as_user true Optional

Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See authorship below.

attachments [{"pretext": "pre-hello", "text": "text-world"}] Optional

A JSON-based array of structured attachments, presented as a URL-encoded string.

icon_emoji :chart_with_upwards_trend: Optional

Emoji to use as the icon for this message. Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.

icon_url Optional

URL to an image to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.

link_names true Optional

Find and link channel names and usernames.

mrkdwn false Optional, default=true

Disable Slack markup parsing by setting to false. Enabled by default.

parse full Optional

Change how messages are treated. Defaults to none. See below.

reply_broadcast true Optional

Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false.

thread_ts 1234567890.123456 Optional

Provide another message's ts value to make this message a reply. Avoid using a reply's ts value; use its parent instead.

unfurl_links true Optional

Pass true to enable unfurling of primarily text-based content.

unfurl_media false Optional

Pass false to disable unfurling of media content.

username My Bot Optional

Set your bot's user name. Must be used in conjunction with as_user set to false, otherwise ignored. See authorship below.

This method supports application/json via HTTP POST. Present your token in your request's Authorization header. Learn more.

Please note that the default value of the as_user parameter varies depending on the kind of token you're using. It's best to be explicit with this value. Read more about Authorship to understand how its default value may vary.

A message must have either text or attachments or both. The text parameter is required unless you provide attachments. You can use both parameters in conjunction with each other to create awesome messages.

JSON POST support

As of October 2017, it's now possible to send a well-formatted application/json POST body to chat.postMessage and other Web API write methods. No need to carefully URL-encode your JSON attachments and present all other fields as URL encoded key/value pairs; just send JSON instead.

Now you can send messages lovingly authored with the message builder to chat.postMessage without further modification.

Learn more about this support in the Web API docs or this changelog.


Messages are formatted as described in the formatting spec. You can specify values for parse and link_names to change formatting behavior.

When POSTing with application/x-www-form-urlencoded data, the optional attachments argument should contain a JSON-encoded array of attachments. Make it easy on yourself and send your entire messages as application/json instead.

For more information, see the attachments spec. If you're using a Slack app, you can also use this method to attach message buttons.

By default links to media are unfurled, but links to text content are not. For more information on the differences and how to control this, see the the unfurling documentation.

Use the Message Builder to preview your message formatting and attachments in real time! It's easy to translate your JSON examples to the parameters understood by chat.postMessage.

For best results, limit the number of characters in the text field to a few thousand bytes at most. Ideally, messages should be short and human-readable, if you need to post longer messages, please consider uploading a snippet instead. (A single message should be no larger than 4,000 bytes.)

Consider reviewing our message guidelines, especially if you're using attachments or message buttons.


How message authorship is attributed varies by a few factors, with some behaviors varying depending on the kinds of tokens you're using to post a message.

The best way to realize your intended result is to be explicit with the as_user parameter.

chat.postMessage wants your message posting to succeed and may attempt to guess the most appropriate as_user interpretation based on the kind of token you're using.

If as_user is not provided at all, then the value is inferred, based on the scopes granted to the caller: If the caller could post with as_user passed as false, then that is how the method behaves; otherwise, the method behaves as if as_user were passed as true.

When as_user is false

When the as_user parameter is set to false, messages are posted as "bot_messages", with message authorship attributed to the default user name and icons associated with the Custom Integration or Slack App.

With as_user set to false, you may also provide a username to explicitly specify the bot user's identity for this message, along with icon_url or icon_emoji.

Effect on identity

Token types provide varying default identity values for username, icon_url, and icon_emoji.

Note: In the Slack App cases above, it would certainly make more sense for your application's name to be the default username associated with your app. This inconsistent behavior will be corrected. Of course, you can still name your bot "bot," if that is your bot's name.

When as_user is true

Set as_user to true and the authenticated user will appear as the author of the message, ignoring any values provided for username, icon_url, and icon_emoji. Posting as the authenticated user requires the client or the more preferred chat:write:user scopes.

Effect on identity

Token types provide varying default identity values for username, icon_url, and icon_emoji.

Threads and replies

Provide a thread_ts value for the posted message to act as a reply to a parent message. Sparingly set reply_broadcast to true if your reply is important enough for everyone in the channel to receive.

See message threading for a more in depth look at message threading.


You must specify a public channel, private channel, or an IM channel with the channel argument. Each one behaves slightly differently based on the authenticated user's permissions and additional arguments:

Post to a public channel

You can either pass the channel's name (#general) or encoded ID (C024BE91L), and the message will be posted to that channel. The channel's ID can be retrieved through the channels.list API method.

Post to a private group

As long as the authenticated user is a member of the private group, you can either pass the group's name (secret-group) or encoded ID (G012AC86C), and the message will be posted to that group. The private group's ID can be retrieved through the groups.list API method.

Post to an IM channel

Posting to an IM channel is a little more complex depending on the value of as_user.

  • If as_user is false:
    • Pass the IM channel's ID (D023BB3L2) as the value of channel to post to that IM channel as the bot. The IM channel's ID can be retrieved through the im.list API method.
  • If as_user is true:
    • Pass the IM channel's ID (D023BB3L2) as the value of channel to post to that IM channel as the authenticated user. The IM channel's ID can be retrieved through the im.list API method.

To send a direct message to the user owning the token used in the request, provide the channel field with the a conversation/IM ID value found in a method like im.list.

We are phasing out support for ambiguously passing a "username" as a channel value. Please always use channel-like IDs instead.


Typical success response

    "ok": true,
    "channel": "C1H9RESGL",
    "ts": "1503435956.000247",
    "message": {
        "text": "Here's a message for you",
        "username": "ecto1",
        "bot_id": "B19LU7CSY",
        "attachments": [
                "text": "This is an attachment",
                "id": 1,
                "fallback": "This is an attachment's fallback"
        "type": "message",
        "subtype": "bot_message",
        "ts": "1503435956.000247"

Typical error response if too many attachments are included

    "ok": false,
    "error": "too_many_attachments"

The response includes the "timestamp ID" (ts) and the channel-like thing where the message was posted. It also includes the complete message object, as parsed by our servers. This may differ from the provided arguments as our servers sanitize links, attachments, and other properties. Your message may mutate.


This table lists the expected errors that this method could return. However, other errors can be returned in the case where the service is down or other unexpected factors affect processing. Callers should always check the value of the ok params in the response.

Error Description

Value passed for channel was invalid.


Cannot post user messages to a channel they are not in.


Channel has been archived.


Message text is too long


No message text provided


Too many attachments were provided with this message. A maximum of 100 attachments are allowed on a message.


Application has posted too many messages, read the Rate Limit documentation for more information


No authentication token provided.


Some aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.


Authentication token is for a deleted user or workspace.


The workspace token used in this request does not have the permissions necessary to complete the request.


The method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.


The method was passed a PHP-style array argument (e.g. with a name like foo[7]). These are never valid with the Slack API.


The method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.


The method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.


The method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/x-www-form-urlencoded multipart/form-data text/plain.


The method was called via a POST request and included a data payload, but the request did not include a Content-Type header.


The workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.


The method was called via a POST request, but the POST data was either missing or truncated.


The server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.


This table lists the expected warnings that this method will return. However, other warnings can be returned in the case where the service is experiencing unexpected trouble.

Warning Description

The method was called via a POST request, and recommended practice for the specified Content-Type is to include a charset parameter. However, no charset was present. Specifically, non-form-data content types (e.g. text/plain) are the ones for which charset is recommended.


The method was called via a POST request, and the specified Content-Type is not defined to understand the charset parameter. However, charset was in fact present. Specifically, form-data content types (e.g. multipart/form-data) are the ones for which charset is superfluous.

Argument Value
token Required Generate tokens to test with here.
channel Required
text Required
as_user Optional
attachments Optional
icon_emoji Optional
icon_url Optional
link_names Optional
mrkdwn Optional, default=true
parse Optional
reply_broadcast Optional
thread_ts Optional
unfurl_links Optional
unfurl_media Optional
username Optional
Extra args