s3.bucket-objects.delete-prefix

Delete everything under a folder; with prefix "" and allVersions, empty the bucket

POST /s3/api/buckets/{name}/objects/delete-prefixIAM s3:DeleteObjectChanges stateDestructive

allVersions: true needs s3:DeleteObjectVersion and deletes every version and delete marker for good. Each call works ~20 seconds and answers { deleted, failed, errors, done, cursor }; while done is false, call again with cursor. A key your policies keep is reported in errors and stays.

Request syntax

POST /s3/api/buckets/{name}/objects/delete-prefix
{
  "prefix": "string",
  "allVersions": "boolean",
  "cursor": "object"
}

Path parameters

  • nameRequired

    string

    Constraints: 3-63 chars, /^[a-z0-9][a-z0-9-]*[a-z0-9]$/

Request body

  • prefixRequired

    string

    A folder ending in /; "" is the whole bucket

    Constraints: max 1024 chars

  • allVersionsRequired

    boolean

    true: every version and delete marker, for good (Empty bucket). false: the current objects, as Delete does (a versioned bucket keeps them as old versions)

  • cursorOptional

    object

    From the previous answer, when it said done: false

    Constraints: JSON

Response

200; data is { deleted, failed, errors: [{ key, versionId?, message }], done, cursor }: what this call deleted and refused; while done is false, pass cursor back.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow s3:DeleteObject on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud s3 bucket-objects delete-prefix name --prefix example --all-versions

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_s3_bucket-objects_delete-prefix.