Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Object Storage
  • Terraform reference
    • Authentication with the API
      • How to use the API
      • Signing requests
        • All services and methods
          • All methods
          • create
          • getBucketEncryption
          • getMeta
          • listObjects
          • listBuckets
          • deleteBucket
          • deleteBucketEncryption
          • putBucketEncryption
          • putBucketVersioning
          • getBucketVersioning
          • putBucketLogging
          • getBucketLogging
          • listObjectVersions
          • putObjectLockConfiguration
          • getObjectLockConfiguration
          • putBucketTagging
          • getBucketTagging
          • deleteBucketTagging
        • Common request headers
        • Common response headers
        • Responses
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Request
  • Path parameters
  • Headers
  • Data schema
  • Response
  • Headers
  • Response codes
  1. API reference
  2. REST (Amazon S3-compatible)
  3. REST
  4. Bucket
  5. putObjectLockConfiguration

putObjectLockConfiguration method

Written by
Yandex Cloud
Updated at March 19, 2025
  • Request
    • Path parameters
    • Headers
    • Data schema
  • Response
    • Headers
    • Response codes

Sets up object locks in a versioned bucket: enables or disables object locks and configures default locks.

With object lock enabled, you can lock an object version so that it cannot be deleted or overwritten:

  • When uploading the object (the upload method).
  • After uploading the object (the putObjectRetention and putObjectLegalHold methods).

For more information on getting started with the API and the general request format, see How to use the S3 API.

RequestRequest

PUT /{bucket}?object-lock HTTP/2

Path parametersPath parameters

Parameter Description
bucket Bucket name.

HeadersHeaders

Use only common headers in your requests.

Data schemaData schema

<ObjectLockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
   <ObjectLockEnabled>string</ObjectLockEnabled>
   <Rule>
      <DefaultRetention>
         <Mode>string</Mode>
         <Days>integer</Days>
         <Years>integer</Years>
      </DefaultRetention>
   </Rule>
</ObjectLockConfiguration>
Element Description
ObjectLockConfiguration

Root element.

To disable object lock, provide this parameter with an empty value, e.g., <ObjectLockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/" />.

Path: ObjectLockConfiguration.

ObjectLockEnabled

Object lock status:

  • Enabled: You can use object locks.

If you do not specify this item, you will get the InvalidRequest error message, and object lock will not get enabled.

Path: ObjectLockConfiguration\ObjectLockEnabled.

Rule

Lock settings.

Path: ObjectLockConfiguration\Rule.

DefaultRetention

Default lock settings.

Path: ObjectLockConfiguration\Rule\DefaultRetention.

Mode

Default retention type:

  • GOVERNANCE: Governance-mode retention.
  • COMPLIANCE: Compliance-mode retention.

Path: ObjectLockConfiguration\Rule\DefaultRetention\Mode.

Days

Default retention period in days since the object version upload. It must be a positive integer. You cannot use it together with Years.

Path: ObjectLockConfiguration\Rule\DefaultRetention\Days.

Years

Default retention period in years since the object version upload. It must be a positive integer. You cannot use it together with Days.

Path: ObjectLockConfiguration\Rule\DefaultRetention\Years.

ResponseResponse

HeadersHeaders

Responses can only contain common headers.

Response codesResponse codes

For a list of possible responses, see Responses.

See alsoSee also

  • Debugging requests using the AWS CLI
  • Example of sending a signed request using curl
  • Code example for generating a signature

Was the article helpful?

Previous
listObjectVersions
Next
getObjectLockConfiguration
© 2025 Direct Cursus Technology L.L.C.