- Documentation
Torch Object Storage
User Guide
Working with buckets
Basic configurations
Managing lifecycle
Expiring objects via APIs
Managing lifecycle
Expiring objects via APIs
Expiring objects via APIs
You can use APIs to instruct TOS to delete objects when they reach the end of their lifecycle. This topic explains how to set, modify, and view the expiration times for objects.
Set expiration times
Modify expiration times
View expiration times
Adding an expiration time when uploading an object
You can use the parameter x-tos-object-expires to set an object's expiration time. This parameter accepts a positive integer indicating the number of days after which the object will expire. The count begins at the object's last modified time, and the deletion task begins at midnight after the expiration time is reached. For instance, if the parameter x-tos-object-expires is set to 3 and the object's last modified time is 2024-09-26 12:00, the object will expire at 2024-09-30 00:00. The following APIs support this parameter:
- Adding an expiration time when uploading an object
- Adding an expiration time when appending an object
- Adding an expiration time when copying an object
Adding an expiration time to an existing object
You can use the parameter ObjectExpires in the SetObjectExpires API to set an expiration time for an object that has already been uploaded. This parameter accepts a positive integer or 0 and is expressed in days with the following semantics:
- Positive integer: The object will expire after the specified number of days. The count begins at the object's last modified time, and the deletion task begins at midnight after the expiration time is reached. For instance, if the parameter ObjectExpires is set to 3 and the object's last modified time is 2024-09-26 12:00, the object will expire at 2024-09-30 00:00.
- 0: The object will remain in the bucket indefinitely, unless it is manually deleted or removed via a lifecycle rule.
You can use the parameter ObjectExpires in the SetObjectExpires API to modify an object's expiration time. This parameter accepts a positive integer or 0 and is expressed in days with the following semantics:
- Positive integer: The object will expire after the specified number of days. The count begins at the object's last modified time, and the deletion task begins at midnight after the expiration time is reached. For instance, if the parameter ObjectExpires is set to 3 and the object's last modified time is 2024-09-26 12:00, the object will expire at 2024-09-30 00:00.
- 0: The object will remain in the bucket indefinitely, unless it is manually deleted or removed via a lifecycle rule.
- To check when an object will expire, you can use the parameter X-Tos-Expiration in GetObject and HeadObject operations. For more information, see GetObject and HeadObject.
- To view the expiration time of an object in the console:
- In the left navigation pane, click Buckets. In the Buckets list, click the bucket you want to manage.
- On the Objects page, click Details in the Actions column of the object you want to check. The expiration time is displayed under Basic information.
tip
- The expiration time is only displayed when a lifecycle rule is configured with an automatic deletion policy in the Policy configuration section.
- If there are multiple lifecycle rules and the first rule does not include an automatic deletion policy, but subsequent rules do, the expiration time will not be displayed.
Last updated: 2026.07.27 10:24:42