---
title: "Cancel an API task"
slug: "cancel-an-api-task"
abstract: "How to cancel an onging task with the xConnect purge Web API."
---
# Cancel an API task

You can use the [xConnect Web API](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-platform/web-api-for-xconnect-data-tools.html "Web API for xConnect Data Tools") to cancel a [purge](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-platform/xconnect-purging-tool.html "xConnect purging tool") task.

To cancel the task:

- Use the following PUT request and substitute the `{{TaskId}}` parameter with the ID of the ongoing registered task:

    ```text
    <instance>/sitecore/api/datatools/tasks/{{TaskId}}/cancel
    ```

    > [!note]
    > The task cancellation is not an immediate process because the task completes the in-progress batch of contacts before the cancellation takes effect, and the task still processes the related data. If you, for example, cancel a purge task, any items that were deleted before you cancelled the task remain deleted.