> For the complete documentation index, see [llms.txt](https://docs.blockchainsecurity.asia/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockchainsecurity.asia/help-center/guan-li/managing-api-keys.md).

# 管理 API key

API key 讓你的應用程式以程式化方式存取 BCS API。管理員可在管理後台隨時建立、檢視、撤銷 key 與調整 credit。

## 建立 key

在後台建立 key 時，指定**名稱**、**方案**與**初始 credit**。建立後系統會回傳一次性的明碼 key。

{% hint style="warning" %}
明碼 key（`ak_live_…`）**只會出現這一次**，請當場交付給使用者並妥善保存。系統只保存雜湊值，遺失只能撤銷後重建。
{% endhint %}

請給每把 key 一個能辨識用途的名稱（例如「行動 App」「對帳排程」），方便日後稽核。

## 撤銷 key

在後台找到該 key 按撤銷。撤銷**立即生效**——之後使用該 key 的請求一律回 `401`。

## 調整 credit

可為任一 key 增減 credit（`delta` 可正可負）。加值後使用者即可繼續呼叫。

## key 的狀態

| 狀態        | 意義      | 請求結果               |
| --------- | ------- | ------------------ |
| active    | 正常      | 通過認證               |
| suspended | 暫停（如欠費） | `403 forbidden`    |
| revoked   | 已撤銷     | `401 unauthorized` |

## 最佳實務

* **一整合一把 key** — 方便個別撤銷與用量追蹤。
* **最小權限** — 只發放必要的 credit 與方案額度。
* **定期盤點** — 撤銷不再使用的 key。
* **安全保管** — 提醒使用者把 key 放在伺服器端密鑰管理，勿入版本控制或前端。

詳細的 API 操作見[開發者文件的管理後台章節](https://api.blockchainsecurity.asia/docs)。
