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/...}`.

Query parameters

scope_idstringRequired

Session / container identifier.

prefixstringRequired

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).

namespacestringOptionalDefaults to session
Namespace to delete from. Defaults to 'session'.

Response

Successful Response
prefixstring
The key prefix that was deleted.
deleted_countinteger
Number of files actually removed.
type"prefix_deleted"OptionalDefaults to prefix_deleted

Object type discriminator, always ‘prefix_deleted’.

Errors

400
Bad Request Error
401
Unauthorized Error
422
Unprocessable Entity Error
503
Service Unavailable Error