Set bucket versioning

By default, buckets do not have versioning enabled. To set or modify versioning configuration for an existing bucket you make a PUT request that is scoped to the bucket and you use the versioning query string parameter. You must include an XML document in the request body that contains the versioning configuration that you want to apply. Notice that you cannot set versioning configuration on a new bucket that you are creating.

You must have FULL_CONTROL permission to set or modify versioning configuration for an existing bucket. Also, you must be authenticated to use the PUT Bucket method.

Query string parameters

Parameter Description Required
versioning You use this to change the versioning configuration on an existing bucket. You must provide the VersioningConfiguration document in the request body. No

See signed URL query string parameters for information on the parameters you include when creating and using signed URLs.

Request headers

See common request headers.

Request body elements

The following request body elements are applicable only if you use the versioning query string parameter to specify versioning configuration for an existing bucket.

Element Description
VersioningConfiguration Container for versioning configuration.
Status Status of versioning for this bucket. Currently can be either Enabled or Suspended.

Request syntax

PUT /?versioning HTTP/1.1
Host: BUCKET_NAME.storage.googleapis.com
Date: DATE
Content-Length: REQUEST_BODY_LENGTH
Content-Type: MIME_TYPE_OF_THE_BODY
Authorization: AUTHENTICATION_STRING

XML_DOCUMENT_DEFINING_VERSIONING

Response headers

The request can return a variety of response headers depending on the request headers you use.

Response body elements

The response does not include an XML document in the response body.

Example

The following sample turns on Object Versioning on a bucket named acme-pets.

Request

PUT /?versioning HTTP/1.1
Host: acme-pets.storage.googleapis.com
Date: Thu, 12 Mar 2012 03:38:42 GMT
Content-Length: 113
Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg

<?xml version="1.0" encoding="UTF-8"?>
<VersioningConfiguration><Status>Enabled</Status></VersioningConfiguration>

Response

HTTP/1.1 200 OK
Date: Thu, 12 Mar 2012 03:38:42 GMT
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, no-store, must-revalidate
Content-Length: 0
Content-Type: text/html