Files

Delete all files matching a prefix (bulk delete)

S3/blob-style bulk delete: remove every uploaded file whose key starts with prefix (e.g. data/2024/ deletes all files in that virtual folder). Only upload-side files are affected; sandbox output files cannot be bulk-deleted. Returns the count of files actually removed. Anthropic SDK callers can reach this via client.beta.files.with_raw_response or a plain httpx call with extra_query={...prefix: data/2024/...}.

delete/v1/files

Query parameters

scope_idstring required

Session / container identifier.

Example:session-abc123

Session / container identifier.

prefixstring required

Key prefix to delete. All uploaded files whose relative path starts with this string are removed. Must be non-empty. A trailing / is recommended to avoid accidentally deleting sibling keys that share the same prefix string (e.g. use data/2024/ not data/2024).

Example:data/2024/

Key prefix to delete. All uploaded files whose relative path starts with this string are removed. Must be non-empty. A trailing / is recommended to avoid accidentally deleting sibling keys that share the same prefix string (e.g. use data/2024/ not data/2024).

namespacestring

Namespace to delete from. Defaults to 'session'.

Example:session

Namespace to delete from. Defaults to 'session'.

Response

Successful Response

prefixstring required

The key prefix that was deleted.

deleted_countinteger required

Number of files actually removed.

type'prefix_deleted'

Object type discriminator, always 'prefix_deleted'.

Example response

{
  "deleted_count": 3,
  "prefix": "data/2024/",
  "type": "prefix_deleted"
}

Changes