Search code examples
pythonamazon-web-servicesboto3amazon-sns

AWS SNS - boto3 - Specify TemplateId and EntityId


The following code works to send a message with a sender id but how do I specify a TemplateId and EntityId? These two fields were added recently and are required to send SMS messages to destinations in India. It's done with the message attributes but I cannot figure out the syntax/keys.

client.publish(PhoneNumber=phone, Message=message,
 MessageAttributes={
 'AWS.SNS.SMS.SenderID': {
   'DataType': 'String',
   'StringValue': 'SenderID'
  },
 'AWS.SNS.SMS.SMSType': {
   'DataType': 'String',
   'StringValue': 'Transactional'
 }})

AWS.SNS.SMS.TemplateId and AWS.SNS.SMS.TemplateID keys don't work.

I this error get:

Message attribute names starting with 'AWS.' or 'Amazon.' are reserved for use by Amazon.


Solution

  • As detailed here, the correct keys to use are AWS.MM.SMS.EntityId and AWS.MM.SMS.TemplateId.