PutRecords
Puts multiple records into a data stream in a single call.
This method delivers higher throughput compared to PutRecord. A single request can contain up to 500 records. Each record in the request can be up to 1 MB in size. The total request size cannot exceed 5 MB, including partition keys.
The request must include the stream name and an array of Records. Each record must contain a partition key and an object containing Base64-encoded user data. To explicitly specify the hash key determining the target shard for records, use the ExplicitHashKey parameter.
Returns an array of elements containing status information for each record. Each entry in the response array corresponds to a record in the request array. The response array maintains the same order as the request array. The response array provides status information for all records, whether processed successfully or not. A single record failure does not prevent processing of subsequent records.
PutRecords guarantees that records are written to the stream in the exact order they appear in the request array.
For successfully processed records, the response includes the ShardId of the shard where the record was stored and the SequenceNumber assigned to the record.
For records that failed processing, the response includes an ErrorCode and an ErrorMessage. Common error types include ProvisionedThroughputExceededException and InternalFailure. For ProvisionedThroughputExceededException errors, the error message includes the account ID, the stream name, and the shard ID of the failed record.
Request
The request contains JSON-formatted data.
{
"Records": [{
"Data": blob,
"ExplicitHashKey": "string",
"PartitionKey": "string"
}],
"StreamName": "string"
}
Request options
| Option | Description |
|---|---|
Records |
Record to write Type Array of objects PutRecordsRequestEntryNumber of elements: 1-500Required: Yes |
StreamName |
Data stream name. Type: String Size: 1-128 characters.The possible values are: [a-zA-Z][a-zA-Z0-9-]+*(?<!-)$Required: Yes |
Response
Successful requests return HTTP 200 with a JSON-formatted response body.
{
"EncryptionType": "string",
"FailedRecordCount": number,
"Records": [{
"ErrorCode": "string",
"ErrorMessage": "string",
"SequenceNumber": "string",
"ShardId": "string"
}]
}
Response parameters
| Parameter | Description |
|---|---|
EncryptionType |
Encryption type. Type: String Allowed values: NONERequired: Yes |
FailedRecordCount |
Number of failed records. |
Records |
Record processing results. Type Array of PutRecordsRequestEntry objectsNumber of elements: 1-500Required: Yes |
Errors
| Error | Description | HTTP code |
|---|---|---|
InvalidArgumentException |
The argument is invalid. See the error message for details. | 400 |
ResourceNotFoundException |
The requested resource was not found. | 400 |
Errors common to all methods may occur.