TokenLab

檔案與批次

列出訊息批次 (List Message Batches)

列出貴組織所建立的訊息批次。

GET
/v1/messages/batches

概覽

回傳貴組織透過此 API 建立的訊息批次,按時間由新到舊排序。此列表顯示 TokenLab 最後記錄的每個批次狀態。若要立即檢查特定批次,請檢索該批次。

注意事項

  • limit 的範圍為 1 到 1000,預設值為 20。
  • 若要進行分頁,請傳入 after_id(較舊的批次)或 before_id(較新的批次),並搭配列表中的批次 ID。請勿同時傳送兩者。若 ID 未知或包含任何其他查詢參數,TokenLab 將回傳 400 錯誤。
  • 已刪除的批次不會列出。
  • 當後續還有更多批次時,has_more 為 true。

範例

請求

cURL
curl -X GET "https://api.tokenlab.sh/v1/messages/batches?limit=20" \
  -H "x-api-key: sk-your-api-key" \
  -H "anthropic-version: 2023-06-01"

回應範例

回應

200 OK
{
  "data": [
    {
      "id": "msgbatch_01ABC123",
      "type": "message_batch",
      "processing_status": "ended",
      "request_counts": { "processing": 0, "succeeded": 2, "errored": 0, "canceled": 0, "expired": 0 },
      "ended_at": "2026-11-01T10:20:00Z",
      "created_at": "2026-11-01T10:00:00Z",
      "expires_at": "2026-11-02T10:00:00Z",
      "cancel_initiated_at": null,
      "archived_at": null,
      "results_url": "https://api.tokenlab.sh/v1/messages/batches/msgbatch_01ABC123/results"
    }
  ],
  "first_id": "msgbatch_01ABC123",
  "last_id": "msgbatch_01ABC123",
  "has_more": false
}

重要欄位

dataarray
訊息批次,按時間由新到舊排序。
first_idstring|null
data 中第一個批次的 ID。
last_idstring|null
data 中最後一個批次的 ID。
has_moreboolean
當 has_more 為 true 時,表示還有更多批次可供讀取。

授權

BearerAuth
AuthorizationBearer <token>

API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。

位置: header

查詢參數

before_id?string

回傳此批次 ID 之前的批次。不可與 after_id 結合使用。

after_id?string

回傳此批次 ID 之後的批次。不可與 before_id 結合使用。

limit?integer

要傳回的批次最大數量

範圍1 <= value <= 1000
預設值20

回應

application/json

application/json

application/json

application/json

application/json

application/json

application/json