I have a contact list where each contact has a list of topic preferences, e.g.
// aws sesv2 get-contact-list --contact-list-name my_contact_list
{
"ContactListName": "my_contact_list",
"Topics": [
{
"TopicName": "transactional_emails_1",
"DisplayName": "...",
"Description": "...",
"DefaultSubscriptionStatus": "OPT_IN"
},
{
"TopicName": "transactional_emails_2",
"DisplayName": "...",
"Description": "...",
"DefaultSubscriptionStatus": "OPT_IN"
}
],
"CreatedTimestamp": "2022-04-12T11:40:48.061000+01:00",
"LastUpdatedTimestamp": "2022-05-12T11:01:13.596000+01:00",
"Tags": []
}
And when I list the contacts:
// aws sesv2 list-contacts --contact-list-name my_contact_list
{
"EmailAddress": "name.surname@example.com",
"TopicPreferences": [
{
"TopicName": "transactional_emails_1",
"SubscriptionStatus": "OPT_IN"
}
],
"TopicDefaultPreferences": [
{
"TopicName": "transactional_emails_2",
"SubscriptionStatus": "OPT_IN"
}
],
"UnsubscribeAll": false,
"LastUpdatedTimestamp": "2022-05-16T09:14:16.483000+01:00"
}
I would now need to add a new topic to the contact list.
However, I can't find any way to update the list, or the existing contacts in that list.
When I try to send an email to that list with a new topic, I get this error:
"An error occurred (NotFoundException) when calling the SendEmail operation: List: my_contact_list doesn't contain Topic: transactional_emails_3
What I would end up with is a situation where the contact list contains the new topic (transactional_emails_3
) and each user in that list is subscribed to it:
// aws sesv2 get-contact-list --contact-list-name my_contact_list
{
"ContactListName": "my_contact_list",
"Topics": [
{
"TopicName": "transactional_emails_1",
"DisplayName": "...",
"Description": "...",
"DefaultSubscriptionStatus": "OPT_IN"
},
{
"TopicName": "transactional_emails_2",
"DisplayName": "...",
"Description": "...",
"DefaultSubscriptionStatus": "OPT_IN"
},
{
"TopicName": "transactional_emails_3",
"DisplayName": "...",
"Description": "...",
"DefaultSubscriptionStatus": "OPT_IN"
}
],
"CreatedTimestamp": "2022-04-12T11:40:48.061000+01:00",
"LastUpdatedTimestamp": "2022-05-12T11:01:13.596000+01:00",
"Tags": []
}
Can it be done using the AWS SDK (SESv2 API)?
Thank you, I saw that API but it actually replaces a contact list, rather than just making additive/subtractive updates. My understanding is that, in order to simply add a new topic to an existing contact list, one would have to:
GetContactList
UpdateContactList
ListContacts
(it involves pagination, so multiple calls)UpdateContact
(to subscribe them to the new topic)Is my understanding correct, or is there a better way to achieve that?