Prompt
How do I use one API for email and in-app alerts?
Latest observation
Oct 6, 2026
OpenAI APIWeb search: off
Use a single notification API and make the channel a parameter.
Common pattern
Send one request like:
POST /notifications
{
"user_id": "123",
"type": "order_shipped",
"channels": ["email", "in_app"],
"title": "Your order shipped",
"message": "Your package is on the way.",
"data": {
"order_id": "A1001"
}
}
How it works
- One endpoint handles all notifications.
channelstells the system where to deliver:emailin_app- or both
- The backend routes the same notification content to the right delivery service.
Recommended structure
- Notification API
- Accepts one payload
- Validates recipient, template, and channels
- Channel adapters
- Email adapter sends via SMTP/SendGrid/Mailgun
- In-app adapter stores alert in your database / websocket stream
- Template system
- One logical notification type
- Channel-specific formatting if needed
Example backend flow
- API receives request
- Creates a notification record
- Queues jobs for each channel
- Email worker sends email
- In-app worker creates unread alert for user
Good design tips
- Keep the notification event separate from the delivery channel
- Use templates per channel if formatting differs
- Add preferences so users can opt out of email but keep in-app alerts
- Track delivery status per channel
If you want, I can show:
- a REST API design
- a database schema
- or an example in Node.js / Python / Java