Skip to main content

chat.scheduleMessage method

Facts

DescriptionSchedules a message to be sent to a channel.
Method Access
POST https://slack.com/api/chat.scheduleMessage
Scopes
Bot token:
User token:
Content types
application/x-www-form-urlencoded
application/json

Arguments

Required arguments

tokenstringRequired

Authentication token bearing required scopes. Tokens should be passed as an HTTP Authorization header or alternatively, as a POST parameter.

Example: xxxx-xxxxxxxxx-xxxx
channelstringRequired

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

post_atintegerRequired

Unix timestamp representing the future time the message should post to Slack.

Example: 299876400

Optional arguments

as_userbooleanOptional

Set to true to post the message as the authed user, instead of as a bot. Defaults to false. Cannot be used by new Slack apps. See chat.postMessage.

Example: true
attachmentsstringOptional

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

Example: [{"pretext": "pre-hello", "text": "text-world"}]
blocksstringOptional

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

Example: [{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]
link_namesbooleanOptional

Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead.

Example: true
markdown_textstringOptional

Accepts message text formatted in markdown. This argument should not be used in conjunction with blocks or text. Limit this field to 12,000 characters.

Example: **This is bold text**
parsestringOptional

Change how messages are treated. See chat.postMessage.

Acceptable values: none full
Example: full
reply_broadcastbooleanOptional

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

Example: true
textstringOptional

How this field works and whether it is required depends on other fields you use in your API call. See below for more detail.

Example: Hello world
thread_tsstringOptional

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

unfurl_linksbooleanOptional

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

Example: true
unfurl_mediabooleanOptional

Pass false to disable unfurling of media content.

Example: false
metadataOptional

JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.

Example: {"event_type": "task_created", "event_payload": { "id": "11223", "title": "Redesign Homepage"}}

Usage info

Bug alert

Messages scheduled with chat.scheduleMessage will not post if the metadata parameter is used.

This method schedules a message for delivery to a public channel, private channel, or direct message (DM) conversation at a specified time in the future. Messages scheduled through this method can be seen by calling the chat.scheduledMessages.list API method.

The text, blocks and attachments fields

The usage of the text field changes depending on whether you're using blocks. If you're using blocks, this is used as a fallback string to display in notifications. If you aren't, this is the main body text of the message. It can be formatted as plain text, or with mrkdwn.

Restrictions

You will only be able to schedule a message up to 120 days into the future. If you specify a post_at timestamp beyond this limit, you’ll receive a time_too_far error response. Additionally, you cannot schedule more than 30 messages to post within a 5-minute window to the same channel. Exceeding this will result in a restricted_too_many error.


Response

Typical success response

{
"ok": true,
"channel": "C123ABC456",
"scheduled_message_id": "Q1298393284",
"post_at": "1562180400",
"message": {
"text": "Here's a message for you in the future",
"username": "ecto1",
"bot_id": "B123ABC456",
"attachments": [
{
"text": "This is an attachment",
"id": 1,
"fallback": "This is an attachment's fallback"
}
],
"type": "delayed_message",
"subtype": "bot_message"
}
}

Typical error response if the post_at is invalid (ex. in the past or too far into the future)

{
"ok": false,
"error": "time_in_past"
}

The response includes the scheduled_message_id assigned to your message. Use it with the chat.deleteScheduledMessage API method to delete the message before it is sent.

For details on formatting, usage in threads, and rate limiting, refer to the chat.postMessage API method documentation.

Channels

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

Post to a channel

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

Post to a DM

Pass the DM conversation's channel ID (D123ABC456) or a user's ID (U123ABC456) as the value of channel to post to that DM conversation.

The DM conversation's channel ID can be retrieved by calling the conversations.list API method. Use the types parameters to return only im conversations. You may receive a channel_not_found error if your app doesn't have permission to enter into an direct message with the intended user.

Errors

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 parameter in the response.

Error
Description
access_denied

Access to a resource specified in the request is denied.

accesslimited

Access to this method is limited on the current network

account_inactive

Authentication token is for a deleted user or workspace when using a bot token.

channel_not_found

Value passed for channel was invalid.

deprecated_endpoint

The endpoint has been deprecated.

ekm_access_denied

Administrators have suspended the ability to post a message.

enterprise_is_restricted

The method cannot be called from an Enterprise.

fatal_error

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.

internal_error

The server could not complete your operation(s) without encountering an error, likely due to a transient issue on our end. It's possible some aspect of the operation succeeded before the error was raised.

invalid_arg_name

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.

invalid_arguments

The method was called with invalid arguments.

invalid_array_arg

The method was passed an array as an argument. Please only input valid strings.

invalid_auth

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.

invalid_blocks

Blocks submitted with this message are not valid

invalid_blocks_format

The blocks is not a valid JSON object or doesn't match the Block Kit syntax.

invalid_charset

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.

invalid_form_data

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.

invalid_metadata_format

Invalid metadata format provided

invalid_metadata_schema

Invalid metadata schema provided

invalid_post_type

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

invalid_time

value passed for post_time was invalid.

invalid_token

The passed token is invalid or not supported by this method.

is_archived

Channel has been archived.

markdown_text_conflict

Markdown text cannot be used in conjunction with blocks or text argument.

message_limit_exceeded

Members on this team are sending too many messages. For more details, see https://slack.com/help/articles/115002422943-Usage-limits-for-free-workspaces

metadata_must_be_sent_from_app

Message metadata can only be posted or updated using an app-level token

metadata_too_large

Metadata exceeds size limit

method_deprecated

The method has been deprecated.