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

# 輪詢

> 讀取工作直到結束的節奏。

工作是非同步的：`POST /jobs` 在接受工作後就立即回應。持續讀取 `GET /jobs/{id}`，直到 `status` 為 `completed`、`failed` 或 `canceled`。

## 建議做法

1. 提交後，先等待 `202` 回應的 `Retry-After` 秒數。
2. 讀取工作。
3. 若還不是終態，依 body 的 `next_poll_after_seconds` 等待後再讀。

`next_poll_after_seconds` 由 Blon 依工作設定：排隊中 5 秒，處理中 3 秒（影片 10 秒）。讀得更頻繁不會讓工作更快完成。

```bash theme={null}
until
  job=$(curl -s https://api.blon.ai/v1/jobs/$JOB_ID -H "Authorization: Bearer $BLON_API_KEY")
  status=$(echo "$job" | jq -r .status)
  [ "$status" = completed ] || [ "$status" = failed ] || [ "$status" = canceled ]
do
  sleep "$(echo "$job" | jq -r '.next_poll_after_seconds // 5')"
done
```

## 速率限制

`429` 回應（`rate_limited`、`queue_full` 或 `concurrency_limit`）帶 `Retry-After` header，請等待該秒數後再重試。重試 `POST /jobs` 時請沿用同一個 `Idempotency-Key`。

## 改用 Webhooks

不想輪詢時，提交時帶 `webhook_url`，工作結束時 Blon 會呼叫一次，見 [Webhooks](https://docs.blon.ai/zh-TW/how-to/webhooks.md)。由於沒有重新投遞，仍建議保留讀取工作作為備援。


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