Canceling a workflow allows you to stop the sending of messages within a specified workflow for one or more recipients. This can be useful in settings like reminders where a notification needs to be canceled once a user has performed the intended action.
It's important to understand that only workflows that include a delay function or a batch function can be canceled within Knock, as without the built-in delay of a function Knock will immediately send a notification to your recipients.
To perform a cancellation, you first need to give Knock a pointer to understand how to uniquely
identify the triggered workflow by providing a
cancellation_key on the
You can read about generating workflow cancellation keys and some best practices in the triggering workflows guide.
|key*||string||The human readable key of the workflow from the Knock dashboard|
|cancellation_key||string||A unique identifier for the workflow run|
|recipients||RecipientIdentifier||A list of specific recipient identifiers to cancel the workflow for (optional)|
In some cases you may need to cancel a workflow for a subset of recipients only. You can do this by specifying the recipients list on the cancellation:
There are a few things to watch out for when using cancellations:
A cancellation cannot be performed on a specific channel step, it can only be performed against the entire workflow.
You cannot cancel a given workflow run after it has finished ; if you need to revoke messages for persistent channels like the in-app feed, then you can
archivea message instead.
You can learn more about using cancellation with batch and delay functions in our workflow functions guide.