PutBucketAnalyticsConfiguration - Amazon Simple Storage Service
AWS services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with AWS services in China.


Sets an analytics configuration for the bucket (specified by the analytics configuration ID). You can have up to 1,000 analytics configurations per bucket.

You can choose to have storage class analysis export analysis reports sent to a comma-separated values (CSV) flat file. See the DataExport request element. Reports are updated daily and are based on the object filters that you configure. When selecting data export, you specify a destination bucket and an optional destination prefix where the file is written. You can export the data to a destination bucket in a different account. However, the destination bucket must be in the same Region as the bucket that you are making the PUT analytics configuration to. For more information, see Amazon S3 Analytics – Storage Class Analysis.


You must create a bucket policy on the destination bucket where the exported file is written to grant permissions to Amazon S3 to write objects to the bucket. For an example policy, see Granting Permissions for Amazon S3 Inventory and Storage Class Analysis.

To use this operation, you must have permissions to perform the s3:PutAnalyticsConfiguration action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources.

Special Errors

    • HTTP Error: HTTP 400 Bad Request

    • Code: InvalidArgument

    • Cause: Invalid argument.

    • HTTP Error: HTTP 400 Bad Request

    • Code: TooManyConfigurations

    • Cause: You are attempting to create a new configuration but have already reached the 1,000-configuration limit.

    • HTTP Error: HTTP 403 Forbidden

    • Code: AccessDenied

    • Cause: You are not the owner of the specified bucket, or you do not have the s3:PutAnalyticsConfiguration bucket permission to set the configuration on the bucket.

Request Syntax

PUT /?analytics&id=Id HTTP/1.1 Host: Bucket.s3.amazonaws.com x-amz-expected-bucket-owner: ExpectedBucketOwner <?xml version="1.0" encoding="UTF-8"?> <AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>string</Id> <Filter> <And> <Prefix>string</Prefix> <Tag> <Key>string</Key> <Value>string</Value> </Tag> ... </And> <Prefix>string</Prefix> <Tag> <Key>string</Key> <Value>string</Value> </Tag> </Filter> <StorageClassAnalysis> <DataExport> <Destination> <S3BucketDestination> <Bucket>string</Bucket> <BucketAccountId>string</BucketAccountId> <Format>string</Format> <Prefix>string</Prefix> </S3BucketDestination> </Destination> <OutputSchemaVersion>string</OutputSchemaVersion> </DataExport> </StorageClassAnalysis> </AnalyticsConfiguration>

URI Request Parameters

The request uses the following URI parameters.


The name of the bucket to which an analytics configuration is stored.

Required: Yes


The ID that identifies the analytics configuration.

Required: Yes


The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Request Body

The request accepts the following data in XML format.


Root level tag for the AnalyticsConfiguration parameters.

Required: Yes


The filter used to describe a set of objects for analyses. A filter must have exactly one prefix, one tag, or one conjunction (AnalyticsAndOperator). If no filter is provided, all objects will be considered in any analysis.

Type: AnalyticsFilter data type

Required: No


The ID that identifies the analytics configuration.

Type: String

Required: Yes


Contains data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes.

Type: StorageClassAnalysis data type

Required: Yes

Response Syntax

HTTP/1.1 200

Response Elements

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


Example 1: Creating an analytics configuration

The following PUT request for the bucket examplebucket creates a new or replaces an existing analytics configuration with the ID report1. The configuration is defined in the request body.

PUT /?analytics&id=report1 HTTP/1.1 Host: examplebucket.s3.<Region>.amazonaws.com Date: Mon, 31 Oct 2016 12:00:00 GMT Authorization: authorization string Content-Length: length <?xml version="1.0" encoding="UTF-8"?> <AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>report1</Id> <Filter> <And> <Prefix>images/</Prefix> <Tag> <Key>dog</Key> <Value>corgi</Value> </Tag> </And> </Filter> <StorageClassAnalysis> <DataExport> <OutputSchemaVersion>V_1</OutputSchemaVersion> <Destination> <S3BucketDestination> <Format>CSV</Format> <BucketAccountId>123456789012</BucketAccountId> <Bucket>arn:aws:s3:::destination-bucket</Bucket> <Prefix>destination-prefix</Prefix> </S3BucketDestination> </Destination> </DataExport> </StorageClassAnalysis> </AnalyticsConfiguration>

Sample Response

This example illustrates one usage of PutBucketAnalyticsConfiguration.

HTTP/1.1 200 OK x-amz-id-2: YgIPIfBiKa2bj0KMg95r/0zo3emzU4dzsD4rcKCHQUAdQkf3ShJTOOpXUueF6QKo x-amz-request-id: 236A8905248E5A01 Date: Mon, 31 Oct 2016 12:00:00 GMT Content-Length: 0 Server: AmazonS3

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: