dynobase-icon
Dynobase

Error: dynamodb put item not working

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

PutItem can fail because the request is not awaited, required keys are missing, or low-level attribute values use the wrong representation. Capture the actual exception and use the API format that matches the client.

import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb";

const db = new DynamoDBClient({});
export const handler = async () => {
  await db.send(new PutItemCommand({
    TableName: "People",
    Item: { pk: { N: "1" }, name: { S: "Lakindu" } },
    ReturnConsumedCapacity: "TOTAL",
  }));
  return { statusCode: 200, body: "Saved" };
};

This table has a Number partition key. In low-level DynamoDB JSON, the value inside N is a string, even for an integer. With DynamoDBDocumentClient and PutCommand, use pk: 1 instead. Awaiting keeps the handler from returning before the write completes; it does not block all other JavaScript work.

An empty successful response does not mean failure. Read the same complete key from the base table with ConsistentRead enabled to verify it. A PutItem replaces the entire existing item at that key unless a condition rejects the write.

See writing items and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
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.