Error: DynamoDB Key element does not match the schema

Answered by Rafal Wilinski
Last updated: October 23rd, 2026
Solution
The provided key element does not match the schema means the request key differs from the target table's primary key. Check the names, required attributes and DynamoDB types before changing the table.
- Use DescribeTable in the same account, Region and endpoint as the failing request. Read KeySchema and AttributeDefinitions.
- For GetItem, UpdateItem and DeleteItem, provide exactly the partition key and, if configured, sort key. Do not add ordinary attributes to Key.
- Match capitalization and data types. The string "123" and the number 123 are different keys.
- Use native JavaScript values with DynamoDBDocumentClient; use AttributeValue objects with the low-level client. Do not mix them.
aws dynamodb describe-table --table-name Orders \
--query 'Table.{Keys:KeySchema,Types:AttributeDefinitions}'For a table with String keys pk and sk, this document-client request supplies the complete key:
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";
const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));
const result = await db.send(new GetCommand({
TableName: "Orders",
Key: { pk: "CUSTOMER#123", sk: "ORDER#42" },
ConsistentRead: true,
}));
console.log(result.Item);The low-level equivalent is Key: { pk: { S: "CUSTOMER#123" }, sk: { S: "ORDER#42" } }. A GetItem request cannot address a GSI. Use Query with IndexName and that index's key schema when looking up an index key. If you know only the partition key of a composite table key, use Query to retrieve its matching items.
See key schema rules and AWS documentation.
Other Common DynamoDB Errors (with Solutions)
- DynamoDB Contains not working
- DynamoDB ConditionExpression not working
- dynamodb-admin command not found
- DynamoDB Internal Server Error
- DynamoDB Errors InvalidSignatureException Signature Expired
- DynamoDB Update Not Working
- dynamodb atomic counter not working
- DynamoDB Not Supported Requires @DynamoDBTyped Or @DynamoDBTypeConverted
- error dynamodb streams must be enabled on the table
- dynamodb botocore.exceptions.nocredentialserror unable to locate credentials
- dynamodb local unable to open database file
- name key is not defined dynamodb
- DynamoDB scan does not return all items
- DynamoDB Local NoClassDefFoundError
- could not connect to the endpoint URL dynamodb
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable
DynamoDB Info
© 2026 Dynobase