A simple, scalable newsletter subscription API built with AWS Lambda, DynamoDB, SES, and the Serverless Framework, using TypeScript.
- Subscribe users by email
- Send confirmation emails with secure tokens
- Confirm subscriptions through a unique token link
- Unsubscribe at any time
- Send emails to all confirmed subscribers
- Built using AWS SDK v3
- Fully typed with TypeScript
- Infrastructure as code via Serverless Framework
All endpoints are deployed via AWS API Gateway.
Request Body (JSON):
{
"email": "user@example.com"
}Response:
- Sends a confirmation email with a secure token link.
- Email must be verified in your SES sandbox (if you're in development mode).
Query Parameters:
token:string– The confirmation token from the subscription email
Response:
- Marks the email as confirmed in the database.
Request Body (JSON):
{
"email": "user@example.com"
}Response:
- Deletes the email from the subscriber list.
Request Body (JSON):
{
"subject": "My Newsletter",
"body": "Welcome to the first issue!"
}Response:
- Sends the provided email to all confirmed subscribers via AWS SES.
- Install serverless framework globally:
npm install --global serverless- Make sure your AWS credentials are configured:
aws configure- Add a .env file with:
FROM_EMAIL="your_verified_email@example.com"- Run serverless deploy:
serverless deploy- After use it, make sure to clean your AWS resources:
serverless removeYou can test the endpoints using:
This project includes a test.http file in the root directory. You can use it with VS Code and the REST Client extension to easily run and test all API endpoints.
- Install the REST Client extension for VS Code.
- Open test.http.
- Replace placeholders like
https://your-api-id.execute-api.region.amazonaws.com/devwith your deployed URL. - Click
"Send Request"above any HTTP block to run it directly.
Example with curl:
curl -X POST "https://your-api-id.execute-api.region.amazonaws.com/dev/subscribe" \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com"}'- Node.js / TypeScript
- AWS Lambda
- AWS DynamoDB (with GSI)
- AWS SES (Simple Email Service)
- Serverless Framework
- AWS SDK v3