How to Configure Lifecycle Rules
Validated on 2 Apr 2026 • Last edited on 13 Apr 2026
Spaces Object Storage is an S3-compatible service for storing and serving large amounts of data. The built-in Spaces CDN minimizes page load times, improves performance, and reduces bandwidth and infrastructure costs.
Lifecycle rules define automatic actions for objects in a Space over time. Use lifecycle rules to delete objects after a set number of days or remove incomplete multipart uploads automatically.
Configure Lifecycle Rules Using the API
To configure lifecycle rules via the DigitalOcean API, send a PUT request to the bucket lifecycle endpoint using the S3-compatible API. Include the lifecycle configuration as XML in the request body. For more details, see Configure a Bucket’s Lifecycle Rules.
Configure Lifecycle Rules via the AWS CLI
To configure lifecycle rules via the AWS CLI, use the put-bucket-lifecycle-configuration command and provide the lifecycle configuration in a file. For command syntax and options, see the AWS CLI put-bucket-lifecycle-configuration reference.
Configure Lifecycle Rules Using s3cmd
You can also configure lifecycle rules using s3cmd. The following examples show how to set an expiration rule and remove incomplete multipart uploads.
Set an Expiration Rule
To delete objects automatically after 30 days, run the following command. Replace <your-space-name> with the name of your Space:
s3cmd expire --expiry-days=30 --expiry-prefix= s3://<your-space-name>This command adds a lifecycle rule that expires all objects in the Space 30 days after they are created.
Remove Incomplete Multipart Uploads
To remove incomplete multipart uploads automatically after one day, run the following command. Replace <your-space-name> with the name of your Space:
s3cmd expire --expiry-mpu-days=1 s3://<your-space-name>This command removes abandoned multipart uploads after one day so they don’t continue to use storage.