# Task Cancel API - How to id the task I want to cancel

**URL:** <https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062>\
**Category:** Elasticsearch\
**Created:** [May 7, 2019, 8:58pm UTC](https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062 "2019-05-07T20:58:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeboy](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@codeboy](https://discuss.elastic.co/u/codeboy)\
**Post date:** [May 7, 2019, 8:58pm UTC](https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062/1 "2019-05-07T20:58:31Z")

</div>

I am looking into the tasks api. I have found the listing api using curl /\_tasks?detailed=true&actions=\*search&pretty" and I can successfully cancel one or all.

I would like to implement a [Cancel] button in my application for users who are bored waiting for a long query. How can I tag a query with a unique ID so I know which task to cancel when the user presses that cancel button.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [May 8, 2019, 7:28am UTC](https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062/2 "2019-05-08T07:28:42Z")

</div>

This sounds like a job for the [`X-Opaque-Id` header](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/tasks.html#_identifying_running_tasks).

---

<div class="post-metadata">

**Author:** ![codeboy](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@codeboy](https://discuss.elastic.co/u/codeboy)\
**Post date:** [May 9, 2019, 3:42pm UTC](https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062/3 "2019-05-09T15:42:45Z")

</div>

Yes, thanks. Now I need to upgrade to get this feature.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 6, 2019, 3:42pm UTC](https://discuss.elastic.co/t/task-cancel-api-how-to-id-the-task-i-want-to-cancel/180062/4 "2019-06-06T15:42:47Z")

</div>

Closed on June 6, 2019, 3:42pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
