

# PutSnapshotBlock
<a name="API_PutSnapshotBlock"></a>

Writes a block of data to a snapshot. If the specified block contains data, the existing data is overwritten. The target snapshot must be in the `pending` state.

Data written to a snapshot must be aligned with 512-KiB sectors.

**Note**  
You should always retry requests that receive server (`5xx`) error responses, and `ThrottlingException` and `RequestThrottledException` client error responses. For more information see [Error retries](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html) in the *Amazon Elastic Compute Cloud User Guide*.

## Request Syntax
<a name="API_PutSnapshotBlock_RequestSyntax"></a>

```
PUT /snapshots/snapshotId/blocks/blockIndex HTTP/1.1
x-amz-Data-Length: DataLength
x-amz-Progress: Progress
x-amz-Checksum: Checksum
x-amz-Checksum-Algorithm: ChecksumAlgorithm

BlockData
```

## URI Request Parameters
<a name="API_PutSnapshotBlock_RequestParameters"></a>

The request uses the following URI parameters.

 ** [blockIndex](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-uri-BlockIndex"></a>
The block index of the block in which to write the data. A block index is a logical index in units of `512` KiB blocks. To identify the block index, divide the logical offset of the data in the logical volume by the block size (logical offset of data/`524288`). The logical offset of the data must be `512` KiB aligned.  
Valid Range: Minimum value of 0.  
Required: Yes

 ** [Checksum](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-Checksum"></a>
A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are supported.  
Length Constraints: Maximum length of 64.  
Pattern: `^[A-Za-z0-9+/=]+$`   
Required: Yes

 ** [ChecksumAlgorithm](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-ChecksumAlgorithm"></a>
The algorithm used to generate the checksum. Currently, the only supported algorithm is `SHA256`.  
Length Constraints: Maximum length of 32.  
Pattern: `^[A-Za-z0-9]+$`   
Valid Values: `SHA256`   
Required: Yes

 ** [DataLength](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-DataLength"></a>
The size of the data to write to the block, in bytes. Currently, the only supported size is `524288` bytes.  
Valid values: `524288`   
Required: Yes

 ** [Progress](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-Progress"></a>
The progress of the write process, as a percentage.  
Valid Range: Minimum value of 0. Maximum value of 100.

 ** [snapshotId](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-uri-SnapshotId"></a>
The ID of the snapshot.  
If the specified snapshot is encrypted, you must have permission to use the KMS key that was used to encrypt the snapshot. For more information, see [ Using encryption](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebsapis-using-encryption.html) in the *Amazon Elastic Compute Cloud User Guide*..
Length Constraints: Minimum length of 1. Maximum length of 64.  
Pattern: `^snap-[0-9a-f]+$`   
Required: Yes

## Request Body
<a name="API_PutSnapshotBlock_RequestBody"></a>

The request accepts the following binary data.

 ** [BlockData](#API_PutSnapshotBlock_RequestSyntax) **   <a name="ebs-PutSnapshotBlock-request-BlockData"></a>
The data to write to the block.  
The block data is not signed as part of the Signature Version 4 signing process. As a result, you must generate and provide a Base64-encoded SHA256 checksum for the block data using the **x-amz-Checksum** header. Also, you must specify the checksum algorithm using the **x-amz-Checksum-Algorithm** header. The checksum that you provide is part of the Signature Version 4 signing process. It is validated against a checksum generated by Amazon EBS to ensure the validity and authenticity of the data. If the checksums do not correspond, the request fails. For more information, see [ Using checksums with the EBS direct APIs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums) in the *Amazon Elastic Compute Cloud User Guide*.  
Required: Yes

## Response Syntax
<a name="API_PutSnapshotBlock_ResponseSyntax"></a>

```
HTTP/1.1 201
x-amz-Checksum: Checksum
x-amz-Checksum-Algorithm: ChecksumAlgorithm
```

## Response Elements
<a name="API_PutSnapshotBlock_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 201 response.

The response returns the following HTTP headers.

 ** [Checksum](#API_PutSnapshotBlock_ResponseSyntax) **   <a name="ebs-PutSnapshotBlock-response-Checksum"></a>
The SHA256 checksum generated for the block data by Amazon EBS.  
Length Constraints: Maximum length of 64.  
Pattern: `^[A-Za-z0-9+/=]+$` 

 ** [ChecksumAlgorithm](#API_PutSnapshotBlock_ResponseSyntax) **   <a name="ebs-PutSnapshotBlock-response-ChecksumAlgorithm"></a>
The algorithm used by Amazon EBS to generate the checksum.  
Length Constraints: Maximum length of 32.  
Pattern: `^[A-Za-z0-9]+$`   
Valid Values: `SHA256` 

## Errors
<a name="API_PutSnapshotBlock_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** AccessDeniedException **   
You do not have sufficient access to perform this action.    
 ** Reason **   
The reason for the exception.
HTTP Status Code: 403

 ** InternalServerException **   
An internal error has occurred. For more information see [Error retries](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html).  
HTTP Status Code: 500

 ** RequestThrottledException **   
The number of API requests has exceeded the maximum allowed API request throttling limit for the snapshot. For more information see [Error retries](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/error-retries.html).    
 ** Reason **   
The reason for the exception.
HTTP Status Code: 400

 ** ResourceNotFoundException **   
The specified resource does not exist.    
 ** Reason **   
The reason for the exception.
HTTP Status Code: 404

 ** ServiceQuotaExceededException **   
Your current service quotas do not allow you to perform this action.    
 ** Reason **   
The reason for the exception.
HTTP Status Code: 402

 ** ValidationException **   
The input fails to satisfy the constraints of the EBS direct APIs.    
 ** Reason **   
The reason for the validation exception.
HTTP Status Code: 400

## See Also
<a name="API_PutSnapshotBlock_SeeAlso"></a>

For more information about using this API in one of the language-specific AWS SDKs, see the following:
+  [AWS Command Line Interface V2](https://docs.aws.amazon.com/goto/cli2/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for .NET V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/goto/SdkForCpp/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for Go v2](https://docs.aws.amazon.com/goto/SdkForGoV2/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for Java V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for JavaScript V3](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for Kotlin](https://docs.aws.amazon.com/goto/SdkForKotlin/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for PHP V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for Python](https://docs.aws.amazon.com/goto/boto3/ebs-2019-11-02/PutSnapshotBlock) 
+  [AWS SDK for Ruby V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/ebs-2019-11-02/PutSnapshotBlock) 