# requeue\_tasks

`imerit_ango.sdk.SDK.`

## requeue\_tasks(project\_id, to\_stage\_id, filters, options)

Move tasks from one stage to another within your project, with control over which tasks are requeued and how they are processed.

### Parameters

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](/sdk/sdk-documentation.md#project-ids) or retrieve it using the [`list_projects`](/sdk/sdk-documentation/project-level-sdk-functions/list_projects.md) function.
* **to\_stage\_id:** string
  * The identifier of the target stage to which the tasks will be requeued. This stage must exist within the specified project.
* **filters:** dict, *default None*
  * Criteria to select which tasks should be requeued. If no filters are provided, all tasks will be requeued.
    * **taskIds:** List\[str]
      * List of task IDs
    * **externalIds:** List\[str]
      * List of external IDs
    * **assetIds:** List\[str]
      * List of asset IDs
    * **batches:** List\[str]
      * List of batch IDs
    * **fromStageIds:** List\[str]
      * List of stage IDs from which tasks should be requeued
* **options:** dict, *default None*
  * Settings that customize how tasks are requeued. Supported options:
    * **removeAnnotations:** bool
      * Remove existing annotations before requeuing.
    * **removeAssignee:** bool
      * Unassign the current assignee from the task.
    * **removeStageHistory:** bool
      * Clear the task’s stage history.

{% hint style="danger" %}
Setting `removeAnnotations: true` permanently deletes all annotations on the affected tasks. This cannot be undone. Ensure you have exported or backed up annotations before proceeding.
{% endhint %}

Returns:

* **output:** dict
  * A dictionary containing the result of the operation.
  * Including a `status` field indicating whether the request was successful and a `data` field containing the response payload with updated resources produced by the operation.

{% hint style="warning" %}
The target stage (to\_stage\_id) must already exist within the specified project. If needed, update the workflow using the [update\_workflow\_stages](/sdk/sdk-documentation/project-level-sdk-functions/update_workflow_stages.md) function.
{% endhint %}

{% hint style="warning" %}
It is not allowed to requeue tasks into the **Consensus** and **Logic** stages.
{% endhint %}

<details open>

<summary><strong>How to verify in Ango Hub?</strong></summary>

After successfully executing the `requeue_tasks` function, you can validate the changes directly in Ango Hub.

Navigate to: **Projects → \[Your Project] → Tasks**

* Filter the relevant tasks as needed.
* Confirm that the tasks have been forwarded to the correct workflow stages.

{% hint style="info" %}
Changes made via the SDK are reflected in Ango Hub in near real-time. If updates are not immediately visible, please refresh the page.
{% endhint %}

</details>

### Example

Requeue all the tasks to the specified stage from other stages

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

stage_id = '<YOUR STAGE ID>'
sdk_response = ango_sdk.requeue_tasks(project_id=project_id, to_stage_id=stage_id)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID/requeueTasks" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "filters": {},
    "options": {},
    "toStageId": "<YOUR STAGE ID>"
  }'
```

{% endtab %}
{% endtabs %}

Requeue specific tasks only

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

stage_id = '<YOUR STAGE ID>'
external_id_list = ["<EXTERNAL ID 1>", "<EXTERNAL ID 2>", "<EXTERNAL ID 3>"]

sdk_response = ango_sdk.requeue_tasks(
    project_id=project_id,
    to_stage_id=stage_id,
    filters={"externalIds": external_id_list}
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID/requeueTasks" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "filters": {
      "externalIds": ["<EXTERNAL ID 1>", "<EXTERNAL ID 2>", "<EXTERNAL ID 3>"]
    },
    "options": {},
    "toStageId": "<YOUR STAGE ID>"
  }'
```

{% endtab %}
{% endtabs %}

Requeue tasks with configurable preferences

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

stage_id = '<YOUR STAGE ID>'

sdk_response = ango_sdk.requeue_tasks(
    project_id=project_id,
    to_stage_id=stage_id,
    options={
        "removeAnnotations":True, 
        "removeAssignee": True, 
        "removeStageHistory": True
    }
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID/requeueTasks" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "filters": {},
    "options": {
      "removeAnnotations": true,
      "removeAssignee": true,
      "removeStageHistory": true
    },
    "toStageId": "<YOUR STAGE ID>"
  }'
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
See also

[get\_project](/sdk/sdk-documentation/project-level-sdk-functions/get_project.md)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/requeue_tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
