Adding or extending Object Lock on an object

Object Lock Retention can be applied to an object after it has been uploaded to the system. If an object was uploaded without any applied retention, it can be added with this request. If an object was uploaded with retention applied already (i.e. has an applied “retain-until-date”) then that date can be extended further in the future.

Note: Only bucket owners have permissions to configure object retention on an already uploaded object. Bucket owners can also modify retention on objects owned by other users that were uploaded to their bucket.
Note: The contents of request must be signed by using either a Content-MD5 header or with a x-amz-checksum- header or with V4 signing that includes content signing.

Request syntax


PUT /BucketName/ObjectName?retention HTTP/1.
Content-MD5: <Calculated Content MD5 checksum>

<?xml version="1.0" encoding="UTF-8"?>
<Retention>
    <Mode>string</Mode>
    <RetainUntilDate>string</RetainUntilDate>
</Retention>

Request Payload Elements

Table 1. Request parameters
Name Description
Retention Container for holding Retention Elements.
Mode The Object Lock retention mode that is applied to the object.
Type
String
Valid Values
COMPLIANCE, GOVERNANCE
Ancestor
Retention
RetainUntilDate The Object Lock retention retain until date that is applied to the object.
Type
String
Valid Values
ISO8601 Date-Time Format
Ancestor
Retention
Note: An object’s retain-until-date cannot be set to a date earlier than either the current retain-until-date or the current date-time, except when the object is in GOVERNANCE mode. In GOVERNANCE mode, the retain-until-date can be shortened or removed if the requester has the required BypassGovernanceRetention permission and includes the x-amz-bypass-governance-retention: true header in the request. Only bucket owner has BypassGovernanceRetention permission.

Sample request

Object Lock Object Retention request


PUT /BucketName/ObjectName?retention&versionId=<VersionID> 
HTTP/1.1 Host: myBucket.mydsNet.corp.com
Date: Wed, 8 Feb 2017 17:50:00 GMT
Authorization: authorization string 
Content-Type: text/plain
Content-MD5:<Valid-ContentMD5>

<?xml version="1.0" encoding="UTF-8"?>
<Retention>
    <Mode>COMPLIANCE</Mode>
    <RetainUntilDate>2022-06-18T23:01:00.000Z</RetainUntilDate>
</Retention>

Sample response

Object Lock Object Retention response


HTTP/1.1 200 OK
Date: Wed, 8 Feb 2017 17:51:00 GMT
Connection: close