dynobase-icon
Dynobase

Error: DynamoDB Key element does not match the schema

Rafal Wilinski

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.

  1. Use DescribeTable in the same account, Region and endpoint as the failing request. Read KeySchema and AttributeDefinitions.
  2. For GetItem, UpdateItem and DeleteItem, provide exactly the partition key and, if configured, sort key. Do not add ordinary attributes to Key.
  3. Match capitalization and data types. The string "123" and the number 123 are different keys.
  4. 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.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.