--- title: "Lock objects with Object Lock" description: "Turn on Object Lock when you create a bucket, set a retention period, and remove a Governance Lock or Legal Hold from a version." content_type: "how-to" product: "object-storage" platform: "MyAccount" url: "/myaccount/object-storage/how-to/lock-objects-with-object-lock/" topic: ["protect-your-data"] relationships: {"requires":["/myaccount/object-storage/how-to/create-a-bucket/"]} --- # Lock objects with Object Lock Object Lock stops a locked object version from being overwritten or deleted. Read [Object Lock](/myaccount/object-storage/concepts/object-lock/) first: you can turn it on only when you create the bucket, so decide before you create it. ## Turn on Object Lock when you create the bucket On the bucket creation form, check **Enable Object Lock**. This also turns on Object Versioning, since a lock only protects a version. Click **Create Bucket**. ## Set a default retention policy Open the bucket's **Object Lock** tab, set a retention period in days (1 to 36,500), select **Governance** (the only lock mode available today) as the lock mode, and save. Every object uploaded to this bucket from then on inherits this retention period automatically. ## Lock or unlock one version On the **Objects** tab, click **View All Versions**, open the version's menu, and select **Lock Settings**. From there: - Turn on **Governance Lock** to set a retention period on this one version, or remove it early. As the bucket's owner, you can shorten or clear a Governance Lock before it expires. - Turn on **Legal Hold** for an indefinite hold with no expiry; turn it off yourself when it is no longer needed. ## Before you delete a locked bucket To delete a bucket with a default lock policy, remove the policy first. Once it is gone, locked objects on their own no longer hold the delete back. A version under Governance Lock can still be deleted early if you, as the owner, clear or shorten the lock first; a version under Legal Hold can be deleted once you turn the hold off. See [Troubleshooting E2E Object Storage](/myaccount/object-storage/troubleshooting/object-storage/#my-bucket-will-not-delete) if a delete is blocked. For when to use Governance Lock and when to use Legal Hold, see [Object Lock](/myaccount/object-storage/concepts/object-lock/).