- Newest
- Most votes
- Most comments
The MessageAttributes object is used to specify additional metadata for the SMS message, including the AWS.MM.SMS.EntityId and AWS.MM.SMS.TemplateId parameters.
In the provided code snippet:
"AWS.SNS.SMS.EntityID": {
DataType: "String",
StringValue: <entity-id>,
},
"AWS.SNS.SMS.TemplateID": {
DataType: "String",
StringValue: <template-id>,
}
The parameter name AWS.SNS.SMS.EntityID and AWS.SNS.SMS.TemplateID are not correct. According to the AWS documentation, the correct parameter name are AWS.MM.SMS.EntityId and AWS.MM.SMS.TemplateId.
The code should be updated as follows:
"AWS.MM.SMS.EntityId": {
DataType: "String",
StringValue: <entity-id>,
},
"AWS.MM.SMS.TemplateId": {
DataType: "String",
StringValue: <template-id>,
}
Please make the necessary corrections to ensure that the correct parameter names are used when specifying the entity ID and template ID for SMS messages.
The error you're encountering is due to the incorrect use of reserved message attribute names in your AWS SNS code. AWS reserves attribute names starting with 'AWS.' or 'Amazon.' for their own use, and you cannot directly set these attributes in your code.
For sending SMS messages to Indian mobile numbers with DLT (Distributed Ledger Technology) compliance, you need to include the EntityID and TemplateID, but not as reserved AWS attributes. Instead, you should include these as custom message attributes.
Here's how you can modify your code to correctly include the EntityID and TemplateID:
const sendSnsMessage = async (message, phone) => { try { let params = { Message: message, PhoneNumber: phone, MessageAttributes: { "AWS.SNS.SMS.SMSType": { DataType: "String", StringValue: "Transactional", }, "AWS.SNS.SMS.SenderID": { DataType: "String", StringValue: "YOUR_SENDER_ID", }, "EntityId": { DataType: "String", StringValue: "YOUR_ENTITY_ID", }, "TemplateId": { DataType: "String", StringValue: "YOUR_TEMPLATE_ID", }, }, }; let publishCmd = new PublishCommand(params); let sentMsg = await SNS.send(publishCmd); return sentMsg; } catch (error) { console.log("error", error.message); } };
In this modified version:
- We've kept the reserved attributes "AWS.SNS.SMS.SMSType" and "AWS.SNS.SMS.SenderID" as they are.
- We've added "EntityId" and "TemplateId" as custom message attributes, without the "AWS.SNS.SMS." prefix.
By making these changes, you should be able to include your EntityID and TemplateID without encountering the error about reserved attribute names. Remember to replace "YOUR_SENDER_ID", "YOUR_ENTITY_ID", and "YOUR_TEMPLATE_ID" with your actual values.
This approach allows you to comply with DLT requirements for sending SMS to Indian mobile numbers while adhering to AWS SNS's rules about reserved attribute names.
Sources
Publishing with platform-specific payloads - Amazon Simple Notification Service
Amazon SNS now supports sending SMS from five new regions
answered 2 years ago
Removed AWS prefix from EntityID and TemplateID, resolving reserved attribute error, but now receiving SMS with random number; how to use registered SenderID with AWS SNS for Indian mobile numbers?

After resolving the reserved attribute error by modifying the code, I'm now encountering an issue where SMS messages are being sent from random numbers instead of my registered SenderID; how can I configure AWS SNS to use my registered SenderID for Indian mobile numbers?
Share your modified complete code for review
An issue where messages are sent from random number instead of SenderID has resolved by adding the SNS policy on AWS End User Messaging console; thanks:)