UpdateItem method
Written by
Updated at April 24, 2026
Updates the attributes of an existing item or adds a new item if it does not exist. You can update, delete, or add attribute values.
You can set an update condition. The method will then be triggered only if the condition is met.
It may return the attribute values as they were before or after the update.
Request
The request contains data in JSON format.
{
"AttributeUpdates": {
"string" : {
"Action": "string",
"Value": {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
}
},
"ConditionExpression": "string",
"Expected": {
"string" : {
"AttributeValueList": [
{
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
],
"ComparisonOperator": "string",
"Exists": boolean,
"Value": {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
}
},
"ExpressionAttributeNames": {
"string" : "string"
},
"ExpressionAttributeValues": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"Key": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"ReturnConsumedCapacity": "string",
"ReturnValues": "string",
"TableName": "string",
"UpdateExpression": "string"
}
Parameters
| Parameter | Description |
|---|---|
Key |
Primary key of the item to update; specify all the key attributes. For a simple primary key, you only need to specify its value. For a composite primary key, specify values for both the partition key and the sort key. Type: Associative array of the AttributeValue type.Length: 1 to 65,535 characters. Required: Yes |
TableName |
Name of the table with the item to update.It may contain a path in the hierarchical directory structure in path/to/table format.Type: String Length: 3 to 255 characters. Template: [a-zA-Z0-9_.-]+ Required: Yes |
ConditionExpression |
Condition for updating the item. The method will be triggered only if the condition is met. The condition consists of:
Type: String Required: No |
ExpressionAttributeNames |
Placeholder for an attribute name in an expression. The placeholder must start with the hash character, #.You can use it in the following cases:
Percentile attribute name conflicts with the reserved word, so you cannot use it explicitly in an expression. To fix this issue, specify the {"#P":"Percentile"} placeholder in the ExpressionAttributeNames parameter, and then, further on, use #P instead of the real attribute name.Type: String Length: 1 to 65,535 characters. Required: No |
ExpressionAttributeValues |
Placeholder for an attribute name in an expression, same as ExpressionAttributeNames. The placeholder must start with a colon, :.For example, you need to check whether the value of the ProductStatus attribute was one of the following: Available | Backordered | Discontinued. To do this, first declare placeholders: { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }. Now you can use them in the expression: ProductStatus IN (:avail, :back, :disc)Type: String of the AttributeValue typeRequired: No |
ReturnConsumedCapacity |
Sets whether to return information about the consumed capacity.
Type: String Possible values: TOTAL | NONERequired: No |
ReturnValues |
Use it if you need to get the attributes of an item before or after its update. Possible values:
Return values are strongly consistent. Type: String Possible values: NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEWRequired: No |
UpdateExpression |
Expression to update. It specifies the attributes to update and how to do it. Possible actions:
SET a=:value1, b=:value2 DELETE :value3, :value4, :value5Type: String Required: No |
Response
If successful, HTTP code 200 is returned.
You will get data in JSON format.
{
"Attributes": {
"string" : {
"B": blob,
"BOOL": boolean,
"BS": [ blob ],
"L": [
"AttributeValue"
],
"M": {
"string" : "AttributeValue"
},
"N": "string",
"NS": [ "string" ],
"NULL": boolean,
"S": "string",
"SS": [ "string" ]
}
},
"ConsumedCapacity": {
"CapacityUnits": number,
"GlobalSecondaryIndexes": {
"string" : {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
}
},
"LocalSecondaryIndexes": {
"string" : {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
}
},
"ReadCapacityUnits": number,
"Table": {
"CapacityUnits": number,
"ReadCapacityUnits": number,
"WriteCapacityUnits": number
},
"TableName": "string",
"WriteCapacityUnits": number
}
}
Parameters
| Parameter | Description |
|---|---|
Attributes |
Associative array of the AttributeValue type containing the item representation before or after its update.It is returned only if you provide ReturnValues set to ≠ NONE in the request.Type: Associative array of the AttributeValue type.Length: 1 to 65,535 characters. |
ConsumedCapacity |
Capacity units consumed by a delete operation. It is returned only if you provide ReturnConsumedCapacity set to TOTAL in the request.Type: Object of the ConsumedCapacity type. |
Errors
| Parameter | Description |
|---|---|
ConditionalCheckFailedException |
Cannot check the condition specified in the operation. HTTP status code: 400 |
InternalServerError |
An internal error occurred on the server side. HTTP status code: 500 |
ProvisionedThroughputExceededException |
Your request rate is too high. Try to reduce the frequency of requests. If their number is not too large, Managed Service for YDB will try to process them all. HTTP status code: 400 |
RequestLimitExceeded |
The throughput capacity exceeds the set quota. HTTP status code: 400 |
ResourceNotFoundException |
The specified table does not exist or its state is different from 'ACTIVE'. HTTP status code: 400 |
TransactionConflictException |
The operation is rejected because there is an ongoing transaction for the item. HTTP status code: 400 |
There may be some common errors as well shared by all methods.