Upstash Documentation

Bulk Cancel Messages

Delete all pending messages
1 min read
delete/v2/messages
Request example
Response
delete/v2/messages
Note
Cancelling a message will remove it from QStash and stop it from being delivered in the future. If a message is in flight to your API, it might be too late to cancel.
Warning

If you provide a set of message IDs in the request, only those messages will be cancelled.

If you include filter parameters in the request, only the messages that match the filters will be canceled.

If no filter or messageIds are sent, QStash will cancel all of your messages. We highly recommend at least providing count parameter and cancel in batches.

This operation scans all your messages and attempts to cancel them. If an individual message cannot be cancelled, it will not continue and will return an error message. Therefore, some messages may not be cancelled at the end. In such cases, you can run the bulk cancel operation multiple times.

Info

For multi-value filters, a message matches if its value equals any of the given values (OR logic), and multiple filters are combined with AND logic.

Multiple values can be passed either by repeating the query parameter (label=label_1&label=label_2) or as a single comma-separated value (label=label_1,label_2).

Authorization

Authorizationstringheaderrequired#
QStash authentication token

1 alternative authorization method available — see the spec for details.

Query parameters

messageIdsstring[]#
A list of message IDs to delete. If provided, other filters are ignored.
topicNamestring[]#
Filter messages by URL Group name. Supports multiple values.
queueNamestring[]#
Filter messages by Queue name. Supports multiple values.
urlstring[]#
Filter messages by destination URL. Supports multiple values.
hoststring[]#
Filter messages by the host of the destination URL. Supports multiple values.
pathstring[]#
Filter messages by the path of the destination URL. Supports multiple values.
labelstring[]#

Filter messages by label. Supports multiple values. You can pass multiple values to match messages with any of the given labels (OR logic).

Examples:

  • label=my_label
  • label=label_1&label=label_2
  • label=label_1,label_2
flowControlKeystring[]#
Filter messages by Flow Control Key. Supports multiple values.
fromDateinteger#
Filter messages created after this timestamp (Unix milli, inclusive).
toDateinteger#
Filter messages created before this timestamp (Unix milli, inclusive).
scheduleIdstring[]#
Filter messages by Schedule ID. Supports multiple values.
callerIpstring[]#
Filter messages by the IP address of the publisher. Supports multiple values.
callerIPstring[]deprecated#
Deprecated. Use callerIp instead.
countinteger#
Maximum number of messages to delete, between 1 and 500. If not provided, all messages matching the filters will be deleted.

Range: 1–500

Responses

application/json
200
All messages deleted successfully
cancelledinteger#
Number of messages cancelled