demo-billing / AWS setup
Webhook endpoint
AWS pushes SES events to this URL. Sesmograph never needs your AWS credentials.
https://demo.sesmograph.com/webhooks/xhz5engfv7rmtnknb31h2wwl16jigsdrfqqulbnatn4qmamc
Connect AWS
Five steps in the AWS console, in the region you send from - or expand
Prefer CLI? under each step.
In the CLI commands, replace <region> and
<account-id> with your values.
-
1. Create a configuration set
A configuration set tracks what happens after emails are sent.
- Go to Amazon SES (correct region)
- Navigate to Configuration sets
- Click Create set
- Name:
demo-billing-ses - Leave defaults, click Create set
Prefer CLI?
aws ses create-configuration-set \ --configuration-set '{"Name":"demo-billing-ses"}' \ --region <region> -
2. Create an SNS topic
SNS forwards events to your webhook.
- Go to Amazon SNS
- Click Topics -> Create topic
- Select Standard (not FIFO)
- Name:
demo-billing-ses-events - Click Create topic
Prefer CLI?
aws sns create-topic \ --name "demo-billing-ses-events" \ --region <region> -
3. Subscribe this webhook
An HTTPS subscription pointing at this topic's endpoint.
- From the SNS topic, click Create subscription
- Protocol: HTTPS
- Endpoint:
https://demo.sesmograph.com/webhooks/xhz5engfv7rmtnknb31h2wwl16jigsdrfqqulbnatn4qmamc - Leave filter policy empty
- Leave "Enable raw message delivery" unchecked
- Click Create subscription
- Confirmation is automatic
Prefer CLI?
aws sns subscribe \ --topic-arn arn:aws:sns:<region>:<account-id>:demo-billing-ses-events \ --protocol https \ --notification-endpoint "https://demo.sesmograph.com/webhooks/xhz5engfv7rmtnknb31h2wwl16jigsdrfqqulbnatn4qmamc" \ --region <region> -
4. Add an event destination
Connect the configuration set to the SNS topic.
- Go to SES -> Configuration sets
- Click
demo-billing-ses - Event destinations tab -> Add destination
- Select all event types: Sends, Deliveries, Bounces, Complaints, Opens, Clicks, Delivery delays, Rejections, Rendering failures, Subscriptions
- Destination type: Amazon SNS
- Topic:
demo-billing-ses-events - Enable "Include original email headers" - that is how subjects and recipients show up here
- Click Add destination
Prefer CLI?
aws ses create-configuration-set-event-destination \ --configuration-set-name "demo-billing-ses" \ --event-destination '{ "Name":"demo-billing-ses-events", "Enabled":true, "MatchingEventTypes":["send","reject","bounce","complaint","delivery","open","click","renderingFailure","deliveryDelay","subscription"], "SNSDestination":{"TopicARN":"arn:aws:sns:<region>:<account-id>:demo-billing-ses-events"} }' \ --region <region> -
5. Send with the configuration set
Specify the configuration set on outgoing mail - as an API parameter or a header:
X-SES-CONFIGURATION-SET: demo-billing-sesOr skip the header: set it as the identity's default, and SES applies it to every email sent from that address or domain.
- Go to SES -> Identities
- Open the identity you send from
- Configuration set tab -> Edit
- Pick
demo-billing-sesas the default configuration set, save
Prefer CLI?
aws sesv2 put-email-identity-configuration-set-attributes \ --email-identity your-identity.example.com \ --configuration-set-name "demo-billing-ses" \ --region <region>
Optional: store full message content
SES events never carry the body. To see full messages here, have your app post the content right after sending, using the SES message id and an API token (Settings -> API tokens). Bodies are kept for 30 days.
curl -X POST https://demo.sesmograph.com/api/v1/messages/<ses-message-id>/content \
-H "Authorization: Bearer <api-token>" \
-H "Content-Type: application/json" \
-d '{"html":"<!doctype html>...","text":"Plain-text version"}'
Verify it works
Send a test email through the configuration set. Its events appear on this topic within seconds.
Prefer CLI?
aws sns list-subscriptions-by-topic \
--topic-arn arn:aws:sns:<region>:<account-id>:demo-billing-ses-events \
--region <region>
aws ses describe-configuration-set \
--configuration-set-name "demo-billing-ses" \
--configuration-set-attribute-names eventDestinations \
--region <region>