Delete Object
client.r2.buckets.objects.delete(stringbucketName, stringobjectKey, ObjectDeleteParams { account_id, jurisdiction } params, RequestOptionsoptions?): ObjectDeleteResponse { key }
DELETE/accounts/{account_id}/r2/buckets/{bucket_name}/objects/{object_key}
Deletes an object from an R2 bucket.
For most workloads, we recommend using R2’s S3-compatible API or a Worker with an R2 binding instead.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
Accepted Permissions (at least one required)
Delete Object
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const object = await client.r2.buckets.objects.delete('example-bucket', 'path/to/my-object.txt', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
});
console.log(object.key);{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"key": "path/to/my-object.txt"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
"string"
],
"result": {
"key": "path/to/my-object.txt"
},
"success": true
}