Sample - Slack Web API
POST/chat.postEphemeral

Send an ephemeral message

Sends an ephemeral message that is visible only to one user in a channel. Supply channel and user to identify the destination, and provide message content through text, blocks, or attachments. Use thread_ts to display the ephemeral message in an existing active thread.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 12 body fields
tokenstringrequired
Authentication token with the `chat:write` scope.

The destination, recipient, content, threading, and optional authorship settings for the ephemeral message.

as_userbooleanoptional
Pass true to post the message as the authed user. Defaults to true if the chat:write:bot scope is not included. Otherwise, defaults to false.
attachmentsstringoptional
A JSON-based array of structured attachments, presented as a URL-encoded string.
blocksstringoptional
A JSON-based array of structured blocks, presented as a URL-encoded string.
channelstringrequired
Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.
icon_emojistringoptional
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](#authorship) below.
icon_urlstringoptional
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](#authorship) below.
link_namesbooleanoptional
Find and link channel names and usernames.
parsestringoptional
Change how messages are treated. Defaults to `none`. See [below](#formatting).
textstringoptional
How this field works and whether it is required depends on other fields you use in your API call. [See below](#text_usage) for more detail.
thread_tsstringoptional
Provide another message's `ts` value to post this message in a thread. Avoid using a reply's `ts` value; use its parent's value instead. Ephemeral messages in threads are only shown if there is already an active thread.
userstringrequired
`id` of the user who will receive the ephemeral message. The user should be in the channel specified by the `channel` argument.
usernamestringoptional
Set your bot's user name. Must be used in conjunction with `as_user` set to false, otherwise ignored. See [authorship](#authorship) below.

2 status codes
200Returns the ephemeral message timestamp with `ok: true`.
message_tsstringrequired
okbooleanrequired
Allowed:true
defaultReturns `ok: false` with an error when the channel or user is unavailable, the message content is invalid, authentication or permission checks fail, or the message cannot be delivered.
callstackstringoptional
Note: PHP callstack is only visible in dev/qa
errorstringrequired
Allowed:channel_not_foundis_archivedmsg_too_longno_textrestricted_actiontoo_many_attachmentsuser_not_in_channelnot_authedinvalid_authaccount_inactivetoken_revokedno_permission
okbooleanrequired
Allowed:false

Error handling

channel and user are required, and the user should belong to the specified channel. If you set as_user to false while using icon_emoji, icon_url, or username, supply the corresponding bot-authoring configuration.