> For the complete documentation index, see [llms.txt](https://www.boxhero.io/docs/llms.txt). Every page is available as Markdown by appending `.md` to its URL; this page is [Markdown](https://www.boxhero.io/docs/zh-tw/developers/api/quickstart.md).

# 快速入門

> 發行 API 權杖，並向 BoxHero API 送出第一個請求。

本指南將帶您從沒有權杖開始，完成第一次成功的 API 呼叫。

## 1. 發行 API 權杖

在桌面版網頁應用程式中，開啟要連接的團隊，前往 `設定` > `整合和 API`。產生新的 API 權杖並複製。

![](https://assets.boxhero.io/docs/images/e6bbc8fa4eab21ec0f9ebe74893cd3a6e0c6a5d4d178ae02478ef99adbe4c4cd-2214x1431.jpg)

> **Caution**
>
> **注意**：權杖會綁定發行它的團隊，並可透過 API 完整存取該團隊的資料。請將權杖保存在您的伺服器上，切勿放入行動應用程式、瀏覽器程式碼或公開儲存庫中。

## 2. 送出第一個請求

呼叫[取得連結的團隊](https://www.boxhero.io/docs/zh-tw/developers/api/reference/teams/get-linked-team)，確認權杖是否有效。在 `Authorization` 標頭中傳送權杖：

```bash
curl https://rest.boxhero-app.com/v1/teams/linked \
  -H "Authorization: Bearer $BOXHERO_API_TOKEN"
```

回應會說明權杖所屬的團隊：

```json
{
  "id": 149058,
  "name": "Acme Retail",
  "mode": 2,
  "currency_symbol": "$",
  "currency_code": "USD",
  "price_decimal_places": 2,
  "memo": null
}
```

如果您收到的是 `401`，表示未傳送權杖或權杖複製不完整。錯誤格式請參閱[錯誤](https://www.boxhero.io/docs/zh-tw/developers/api/errors)。

> **Note**
>
> 大多數端點僅適用於依[位置](https://www.boxhero.io/docs/zh-tw/concepts/locations)管理庫存的團隊。對於其他團隊，這些端點會傳回類型為 `/errors/invalid-team-mode` 的錯誤。位置模式團隊在上述回應中的 `mode` 為 `2`。

## 3. 後續步驟

- 使用[列出品項](https://www.boxhero.io/docs/zh-tw/developers/api/reference/items/list-items)列出庫存，並在[分頁](https://www.boxhero.io/docs/zh-tw/developers/api/pagination)中了解如何取得所有頁面。
- 使用[建立庫存記錄](https://www.boxhero.io/docs/zh-tw/developers/api/reference/transactions/create-transaction)記錄庫存變動，相關規則請參閱[庫存記錄](https://www.boxhero.io/docs/zh-tw/developers/api/reference/transactions)。
- 使用 [Webhook](https://www.boxhero.io/docs/zh-tw/developers/webhooks/overview) 接收變更通知，無需輪詢。
- 在 [API 參考](https://www.boxhero.io/docs/zh-tw/developers/api/reference)中瀏覽所有端點。
