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

# Status and polling

> How to tell whether the result is ready, processing is still running, or it has failed.

The API sends no completion notifications, so you need to poll for the result. The source of truth is the response of [`GET /api/spaces/{space_id}/audio/{audio_id}/result/`](/en/api-reference/processing/result).

## States

| `result/` response | Fields in `info/` | Meaning | What to do |
| - | - | - | - |
| `404`, `{"detail": "Not found."}` | `was_classified: false` | Processing was not started | Call [`classify`](/en/processing/start) |
| `200`, `classified: false` | `was_classified: false` | Processing is running | Wait and keep polling |
| `200`, `classified: true`, `success: true` | `result_is_ready: true` | Done | Fetch the [result](/en/processing/result) |
| `200`, `classified: true`, `success: false`, or `500` as an HTML page for more than 3 minutes | `was_classified: true`, `result_is_ready: false` | Processing failed | See below |

<Note>
  A `500` error comes as an HTML page, not JSON. Check the status code before parsing the body.
</Note>

## How long to wait

A short recording is processed in 1–4 minutes. Long recordings and the queue at peak hours add time. Poll every 10–15 seconds and set an overall timeout of at least an hour.

## If processing fails

A failed processing run shows up in one of two ways: `200` with `classified: true` and `success: false`, or `500` as an HTML page. If `500` persists for more than 3 minutes in a row, treat processing as failed. The minutes come back on their own.

`was_classified` in [`info/`](/en/api-reference/audio/info) becomes `true` once processing has finished, successfully or not. While it runs, the value is `false`.

Common causes:

* `title` has no file extension or the wrong one, see [Formats](/en/upload/formats);
* the file has no duration, see [Duration in the file](/en/upload/formats);
* the file is corrupted or has no sound.

Fix the file or the title and upload the recording again.

## Ready-to-use code

```python Python theme={null}
import time

import requests

API = "https://api.aigenda.tech"


def wait_for_result(token: str, space_id: int, audio_id: int, timeout: int = 3600) -> dict:
    """Waits for the processing result. Returns the result/ response body or raises an exception."""
    headers = {"Authorization": f"Bearer {token}"}
    url = f"{API}/api/spaces/{space_id}/audio/{audio_id}/result/"
    started = time.monotonic()
    not_found_since = None
    failing_since = None

    while time.monotonic() - started < timeout:
        r = requests.get(url, headers=headers, timeout=30)
        now = time.monotonic()

        if r.status_code == 200:
            not_found_since = failing_since = None
            body = r.json()
            if body.get("classified"):
                if body.get("success"):
                    return body
                raise RuntimeError("Processing failed, the minutes will be returned automatically")
        elif r.status_code == 404:
            # right after classify the status may not update instantly
            not_found_since = not_found_since or now
            if now - not_found_since > 60:
                raise RuntimeError("Processing not started: call classify")
        elif r.status_code >= 500:
            failing_since = failing_since or now
            if now - failing_since > 180:
                raise RuntimeError("Processing failed, the minutes will be returned automatically")

        time.sleep(15)

    raise TimeoutError("The result was not ready within the allotted time")
```


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