# Cancel a Task

To stop a task that is in progress, use the `cancelTask()` method to stop all processing of the task. DT does not provide any notifications on task cancellations.

{% code title="Kotlin" %}

```kotlin
fun cancelTask(
taskId: String,
metadata: Bundle = Bundle()
)
```

{% endcode %}

| PARAMETER  | STATUS   | TYPE   | DESCRIPTION                                                                                                                                                       |
| ---------- | -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `taskId`   | Required | String | Unique ID for the task you want to cancel. DT assigns a task ID to every task. Obtain the task ID from either a callback or broadcast about the task in progress. |
| `metadata` | Optional | Bundle | Additional metadata to pass to Ignite.                                                                                                                            |

## Example <a href="#h_01k2j950mprmtvc5mcrpz20tt6" id="h_01k2j950mprmtvc5mcrpz20tt6"></a>

{% code title="Kotlin" %}

```kotlin
// Initialization

// Specify task id received previously in broadcast or callbacks onScheduled() method

IgniteServiceSdk.instance().cancelTask(taskId)
// ...
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalturbine.com/dt-ignite/ignite-services/sdk-reference/cancel-a-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
