# 請求失敗怎麼辦

請求失敗時，先看回應的 `error.code`，再對照下表處理。回報問題時，請附上回應 header 的 `X-Request-Id`。

<details>

<summary>401 unauthorized</summary>

* 確認有帶 `X-API-Key` header，且值正確無多餘空白。
* 確認該 key 未被撤銷。
* 為避免洩漏 key 是否存在，查無此 key 與已撤銷都回同樣的 401。

</details>

<details>

<summary>403 forbidden</summary>

key 有效但被停用（例如欠費）。請聯絡管理員恢復或加值。

</details>

<details>

<summary>402 insufficient_credit</summary>

credit 餘額不足。請管理員加值後重試。注意：加值前重試只會再次失敗。

</details>

<details>

<summary>429 rate_limited</summary>

觸發限流。請依回應的 `Retry-After`（秒）等待後再試，並在客戶端採用指數退避，避免立即重打。

</details>

<details>

<summary>400 bad_request</summary>

請求參數或格式有誤。常見原因：`limit` 超過 1000、JSON 格式錯誤、缺少必填欄位、`target_url` 未以 `http(s)://` 開頭。修正後重送。

</details>

<details>

<summary>404 not_found</summary>

資源不存在。檢查路徑與 ID；注意 webhook 只能操作該 key 自己的訂閱。

</details>

<details>

<summary>502 / 503</summary>

後端暫時異常或服務過載。請稍後以退避策略重試。若持續發生，附 `X-Request-Id` 聯絡支援。

</details>

<details>

<summary>500 internal_error</summary>

非預期的內部錯誤。請附上 `X-Request-Id` 聯絡你的客戶經理協助定位。

</details>

{% hint style="success" %}
記得：任何錯誤回應都**不會**扣 credit。
{% 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.blockchainsecurity.asia/help-center/zheng-he-yu-yi-nan-pai-jie/troubleshooting-failed-requests.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.
