Skip to main content
The /tasks route gives information about the progress of asynchronous operations.

Task object

uid

Type: Integer
Description: Unique sequential identifier of the task.
The task uid is incremented across all indexes in an instance.

batchUid

Type: Integer
Description: Unique sequential identifier of the batch this task belongs to.
The batch uid is incremented across all indexes in an instance.

indexUid

Type: String
Description: Unique identifier of the targeted index
This value is always null for global tasks.

status

Type: String
Description: Status of the task. Possible values are enqueued, processing, succeeded, failed, and canceled

type

Type: String
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
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
Description: Detailed information on the task payload. This object’s contents depend on the task’s type

documentAdditionOrUpdate

documentDeletion

indexCreation

indexUpdate

indexDeletion

indexSwap

settingsUpdate

dumpCreation

taskCancelation

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

taskDeletion

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

snapshotCreation

The details object is set to null for snapshotCreation tasks.

error

Type: Object
Description: If the task has the failed status, then this object contains the error definition. Otherwise, set to null

network experimental

Type: Object
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. origin is itself an object with keys: remotes is itself an object whose keys are the remotes and values an object with a single key that is either task_uid or error:
This is an experimental feature. Use the Meilisearch Cloud UI or the experimental features endpoint to activate it:

duration

Type: String
Description: The total elapsed time the task spent in the processing state, in ISO 8601 format

enqueuedAt

Type: String
Description: The date and time when the task was first enqueued, in RFC 3339 format

startedAt

Type: String
Description: The date and time when the task began processing, in RFC 3339 format

finishedAt

Type: String
Description: The date and time when the task finished processing, whether failed, succeeded, or canceled, in RFC 3339 format

customMetadata

Type: String
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: You can use this taskUid to get more details on the status of the task.

Get tasks

GET
/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 and can be filtered.

Query parameters

Response

Example

Response: 200 Ok

Get one task

GET
/tasks/{task_uid}
Get a single task.
If you try retrieving a deleted task, Meilisearch will return a task_not_found error.

Path parameters

Example

Response: 200 Ok

Cancel tasks

POST
/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.
To prevent users from accidentally canceling all enqueued and processing tasks, Meilisearch throws the missing_task_filters error if this route is used without any filters (POST /tasks/cancel).
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.

Query parameters

A valid uids, statuses, types, indexUids, or date(beforeXAt or afterXAt) parameter is required.
Date filters are equivalent to < or > operations. At this time, there is no way to perform a or operations with a date filter.
To learn more about filtering tasks, refer to our dedicated guide.

Example

Response: 200 Ok

Since taskCancelation is a global task, its indexUid is always null.
You can use this taskUid to get more details on the status of the task.

Cancel all tasks

You can cancel all processing and enqueued tasks using the following filter:
POST
/tasks/cancel?statuses=processing,enqueued
The API key used must have access to all indexes ("indexes": [*]) and the task.cancel action.

Delete tasks

DELETE
/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.
To prevent users from accidentally deleting the entire task history, Meilisearch throws the missing_task_filters error if this route is used without any filters (DELETE /tasks).

Query parameters

A valid uids, statuses, types, indexUids, canceledBy, or date(beforeXAt or afterXAt) parameter is required.
Date filters are equivalent to < or > operations. At this time, there is no way to perform a or operations with a date filter.
To learn more about filtering tasks, refer to our dedicated guide.

Example

Response: 200 Ok

Since taskDeletion is a global task, its indexUid is always null.
You can use this taskUid to get more details on the status of the task.

Delete all tasks

You can delete all finished tasks by using the following filter:
DELETE
/tasks?statuses=failed,canceled,succeeded
The API key used must have access to all indexes ("indexes": [*]) and the task.delete action.