Claude Platform Docs

刪除訊息批次

messages.batches.delete(message_batch_id, **kwargs) -> DeletedMessageBatch
DELETE/v1/messages/batches/{message_batch_id}

刪除訊息批次。

訊息批次僅能在處理完成後刪除。若您想刪除進行中的批次,必須先將其取消。

在我們的使用者指南中進一步瞭解 Message Batches API

Parameters
message_batch_id: str⁠Path parameter

ID of the Message Batch.

workspace_id: Optional[str]⁠Header parameter

Optional header to select the Workspace for this request. The value is a Workspace ID (for example, wrkspc_011CZkZaBF1tNoB5wlCeusgy).

Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

Returns
class DeletedMessageBatch: type: "message_batch_deleted"; id
type: Literal["message_batch_deleted"]

Deleted object type.

For Message Batches, this is always "message_batch_deleted".

defaultmessage_batch_deleted
id: str

ID of the Message Batch.

刪除訊息批次
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get(
        "ANTHROPIC_API_KEY"
    ),  # This is the default and can be omitted
)
deleted_message_batch = client.messages.batches.delete(
    message_batch_id="message_batch_id",
)
print(deleted_message_batch.id)
Returns Examples
Response 200
{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "type": "message_batch_deleted"
}