# Enabling object lock

Object lock can prevent objects from being removed or overwritten for a specified period. Note that you must first enable versioning before enabling this feature on a bucket. Unlike versioning, object lock must be enabled at the time of bucket creation and the settings cannot be changed after creation.

You can either choose to define a retention period for each object individually or for all underlying objects. Legal holds can only be defined by version or object and not by bucket.

* **Reserve the option for individual retention periods** for underlying objects by leaving the 'Retention' checkmark blank.

<figure><img src="https://2387956678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY8faE22vrUUDUtw9aDVb%2Fuploads%2F08Y7fN0jMdk6I2fEp2gz%2Fimage.png?alt=media&#x26;token=17435bda-b6bf-4d18-8d8a-a2c501999885" alt=""><figcaption></figcaption></figure>

* **Set up aggregate retention periods** for all underlying objects by defining the retention mode and validity when creating the bucket.

<figure><img src="https://2387956678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY8faE22vrUUDUtw9aDVb%2Fuploads%2FIiVYcmsz2e7xF8WwFkAg%2Fimage.png?alt=media&#x26;token=88cd17aa-874c-409b-9662-dee54510750c" alt=""><figcaption></figcaption></figure>
