---
type: api
title: Get all tasks
description: Get information about the tasks currently running on one or more nodes in the cluster.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-tasks-list
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-tasks-list
products:
  - Elasticsearch
---

# Get all tasks

Availability: Preview since 2.3

## Paths

- `GET` `/_tasks`

## Description

Get information about the tasks currently running on one or more nodes in the cluster.

WARNING: The task management API is new and should still be considered a beta feature.
The API may change in ways that are not backwards compatible.

**Identifying running tasks**

The `X-Opaque-Id header`, when provided on the HTTP request header, is going to be returned as a header in the response as well as in the headers field for in the task information.
This enables you to track certain calls or associate certain tasks with the client that started them.
For example:

```
curl -i -H "X-Opaque-Id: 123456" "http://localhost:9200/_tasks?group_by=parents"
```

The API returns the following result:

```
HTTP/1.1 200 OK
X-Opaque-Id: 123456
content-type: application/json; charset=UTF-8
content-length: 831

{
  "tasks" : {
    "u5lcZHqcQhu-rUoFaqDphA:45" : {
      "node" : "u5lcZHqcQhu-rUoFaqDphA",
      "id" : 45,
      "type" : "transport",
      "action" : "cluster:monitor/tasks/lists",
      "start_time_in_millis" : 1513823752749,
      "running_time_in_nanos" : 293139,
      "cancellable" : false,
      "headers" : {
        "X-Opaque-Id" : "123456"
      },
      "children" : [
        {
          "node" : "u5lcZHqcQhu-rUoFaqDphA",
          "id" : 46,
          "type" : "direct",
          "action" : "cluster:monitor/tasks/lists[n]",
          "start_time_in_millis" : 1513823752750,
          "running_time_in_nanos" : 92133,
          "cancellable" : false,
          "parent_task_id" : "u5lcZHqcQhu-rUoFaqDphA:45",
          "headers" : {
            "X-Opaque-Id" : "123456"
          }
        }
      ]
    }
  }
 }
```
In this example, `X-Opaque-Id: 123456` is the ID as a part of the response header.
The `X-Opaque-Id` in the task `headers` is the ID for the task that was initiated by the REST request.
The `X-Opaque-Id` in the children `headers` is the child task of the task that was initiated by the REST request.

## Required authorization

- Cluster privileges: `monitor`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `actions` (union string | string[]) — optional
  A comma-separated list or wildcard expression of actions used to limit the request.
For example, you can use `cluser:*` to retrieve all cluster-related tasks.
- `detailed` (boolean · default: false) — optional
  If `true`, the response includes detailed information about the running tasks.
This information is useful to distinguish tasks from each other but is more costly to run.
- `group_by` (enum · default: nodes) — optional
  A key that is used to group tasks in the response.
The task lists can be grouped either by nodes or by parent tasks.

Supported values include:
  - `nodes`: Group tasks by node ID.
  - `parents`: Group tasks by parent task ID.
  - `none`: Do not group tasks.
  Values: `nodes`, `parents`, `none`
- `nodes` (union oneOf) — optional
  A comma-separated list of node IDs or names that is used to limit the returned information.
  One of: `string[]` or `string`
- `parent_task_id` (string) — optional
  A parent task identifier that is used to limit returned information.
To return all tasks, omit this parameter or use a value of `-1`.
If the parent task is not found, the API does not return a 404 response code.
- `timeout` (string · default: 30s) — optional
  The period to wait for each node to respond.
If a node does not respond before its timeout expires, the response does not include its information.
However, timed out nodes are included in the `node_failures` property.
- `wait_for_completion` (boolean · default: false) — optional
  If `true`, the request blocks until the operation is complete.

## Response

`application/json`

- `node_failures` (object[])
  - `type` (string)
    The type of error
  - `reason` (union string) — nullable
    A human-readable explanation of the error, in English.
    One of: `string`
  - `stack_trace` (string)
    The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
  - `caused_by` (object) — recursive
    Same fields as `node_failures`
  - `root_cause` (object[]) — recursive
    Same fields as `node_failures`
  - `suppressed` (object[]) — recursive
    Same fields as `node_failures`
- `task_failures` (object[])
  - `task_id` (number)
  - `node_id` (string)
  - `status` (string)
  - `reason` (object)
    - `type` (string)
      The type of error
    - `reason` (union string) — nullable
      A human-readable explanation of the error, in English.
      One of: `string`
    - `stack_trace` (string)
      The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
    - `caused_by` (object) — recursive
      Same fields as `reason` in `task_failures`
    - `root_cause` (object[]) — recursive
      Same fields as `reason` in `task_failures`
    - `suppressed` (object[]) — recursive
      Same fields as `reason` in `task_failures`
- `nodes` (map string to object)
  Task information grouped by node, if `group_by` was set to `node` (the default).
  Map values (object)
  - `name` (string)
  - `transport_address` (string)
  - `host` (string)
  - `ip` (string)
  - `roles` (string[])
  - `attributes` (map string to string)
  - `tasks` (map string to object)
    Map values (object)
    - `action` (string)
    - `cancelled` (boolean)
    - `cancellable` (boolean)
    - `description` (string)
      Human readable text that identifies the particular request that the task is performing.
For example, it might identify the search request being performed by a search task.
Other kinds of tasks have different descriptions, like `_reindex` which has the source and the destination, or `_bulk` which just has the number of requests and the destination indices.
Many requests will have only an empty description because more detailed information about the request is not easily available or particularly helpful in identifying the request.
    - `headers` (map string to string)
    - `id` (number)
    - `node` (string)
    - `running_time` (string)
    - `running_time_in_nanos` (number)
    - `start_time_in_millis` (number)
    - `status` (object)
      The internal status of the task, which varies from task to task.
The format also varies.
While the goal is to keep the status for a particular task consistent from version to version, this is not always possible because sometimes the implementation changes.
Fields might be removed from the status for a particular request so any parsing you do of the status might break in minor releases.
    - `type` (string)
    - `parent_task_id` (number | string)
- `tasks` (union)
  Either a flat list of tasks if `group_by` was set to `none`, or grouped by parents if
`group_by` was set to `parents`.
## Code examples

#### Console

```console
GET _tasks?actions=*search&detailed
```

#### JavaScript

```javascript
const response = await client.tasks.list({
  actions: "*search",
  detailed: "true",
});
```

#### Python

```python
resp = client.tasks.list(
    actions="*search",
    detailed=True,
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_tasks?actions=*search&detailed" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### C#

```c#
var response = await client.Tasks
    .ListAsync(d1 => d1
        .Actions("*search")
        .Detailed(true)
    );
```

#### PHP

```php
$resp = $client->tasks()->list([
    "actions" => "*search",
    "detailed" => "true",
]);
```

#### Ruby

```ruby
response = client.tasks.list(
  actions: "*search",
  detailed: "true"
)
```

## Response examples

#### List tasks response example1

A successful response from `GET _tasks?actions=*search&detailed` The `detailed` parameter affects the `description` field, which contains human readable text that identifies the particular request that the task is performing. For example, it helps identify the search request being performed by a search task.

```json
{
  "nodes" : {
    "oTUltX4IQMOUUVeiohTt8A" : {
      "name" : "H5dfFeA",
      "transport_address" : "127.0.0.1:9300",
      "host" : "127.0.0.1",
      "ip" : "127.0.0.1:9300",
      "tasks" : {
        "oTUltX4IQMOUUVeiohTt8A:464" : {
          "node" : "oTUltX4IQMOUUVeiohTt8A",
          "id" : 464,
          "type" : "transport",
          "action" : "indices:data/read/search",
          "description" : "indices[test], types[test], search_type[QUERY_THEN_FETCH], source[{\"query\":...}]",
          "start_time_in_millis" : 1483478610008,
          "running_time_in_nanos" : 13991383,
          "cancellable" : true,
          "cancelled" : false
        }
      }
    }
  }
}
```

