> ## Documentation Index
> Fetch the complete documentation index at: https://developer.audioshake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Check Task Status

> Poll a Task until all targets complete and download results

Tasks process asynchronously. After [creating a Task](https://developer.audioshake.ai/api-reference/tasks/create.md), poll [Get Task by ID](https://developer.audioshake.ai/api-reference/tasks/get.md) until each target's `status` is `completed` or `error`. Add a delay between requests to avoid hitting [rate limits](https://developer.audioshake.ai/api-reference/rate-limits.md).

> [!TIP]
>
> For production, use [webhooks](https://developer.audioshake.ai/api-reference/tasks/webhooks.md) instead of polling — you'll receive a request each time a target completes.

## Poll and download results

```python check_task_status.py theme={null}
import requests
import time

API_KEY = "your_api_key"
TASK_ID = "your_task_id"

while True:
    task = requests.get(
        f"https://api.audioshake.ai/tasks/{TASK_ID}",
        headers={"x-api-key": API_KEY}
    ).json()

    statuses = [t["status"] for t in task["targets"]]
    print(f"Statuses: {statuses}")

    if all(s in ("completed", "error") for s in statuses):
        break

    time.sleep(5)

# Download results
for target in task["targets"]:
    if target["status"] == "completed":
        for output in target["output"]:
            print(f"{target['model']}: {output['link']}")
    elif target["status"] == "error":
        print(f"{target['model']}: error - {target['error']}")
```

```javascript checkTaskStatus.js theme={null}
const API_KEY = "your_api_key";
const TASK_ID = "your_task_id";

let task;
while (true) {
  const res = await fetch(`https://api.audioshake.ai/tasks/${TASK_ID}`, {
    headers: { "x-api-key": API_KEY }
  });
  task = await res.json();

  const statuses = task.targets.map(t => t.status);
  console.log("Statuses:", statuses);

  if (statuses.every(s => s === "completed" || s === "error")) break;

  await new Promise(r => setTimeout(r, 5000));
}

// Download results
for (const target of task.targets) {
  if (target.status === "completed") {
    for (const output of target.output) {
      console.log(`${target.model}: ${output.link}`);
    }
  } else if (target.status === "error") {
    console.log(`${target.model}: error -`, target.error);
  }
}
```

> [!NOTE]
>
> Output download links expire after one hour. Re-fetch the Task to get fresh links, or download and store files in your own storage.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.