> ## 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](/api-reference/tasks/create), poll [Get Task by ID](/api-reference/tasks/get) until each target's `status` is `completed` or `error`. Add a delay between requests to avoid hitting [rate limits](/api-reference/rate-limits).

<Tip>For production, use [webhooks](/api-reference/tasks/webhooks) instead of polling — you'll receive a request each time a target completes.</Tip>

## Poll and download results

<CodeGroup>
  ```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);
    }
  }
  ```
</CodeGroup>

<Info>Output download links expire after one hour. Re-fetch the Task to get fresh links, or download and store files in your own storage.</Info>
