> For the complete documentation index, see [llms.txt](https://docs.petabox.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.petabox.io/http-api-compatible-with-amazon-s3/api-reference/putbucketversioning.md).

# PutBucketVersioning

Sets the versioning state of an existing bucket

You can set the versioning state with one of the following values:

**Enabled**

Enables versioning for the objects in the bucket. All objects added to the bucket receive a unique version ID.

#### Suspended

Disables versioning for the objects in the bucket. All objects added to the bucket receive the version ID null.

If the versioning state has never been set on a bucket, it has no versioning state; a [GetBucketVersioning](/http-api-compatible-with-amazon-s3/api-reference/getbucketversioning.md) request does not return a versioning state value.

{% hint style="danger" %}
**Important**

If you have an object expiration lifecycle configuration in your non-versioned bucket and you want to maintain the same permanent delete behavior when you enable versioning, you must add a noncurrent expiration policy. The noncurrent expiration lifecycle configuration will manage the deletes of the noncurrent object versions in the version-enabled bucket. (A version-enabled bucket maintains one current and zero or more noncurrent object versions.)
{% endhint %}

## Request Syntax <a href="#api_putbucketversioning_requestsyntax" id="api_putbucketversioning_requestsyntax"></a>

```http
PUT /?versioning HTTP/1.1
Host: Bucket.s3.petabox.io
Content-MD5: ContentMD5
x-amz-expected-bucket-owner: ExpectedBucketOwner
<?xml version="1.0" encoding="UTF-8"?>
<VersioningConfiguration xmlns="http://s3.petabox.io/doc/2006-03-01/">
   <Status>string</Status>
</VersioningConfiguration>
```

## URI Request Parameters <a href="#api_putbucketversioning_requestparameters" id="api_putbucketversioning_requestparameters"></a>

The request uses the following URI parameters.

#### Bucket

The bucket name.

Required: Yes

#### Content-MD5

The base64-encoded 128-bit MD5 digest of the data. You must use this header as a message integrity check to verify that the request body was not corrupted in transit. For more information, see [RFC 1864](http://www.ietf.org/rfc/rfc1864.txt).

For requests made using the AWS Command Line Interface (CLI) or AWS SDKs, this field is calculated automatically.

#### x-amz-expected-bucket-owner

The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with the HTTP status code `403 Forbidden` (access denied).

#### x-amz-mfa

The concatenation of the authentication device's serial number, a space, and the value that is displayed on your authentication device.

## Request Body <a href="#api_putbucketversioning_requestbody" id="api_putbucketversioning_requestbody"></a>

The request accepts the following data in XML format.

#### VersioningConfiguration

Root level tag for the VersioningConfiguration parameters.

Required: Yes

#### Status

The versioning state of the bucket.

Type: String

Valid Values: `Enabled | Suspended`

Required: No

## Response Syntax <a href="#api_putbucketversioning_responsesyntax" id="api_putbucketversioning_responsesyntax"></a>

```http
HTTP/1.1 200
```

## Response Elements <a href="#api_putbucketversioning_responseelements" id="api_putbucketversioning_responseelements"></a>

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

## Examples <a href="#api_putbucketversioning_examples" id="api_putbucketversioning_examples"></a>

### Sample Request <a href="#api_putbucketversioning_example_1" id="api_putbucketversioning_example_1"></a>

The following request enables versioning for the specified bucket.

```http
PUT /?versioning HTTP/1.1
Host: bucket.s3.<Region>.petabox.io
Date: Wed, 01 Mar  2006 12:00:00 GMT
Authorization: authorization string
Content-Type: text/plain
Content-Length: 124
 
<VersioningConfiguration xmlns="http://s3.petabox.io/doc/2006-03-01/"> 
  <Status>Enabled</Status> 
</VersioningConfiguration>
```

### Sample Response <a href="#api_putbucketversioning_example_2" id="api_putbucketversioning_example_2"></a>

This example illustrates one usage of PutBucketVersioning.

```http
HTTP/1.1 200 OK
x-amz-id-2: YgIPIfBiKa2bj0KMg95r/0zo3emzU4dzsD4rcKCHQUAdQkf3ShJTOOpXUueF6QKo
x-amz-request-id: 236A8905248E5A01
Date: Wed, 01 Mar  2006 12:00:00 GMT3
```

### Sample Request <a href="#api_putbucketversioning_example_3" id="api_putbucketversioning_example_3"></a>

The following request suspends versioning for the specified bucket.

```http
PUT /?versioning HTTP/1.1
Host: bucket.s3.<Region>.petabox.io
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
Content-Length: 124
 
<VersioningConfiguration xmlns="http://s3.petabox.io/doc/2006-03-01/"> 
   <Status>Suspended</Status> 
</VersioningConfiguration>
```

### Sample Response <a href="#api_putbucketversioning_example_4" id="api_putbucketversioning_example_4"></a>

This example illustrates one usage of PutBucketVersioning.

```http
HTTP/1.1 200 OK
x-amz-id-2: YgIPIfBiKa2bj0KMg95r/0zo3emzU4dzsD4rcKCHQUAdQkf3ShJTOOpXUueF6QKo
x-amz-request-id: 236A8905248E5A01
Date: Wed, 01 Mar  2006 12:00:00 GMT
```
