---
type: api
title: Get the pending cluster tasks
description: Get information about cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet taken effect.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-cluster-pending-tasks
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-cluster-pending-tasks
products:
  - Elasticsearch
---

# Get the pending cluster tasks

## Paths

- `GET` `/_cluster/pending_tasks`

## Description

Get information about cluster-level changes (such as create index, update mapping, allocate or fail shard) that have not yet taken effect.

NOTE: This API returns a list of any pending updates to the cluster state.
These are distinct from the tasks reported by the task management API which include periodic tasks and tasks initiated by the user, such as node stats, search queries, or create index requests.
However, if a user-initiated task such as a create index command causes a cluster state update, the activity of this task might be reported by both task api and pending cluster tasks API.

## 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

- `local` (boolean · default: false) — optional
  If `true`, the request retrieves information from the local node only.
If `false`, information is retrieved from the master node.
- `master_timeout` (string · default: 30s) — optional
  Period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.

## Response

`application/json`

- `tasks` (object[])
  - `executing` (boolean)
    Indicates whether the pending tasks are currently executing or not.
  - `insert_order` (number)
    The number that represents when the task has been inserted into the task queue.
  - `priority` (string)
    The priority of the pending task.
The valid priorities in descending priority order are: `IMMEDIATE` > `URGENT` > `HIGH` > `NORMAL` > `LOW` > `LANGUID`.
  - `source` (string)
    A general description of the cluster task that may include a reason and origin.
  - `time_in_queue` (string)
    The time since the task is waiting for being performed.
  - `time_in_queue_millis` (number)
    The time expressed in milliseconds since the task is waiting for being performed.
## Code examples

#### Console

```console
GET /_cluster/pending_tasks
```

#### JavaScript

```javascript
const response = await client.cluster.pendingTasks();
```

#### Python

```python
resp = client.cluster.pending_tasks()
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_cluster/pending_tasks" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.cluster().pendingTasks(p -> p);
```

#### C#

```c#
var response = await client.Cluster.PendingTasksAsync();
```

#### PHP

```php
$resp = $client->cluster()->pendingTasks();
```

#### Ruby

```ruby
response = client.cluster.pending_tasks
```

