TokenLab

Tệp và lô

Truy xuất Lô tin nhắn (Retrieve Message Batch)

Truy xuất trạng thái và số lượng yêu cầu của một Lô tin nhắn (Message Batch).

GET
/v1/messages/batches/{message_batch_id}

Tổng quan

Trả về trạng thái, số lượng yêu cầu và dấu thời gian của một Lô tin nhắn mà tổ chức của bạn đã tạo. Hãy thực hiện polling (thăm dò) endpoint này cho đến khi processing_status là ended, sau đó lấy kết quả.

Lưu ý

  • processing_status có thể là in_progress, canceling hoặc ended.
  • results_url sẽ là null cho đến khi lô tin nhắn kết thúc.
  • Một lô tin nhắn không tồn tại hoặc đã bị xóa sẽ trả về mã 404. Một lô tin nhắn chưa sẵn sàng để đọc có thể trả về mã 409; hãy thử lại sau.

Ví dụ

Yêu cầu

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

Ví dụ phản hồi

Phản hồi

200 OK
{
  "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"
}

Các trường quan trọng

processing_statusstring
in_progress, canceling hoặc ended.
request_countsobject
Số lượng các yêu cầu đang processing, succeeded, errored, canceled hoặc expired.
ended_atstring|null
Thời điểm quá trình xử lý kết thúc, hoặc null.
cancel_initiated_atstring|null
Thời điểm yêu cầu hủy được chấp nhận, hoặc null.
results_urlstring|null
URL của kết quả, hoặc null.

Xác thực

BearerAuth
AuthorizationBearer <token>

Xác thực bằng Khóa API. Tạo hoặc quản lý khóa API trong Dashboard > API > API Keys.

Vị trí: header

Tham số đường dẫn

message_batch_id*string

Định danh batch tin nhắn

Phản hồi

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json