> ## Documentation Index
> Fetch the complete documentation index at: https://meilisearch-6b28dec2-mintlify-code-samples.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tasks

> The /tasks route allows you to manage and monitor Meilisearch's asynchronous operations.

export const NoticeTag = ({label}) => <span className="noticeTag noticeTag--{ label }">
    {label}
  </span>;

export const RouteHighlighter = ({method, path}) => <div className={`routeHighlighter routeHighlighter--${method}`}>
    <div className="routeHighlighter__method">
      {method}
    </div>
    <div className="routeHighlighter__path">
      {path}
    </div>
  </div>;

The `/tasks` route gives information about the progress of [asynchronous operations](/learn/async/asynchronous_operations).

## Task object

```json theme={null}
{
  "uid": 4,
  "batchUids": 0,
  "indexUid": "movie",
  "status": "failed",
  "type": "indexDeletion",
  "canceledBy": null,
  "details": {
    "deletedDocuments": 0
  },
  "error": {
    "message": "Index `movie` not found.",
    "code": "index_not_found",
    "type": "invalid_request",
    "link": "https://docs.meilisearch.com/errors#index_not_found"
  },
  "duration": "PT0.001192S",
  "enqueuedAt": "2022-08-04T12:28:15.159167Z",
  "startedAt": "2022-08-04T12:28:15.161996Z",
  "finishedAt": "2022-08-04T12:28:15.163188Z"
}
```

### `uid`

**Type**: Integer<br />
**Description**: Unique sequential identifier of the task.

<Note>
  The task `uid` is incremented across all indexes in an instance.
</Note>

### `batchUid`

**Type**: Integer<br />
**Description**: Unique sequential identifier of the batch this task belongs to.

<Note>
  The batch `uid` is incremented across all indexes in an instance.
</Note>

### `indexUid`

**Type**: String<br />
**Description**:  Unique identifier of the targeted index

<Note>
  This value is always `null` for [global tasks](/learn/async/asynchronous_operations#global-tasks).
</Note>

### `status`

**Type**: String<br />
**Description**: Status of the task. Possible values are `enqueued`, `processing`, `succeeded`, `failed`, and `canceled`

### `type`

**Type**: String<br />
**Description**: Type of operation performed by the task. Possible values are `indexCreation`, `indexUpdate`, `indexDeletion`, `indexSwap`, `documentAdditionOrUpdate`, `documentDeletion`, `settingsUpdate`, `dumpCreation`, `taskCancelation`, `taskDeletion`, `upgradeDatabase`, `documentEdition`, and `snapshotCreation`

### `canceledBy`

**Type**: Integer<br />
**Description**: If the task was canceled, `canceledBy` contains the `uid` of a `taskCancelation` task. If the task was not canceled, `canceledBy` is always `null`

### `details`

**Type**: Object<br />
**Description**: Detailed information on the task payload. This object's contents depend on the task's `type`

#### `documentAdditionOrUpdate`

| Name                    | Description                                                                             |
| :---------------------- | :-------------------------------------------------------------------------------------- |
| **`receivedDocuments`** | Number of documents received                                                            |
| **`indexedDocuments`**  | Number of documents indexed. `null` while the task status is `enqueued` or `processing` |

#### `documentDeletion`

| Name                   | Description                                                                             |
| :--------------------- | :-------------------------------------------------------------------------------------- |
| **`providedIds`**      | Number of documents queued for deletion                                                 |
| **`originalFilter`**   | The filter used to delete documents. `null` if it was not specified                     |
| **`deletedDocuments`** | Number of documents deleted. `null` while the task status is `enqueued` or `processing` |

#### `indexCreation`

| Name             | Description                                                                                    |
| :--------------- | :--------------------------------------------------------------------------------------------- |
| **`primaryKey`** | Value of the `primaryKey` field supplied during index creation. `null` if it was not specified |

#### `indexUpdate`

| Name             | Description                                                                                  |
| :--------------- | :------------------------------------------------------------------------------------------- |
| **`primaryKey`** | Value of the `primaryKey` field supplied during index update. `null` if it was not specified |

#### `indexDeletion`

| Name                   | Description                                                                                                                                                   |
| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`deletedDocuments`** | Number of deleted documents. This should equal the total number of documents in the deleted index. `null` while the task status is `enqueued` or `processing` |

#### `indexSwap`

| Name        | Description                                            |
| :---------- | :----------------------------------------------------- |
| **`swaps`** | Object containing the payload for the `indexSwap` task |

#### `settingsUpdate`

| Name                       | Description                   |
| :------------------------- | :---------------------------- |
| **`rankingRules`**         | List of ranking rules         |
| **`filterableAttributes`** | List of filterable attributes |
| **`distinctAttribute`**    | The distinct attribute        |
| **`searchableAttributes`** | List of searchable attributes |
| **`displayedAttributes`**  | List of displayed attributes  |
| **`sortableAttributes`**   | List of sortable attributes   |
| **`stopWords`**            | List of stop words            |
| **`synonyms`**             | List of synonyms              |
| **`typoTolerance`**        | The `typoTolerance` object    |
| **`pagination`**           | The `pagination` object       |
| **`faceting`**             | The `faceting` object         |

#### `dumpCreation`

| Name          | Description                                                                                                                                                         |
| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`dumpUid`** | The generated `uid` of the dump. This is also the name of the generated dump file. `null` when the task status is `enqueued`, `processing`, `canceled`, or `failed` |

#### `taskCancelation`

| Name                 | Description                                                                                                                                                           |
| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`matchedTasks`**   | The number of matched tasks. If the API key used for the request doesn’t have access to an index, tasks relating to that index will not be included in `matchedTasks` |
| **`canceledTasks`**  | The number of tasks successfully canceled. If the task cancellation fails, this will be `0`. `null` when the task status is `enqueued` or `processing`                |
| **`originalFilter`** | The filter used in the [cancel task](#cancel-tasks) request                                                                                                           |

<Note>
  Task cancellation can be successful and still have `canceledTasks: 0`. This happens when `matchedTasks` matches finished tasks (`succeeded`, `failed`, or `canceled`).
</Note>

#### `taskDeletion`

| Name                 | Description                                                                                                                                                           |
| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`matchedTasks`**   | The number of matched tasks. If the API key used for the request doesn’t have access to an index, tasks relating to that index will not be included in `matchedTasks` |
| **`deletedTasks`**   | The number of tasks successfully deleted. If the task deletion fails, this will be `0`. `null` when the task status is `enqueued` or `processing`                     |
| **`originalFilter`** | The filter used in the [delete task](#delete-tasks) request                                                                                                           |

<Note>
  Task deletion can be successful and still have `deletedTasks: 0`. This happens when `matchedTasks` matches `enqueued` or `processing` tasks.
</Note>

#### `snapshotCreation`

The `details` object is set to `null` for `snapshotCreation` tasks.

### `error`

**Type**: Object<br />
**Description**: If the task has the `failed` [status](#status), then this object contains the error definition. Otherwise, set to `null`

| Name          | Description                                         |
| :------------ | :-------------------------------------------------- |
| **`message`** | A human-readable description of the error           |
| **`code`**    | The [error code](/reference/errors/error_codes)     |
| **`type`**    | The [error type](/reference/errors/overview#errors) |
| **`link`**    | A link to the relevant section of the documentation |

### `network` <NoticeTag type="experimental" label="experimental" />

**Type**: Object<br />
**Description**: If the task was replicated from another remote or to other remotes, `network` will contain information about the remote task uids corresponding to this task. Otherwise, missing in task object.

`network` either has a single key that is either `origin` or `remotes`.

| Name          | Description                                                      |
| :------------ | :--------------------------------------------------------------- |
| **`origin`**  | The task and remote from which this task was replicated **from** |
| **`remotes`** | This task was replicated **to** these tasks and remotes          |

`origin` is itself an object with keys:

| Name             | Description                                      |
| :--------------- | :----------------------------------------------- |
| **`remoteName`** | The name of the [remote](/reference/api/network) |
| **`taskUid`**    | The uid of the task of origin                    |

`remotes` is itself an object whose keys are the [remotes](/reference/api/network) and values an object with a single key that is either `task_uid` or `error`:

| Name           | Description                                                                                   |
| :------------- | :-------------------------------------------------------------------------------------------- |
| **`task_uid`** | The uid of the replicated task                                                                |
| **`error`**    | A human-readable error message indicating why the task could not be replicated to that remote |

<Note>
  This is an experimental feature. Use the Meilisearch Cloud UI or the experimental features endpoint to activate it:

  ```sh theme={null}
  curl \
    -X PATCH 'MEILISEARCH_URL/experimental-features/' \
    -H 'Content-Type: application/json' \
    --data-binary '{
      "network": true
    }'
  ```
</Note>

### `duration`

**Type**: String<br />
**Description**: The total elapsed time the task spent in the `processing` state, in [ISO 8601](https://www.ionos.com/digitalguide/websites/web-development/iso-8601/) format

### `enqueuedAt`

**Type**: String<br />
**Description**: The date and time when the task was first `enqueued`, in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format

### `startedAt`

**Type**: String<br />
**Description**: The date and time when the task began `processing`, in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format

### `finishedAt`

**Type**: String<br />
**Description**: The date and time when the task finished `processing`, whether `failed`, `succeeded`, or `canceled`, in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format

### `customMetadata`

**Type**: String<br />
**Description**: An arbitrary string optionally configured for tasks adding, updating, and deleting documents. Commonly used to keep track of which documents were processed in a specific task.

### Summarized task object

When an API request triggers an asynchronous process, Meilisearch returns a summarized task object. This object contains the following fields:

| Field            | Type    | Description                                                                                                                   |
| :--------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------- |
| **`taskUid`**    | Integer | Unique sequential identifier                                                                                                  |
| **`indexUid`**   | String  | Unique index identifier (always `null` for [global tasks](/learn/async/asynchronous_operations#global-tasks))                 |
| **`status`**     | String  | Status of the task. Value is `enqueued`                                                                                       |
| **`type`**       | String  | Type of task                                                                                                                  |
| **`enqueuedAt`** | String  | Represents the date and time in the [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format when the task has been `enqueued` |

You can use this `taskUid` to get more details on [the status of the task](#get-one-task).

## Get tasks

<RouteHighlighter method="GET" path="/tasks" />

List all tasks globally, regardless of index. The `task` objects are contained in the `results` array.

Tasks are always returned in descending order of `uid`. This means that by default, **the most recently created `task` objects appear first**.

Task results are [paginated](/learn/async/paginating_tasks) and can be [filtered](/learn/async/filtering_tasks).

### Query parameters

| Query Parameter        | Default Value                  | Description                                                                                                                             |
| :--------------------- | :----------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- |
| **`uids`**             | `*` (all uids)                 | [Filter tasks](/learn/async/filtering_tasks) by their `uid`. Separate multiple task `uids` with a comma (`,`)                           |
| **`batchUids`**        | `*` (all batch uids)           | [Filter tasks](/learn/async/filtering_tasks) by their `batchUid`. Separate multiple `batchUids` with a comma (`,`)                      |
| **`statuses`**         | `*` (all statuses)             | [Filter tasks](/learn/async/filtering_tasks) by their `status`. Separate multiple task `statuses` with a comma (`,`)                    |
| **`types`**            | `*` (all types)                | [Filter tasks](/learn/async/filtering_tasks) by their `type`. Separate multiple task `types` with a comma (`,`)                         |
| **`indexUids`**        | `*` (all indexes)              | [Filter tasks](/learn/async/filtering_tasks) by their `indexUid`. Separate multiple task `indexUids` with a comma (`,`). Case-sensitive |
| **`limit`**            | `20`                           | Number of tasks to return                                                                                                               |
| **`from`**             | `uid` of the last created task | `uid` of the first task returned                                                                                                        |
| **`reverse`**          | `false`                        | If `true`, returns results in the reverse order, from oldest to most recent                                                             |
| **`canceledBy`**       | N/A                            | [Filter tasks](/learn/async/filtering_tasks) by their `canceledBy` field. Separate multiple task `uids` with a comma (`,`)              |
| **`beforeEnqueuedAt`** | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `enqueuedAt` field                                                                |
| **`beforeStartedAt`**  | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `startedAt` field                                                                 |
| **`beforeFinishedAt`** | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `finishedAt` field                                                                |
| **`afterEnqueuedAt`**  | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `enqueuedAt` field                                                                |
| **`afterStartedAt`**   | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `startedAt` field                                                                 |
| **`afterFinishedAt`**  | `*` (all tasks)                | [Filter tasks](/learn/async/filtering_tasks) by their `finishedAt` field                                                                |

### Response

| Name          | Type    | Description                                                                                                                    |
| :------------ | :------ | :----------------------------------------------------------------------------------------------------------------------------- |
| **`results`** | Array   | An array of [task objects](#task-object)                                                                                       |
| **`total`**   | Integer | Total number of tasks matching the filter or query                                                                             |
| **`limit`**   | Integer | Number of tasks returned                                                                                                       |
| **`from`**    | Integer | `uid` of the first task returned                                                                                               |
| **`next`**    | Integer | Value passed to `from` to view the next "page" of results. When the value of `next` is `null`, there are no more tasks to view |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X GET 'MEILISEARCH_URL/tasks'
  ```

  ```javascript JS theme={null}
  client.tasks.getTasks()
  ```

  ```python Python theme={null}
  client.get_tasks()
  ```

  ```php PHP theme={null}
  $client->getTasks();
  ```

  ```java Java theme={null}
  client.getTasks();
  ```

  ```ruby Ruby theme={null}
  client.tasks
  ```

  ```go Go theme={null}
  client.GetTasks(nil);
  ```

  ```csharp C# theme={null}
  ResourceResults<Task> taskResult = await client.GetTasksAsync();

  ```

  ```rust Rust theme={null}
  let tasks: TasksResults = client
    .get_tasks()
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  client.getTasks { (result) in
      switch result {
      case .success(let tasks):
          print(tasks)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.getTasks();
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "results": [
    {
      "uid": 1,
      "indexUid": "movies_reviews",
      "status": "failed",
      "type": "documentAdditionOrUpdate",
      "canceledBy": null,
      "details": {
        "receivedDocuments": 100,
        "indexedDocuments": 0
      },
      "error": null,
      "duration": null,
      "enqueuedAt": "2021-08-12T10:00:00.000000Z",
      "startedAt": null,
      "finishedAt": null
    },
    {
      "uid": 0,
      "indexUid": "movies",
      "status": "succeeded",
      "type": "documentAdditionOrUpdate",
      "canceledBy": null,
      "details": {
        "receivedDocuments": 100,
        "indexedDocuments": 100
      },
      "error": null,
      "duration": "PT16S",
      "enqueuedAt": "2021-08-11T09:25:53.000000Z",
      "startedAt": "2021-08-11T10:03:00.000000Z",
      "finishedAt": "2021-08-11T10:03:16.000000Z"
    }
  ],
  "total": 50,
  "limit": 20,
  "from": 1,
  "next": null
}
```

## Get one task

<RouteHighlighter method="GET" path="/tasks/{task_uid}" />

Get a single task.

<Note>
  If you try retrieving a deleted task, Meilisearch will return a [`task_not_found`](/reference/errors/error_codes#task_not_found) error.
</Note>

### Path parameters

| Name              | Type   | Description                         |
| :---------------- | :----- | :---------------------------------- |
| **`task_uid`** \* | String | [`uid`](#uid) of the requested task |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X GET 'MEILISEARCH_URL/tasks/1'
  ```

  ```javascript JS theme={null}
  client.tasks.getTask(1)
  ```

  ```python Python theme={null}
  client.get_task(1)
  ```

  ```php PHP theme={null}
  $client->getTask(1);
  ```

  ```java Java theme={null}
  client.getTask(1);
  ```

  ```ruby Ruby theme={null}
  client.task(1)
  ```

  ```go Go theme={null}
  client.GetTask(1);
  ```

  ```csharp C# theme={null}
  TaskInfo task = await client.GetTaskAsync(1);

  ```

  ```rust Rust theme={null}
  let task: Task = client
    .get_task(1)
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  client.getTask(taskUid: 1) { (result) in
        switch result {
        case .success(let task):
            print(task)
        case .failure(let error):
            print(error)
        }
    }
  ```

  ```dart Dart theme={null}
  await client.getTask(1);
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "uid": 1,
  "indexUid": "movies",
  "status": "succeeded",
  "type": "settingsUpdate",
  "canceledBy": null,
  "details": {
    "rankingRules": [
      "typo",
      "ranking:desc",
      "words",
      "proximity",
      "attribute",
      "exactness"
    ]
  },
  "error": null,
  "duration": "PT1S",
  "enqueuedAt": "2021-08-10T14:29:17.000000Z",
  "startedAt": "2021-08-10T14:29:18.000000Z",
  "finishedAt": "2021-08-10T14:29:19.000000Z"
}
```

## Cancel tasks

<RouteHighlighter method="POST" path="/tasks/cancel?{query_parameter}" />

Cancel any number of `enqueued` or `processing` tasks based on their `uid`, `status`, `type`, `indexUid`, or the date at which they were enqueued (`enqueuedAt`) or processed (`startedAt`).

Task cancellation is an atomic transaction: **either all tasks are successfully canceled or none are**.

<Warning>
  To prevent users from accidentally canceling all enqueued and processing tasks, Meilisearch throws the [`missing_task_filters`](/reference/errors/error_codes#missing_task_filters) error if this route is used without any filters (`POST /tasks/cancel`).
</Warning>

<Tip>
  You can also cancel `taskCancelation` type tasks as long as they are in the `enqueued` or `processing` state. This is possible because `taskCancelation` type tasks are processed in reverse order, such that the last one you enqueue will be processed first.
</Tip>

### Query parameters

A valid `uids`, `statuses`, `types`, `indexUids`, or date(`beforeXAt` or `afterXAt`) parameter is required.

| Query Parameter        | Description                                                                                                                          |
| :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
| **`uids`**             | Cancel tasks based on `uid`. Separate multiple `uids` with a comma (`,`). Use `uids=*` for all `uids`                                |
| **`statuses`**         | Cancel tasks based on `status`. Separate multiple `statuses` with a comma (`,`). Use `statuses=*` for all `statuses`                 |
| **`types`**            | Cancel tasks based on `type`. Separate multiple `types` with a comma (`,`). Use `types=*` for all `types`                            |
| **`indexUids`**        | Cancel tasks based on `indexUid`. Separate multiple `uids` with a comma (`,`). Use `indexUids=*` for all `indexUids`. Case-sensitive |
| **`beforeEnqueuedAt`** | Cancel tasks **before** a specified `enqueuedAt` date. Use `beforeEnqueuedAt=*` to cancel all tasks                                  |
| **`beforeStartedAt`**  | Cancel tasks **before** a specified `startedAt` date. Use `beforeStartedAt=*` to cancel all tasks                                    |
| **`afterEnqueuedAt`**  | Cancel tasks **after** a specified `enqueuedAt` date. Use `afterEnqueuedAt=*` to cancel all tasks                                    |
| **`afterStartedAt`**   | Cancel tasks **after** a specified `startedAt` date. Use `afterStartedAt=*` to cancel all tasks                                      |

<Note>
  Date filters are equivalent to `<` or `>` operations. At this time, there is no way to perform a `≤` or `≥` operations with a date filter.
</Note>

[To learn more about filtering tasks, refer to our dedicated guide.](/learn/async/filtering_tasks)

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X POST 'MEILISEARCH_URL/tasks/cancel?uids=1,2'
  ```

  ```javascript JS theme={null}
  client.tasks.cancelTasks({ uids: [1, 2] })
  ```

  ```python Python theme={null}
  client.cancel_tasks({'uids': ['1', '2']})
  ```

  ```php PHP theme={null}
  $client->cancelTasks((new CancelTasksQuery())->setUids([1, 2]));
  ```

  ```java Java theme={null}
  CancelTasksQuery query = new CancelTasksQuery().setUids(new int[] {1, 2})
  client.cancelTasks(query);
  ```

  ```ruby Ruby theme={null}
  client.cancel_tasks(uids: [1, 2])
  ```

  ```go Go theme={null}
  client.CancelTasks(&meilisearch.CancelTasksQuery{
    UIDS: []int64{1, 2},
  });
  ```

  ```csharp C# theme={null}
  await client.CancelTasksAsync(new CancelTasksQuery { Uids = new List<int> { 1, 2 } });
  ```

  ```rust Rust theme={null}
  let mut query = tasks::TasksCancelQuery::new(&client);
  query.with_uids([1, 2]);

  let res = client.cancel_task_with(&query).await.unwrap();
  ```

  ```swift Swift theme={null}
  client.cancelTasks(filter: CancelTasksQuery(uids: [1, 2])) { (result) in
      switch result {
      case .success(let taskInfo):
          print(taskInfo)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.cancelTasks(params: CancelTasksQuery(uids: [1, 2]));
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "taskUid": 3,
  "indexUid": null,
  "status": "enqueued",
  "type": "taskCancelation",
  "enqueuedAt": "2021-08-12T10:00:00.000000Z"
}
```

<Note>
  Since `taskCancelation` is a [global task](/learn/async/asynchronous_operations#global-tasks), its `indexUid` is always `null`.
</Note>

You can use this `taskUid` to get more details on the [status of the task](#get-one-task).

### Cancel all tasks

You can cancel all `processing` and `enqueued` tasks using the following filter:

<RouteHighlighter method="POST" path="/tasks/cancel?statuses=processing,enqueued" />

The API key used must have access to all indexes (`"indexes": [*]`) and the [`task.cancel`](/reference/api/keys#actions) action.

## Delete tasks

<RouteHighlighter method="DELETE" path="/tasks?{query_parameter}" />

Delete a finished (`succeeded`, `failed`, or `canceled`) task based on `uid`, `status`, `type`, `indexUid`, `canceledBy`, or date. Task deletion is an atomic transaction: **either all tasks are successfully deleted, or none are**.

<Warning>
  To prevent users from accidentally deleting the entire task history, Meilisearch throws the [`missing_task_filters`](/reference/errors/error_codes#missing_task_filters) error if this route is used without any filters (DELETE `/tasks`).
</Warning>

### Query parameters

A valid `uids`, `statuses`, `types`, `indexUids`, `canceledBy`, or date(`beforeXAt` or `afterXAt`) parameter is required.

| Query Parameter        | Description                                                                                                                          |
| :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
| **`uids`**             | Delete tasks based on `uid`. Separate multiple `uids` with a comma (`,`). Use `uids=*` for all `uids`                                |
| **`statuses`**         | Delete tasks based on `status`. Separate multiple `statuses` with a comma (`,`). Use `statuses=*` for all `statuses`                 |
| **`types`**            | Delete tasks based on `type`. Separate multiple `types` with a comma (`,`). Use `types=*` for all `types`                            |
| **`indexUids`**        | Delete tasks based on `indexUid`. Separate multiple `uids` with a comma (`,`). Use `indexUids=*` for all `indexUids`. Case-sensitive |
| **`canceledBy`**       | Delete tasks based on the `canceledBy` field                                                                                         |
| **`beforeEnqueuedAt`** | Delete tasks **before** a specified `enqueuedAt` date. Use `beforeEnqueuedAt=*` to delete all tasks                                  |
| **`beforeStartedAt`**  | Delete tasks **before** a specified `startedAt` date. Use `beforeStartedAt=*` to delete all tasks                                    |
| **`beforeFinishedAt`** | Delete tasks **before** a specified `finishedAt` date. Use `beforeFinishedAt=*` to delete all tasks                                  |
| **`afterEnqueuedAt`**  | Delete tasks **after** a specified `enqueuedAt` date. Use `afterEnqueuedAt=*` to delete all tasks                                    |
| **`afterStartedAt`**   | Delete tasks **after** a specified `startedAt` date. Use `afterStartedAt=*` to delete all tasks                                      |
| **`afterFinishedAt`**  | Delete tasks **after** a specified `finishedAt` date. Use `afterFinishedAt=*` to delete all tasks                                    |

<Note>
  Date filters are equivalent to `<` or `>` operations. At this time, there is no way to perform a `≤` or `≥` operations with a date filter.
</Note>

[To learn more about filtering tasks, refer to our dedicated guide.](/learn/async/filtering_tasks)

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X DELETE 'MEILISEARCH_URL/tasks?uids=1,2'
  ```

  ```javascript JS theme={null}
  client.tasks.deleteTasks({ uids: [1, 2] })
  ```

  ```python Python theme={null}
  client.delete_tasks({'uids': ['1', '2']})
  ```

  ```php PHP theme={null}
  $client->deleteTasks((new DeleteTasksQuery())->setUids([1, 2]));
  ```

  ```java Java theme={null}
  DeleteTasksQuery query = new DeleteTasksQuery().setUids(new int[] {1, 2})
  client.deleteTasks(query);
  ```

  ```ruby Ruby theme={null}
  client.delete_tasks(uids: [1, 2])
  ```

  ```go Go theme={null}
  client.DeleteTaks(&meilisearch.DeleteTasksQuery{
    UIDS: []int64{1, 2},
  });
  ```

  ```csharp C# theme={null}
  await client.DeleteTasksAsync(new DeleteTasksQuery { Uids = new List<int> { 1, 2 } });
  ```

  ```rust Rust theme={null}
  let mut query = tasks::TasksDeleteQuery::new(&client);
  query.with_uids([1, 2]);

  let res = client.delete_tasks_with(&query).await.unwrap();
  ```

  ```swift Swift theme={null}
  client.deleteTasks(filter: DeleteTasksQuery(uids: [1, 2])) { (result) in
      switch result {
      case .success(let taskInfo):
          print(taskInfo)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.deleteTasks(params: DeleteTasksQuery(uids: [1, 2]));
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "taskUid": 3,
  "indexUid": null,
  "status": "enqueued",
  "type": "taskDeletion",
  "enqueuedAt": "2021-08-12T10:00:00.000000Z"
}
```

<Note>
  Since `taskDeletion` is a [global task](/learn/async/asynchronous_operations#global-tasks), its `indexUid` is always `null`.
</Note>

You can use this `taskUid` to get more details on the [status of the task](#get-one-task).

### Delete all tasks

You can delete all finished tasks by using the following filter:

<RouteHighlighter method="DELETE" path="/tasks?statuses=failed,canceled,succeeded" />

The API key used must have access to all indexes (`"indexes": [*]`) and the [`task.delete`](/reference/api/keys#actions) action.
