DELETE /accounts/{account_id}/r2/buckets/{bucket_name}/objects
Deletes objects from an R2 bucket. Three modes are supported:
- Delete by list (default): Provide a JSON array of object keys in the request body. All listed objects are deleted; per-key errors are reported in the response.
- Delete by prefix: Provide a non-empty
prefixquery parameter and no request body to delete every object whose key begins with that prefix. - Empty bucket: Provide the
prefixquery parameter with an empty value (?prefix=) and no request body to delete all objects in the bucket.
Prefix and empty-bucket requests return a job descriptor. Small jobs can finish
synchronously and return COMPLETED; larger jobs continue in the background. Poll the
returned id with the Get Bucket Job endpoint. Objects uploaded after a background job
starts are not deleted by that job. Abort active multipart uploads before submitting the
request; a synchronously completed job does not abort them. Avoid writing objects or
starting multipart uploads while a bucket-emptying job is in progress.
Each repeated or concurrent request creates a distinct job. The number of active jobs is limited per bucket; wait for an existing job to finish before retrying a request rejected with HTTP 429.
A bucket cannot be emptied while event notifications are configured. Remove the event
notification rules and retry requests rejected with HTTP 409 / error code 10034. To
protect a bucket with R2 Data Catalog enabled, send the cf-r2-data-catalog-check header;
a conflict is returned with HTTP 409 / error code 10081.
For most workloads, we recommend using R2's S3-compatible API or a Worker with an R2 binding instead.
Servers
- https://api.cloudflare.com/client/v4
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
bucket_name |
String | Yes | |
account_id |
String | Yes |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
cf-r2-data-catalog-check |
String | No |
Set this header to reject the operation when R2 Data Catalog is enabled for the bucket. |
cf-r2-jurisdiction |
String | No |
Valid values:
Default value: "default" |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
prefix |
String | No |
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
[] |
Array | Yes |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.