Common REST API Elements

Amazon S3 REST Operations are HTTP requests, as defined by RFC 2616 (http://www.ietf.org/rfc/rfc2616.txt). This section describes how Amazon S3 uses HTTP and the parts of HTTP requests and responses that Amazon S3 REST operations have in common. Detailed descriptions of individual operations are provided later in this guide.

A typical REST operation consists of a sending a single HTTP request to Amazon S3, followed by waiting for an HTTP response. Like any HTTP request, a request to Amazon S3 contains a request method, a URI, request headers, and sometimes a query string and request body. The response contains a status code, response headers, and sometimes a response body.

Following is an example that shows how to get an object named "Nelson" from the "quotes" bucket.

Sample Request

GET /Nelson HTTP/1.1
Host: quotes.s3.amazonaws.com
Date: Wed, 01 Mar  2006 12:00:00 GMT
Authorization: AWS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE=

Sample Response

HTTP/1.1 200 OK
x-amz-id-2: qBmKRcEWBBhH6XAqsKU/eg24V3jf/kWKN9dJip1L/FpbYr9FDy7wWFurfdQOEMcY
x-amz-request-id: F2A8CCCA26B4B26D
Date: Wed, 01 Mar  2006 12:00:00 GMT
Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT
ETag: "828ef3fdfa96f00ad9f27c383fc9ac7f"
Content-Type: text/plain
Content-Length: 5
Connection: close
Server: AmazonS3

ha-ha

Common Request Headers

Amazon S3 REST requests include headers which contain basic information about the request. Following is a table that describes common headers for Amazon S3 REST requests.

Header NameDescriptionRequired
AuthorizationThe information required for request authentication. For more information, see Constructing the Authentication Header for details about the format.Yes
Content-Length

Length of the message (without the headers) according to RFC 2616.

Condition: Required for PUTs and operations that load XML, such as logging and ACLs.

Conditional
Content-TypeThe content type of the resource. Example: text/plain Optional
DateThe current date and time according to the requestor. Example: Wed, 01 Mar 2006 12:00:00 GMT Yes
Host

Normally, the value of Host is s3.amazonaws.com. A Host header with a value other than s3.amazonaws.com selects the bucket for the request as described in Virtual Hosting of Buckets.

Condition: Required for HTTP 1.1 (most toolkits add this header automatically); optional for HTTP/1.0 requests.

Conditional
x-amz-security-token

The security tokens for operations that use Amazon DevPay. Each request that uses Amazon DevPay requires two x-amz-security-token headers: one for the product token and one for the user token.

Condition: Required for requests that use Amazon DevPay.

[Note]Note

When Amazon S3 receives an authenticated request, it compares the computed signature with the provided signature. Improperly formatted multi-value headers used to calculate a signature can cause authentication issues. To ensure the signature is calculated properly, follow the instructions in the Constructing the CanonicalizedResource Element section.

Conditional