Prompt
I'm building a SaaS app and need a notification API for email and push
Latest observation
Nov 15, 2026
OpenAI APIWeb search: off
Here’s a solid starting design for a notification API that supports email and push for a SaaS app.
1) Core concepts
Notification
A single message to be delivered through one or more channels.
Fields:
idtenant_iduser_idorrecipienttype(e.g.welcome,invoice_due,password_reset)channels(email,push)titlebodydata(JSON payload for app actions/deep links)status(queued,sent,failed,delivered,read)created_at,scheduled_for,sent_at
Recipient
A user/contact with channel-specific addresses:
- Email:
email - Push:
device_tokens[]orpush_subscriptions[]
Template
Reusable notification content with variables:
template_idchannelsubjecttitlebodyvariables
2) Suggested API endpoints
Create/send notification
POST /v1/notifications
Example:
{
"tenant_id": "t_123",
"recipient": {
"user_id": "u_456"
},
"type": "invoice_due",
"channels": ["email", "push"],
"template_id": "tpl_invoice_due",
"data": {
"invoice_id": "inv_789",
"amount": "$49.00",
"due_date": "2026-01-15"
}
}
Response:
{
"id": "ntf_001",
"status": "queued"
}
Get notification
GET /v1/notifications/{id}
Returns delivery status per channel:
{
"id": "ntf_001",
"status": "sent",
"deliveries": [
{ "channel": "email", "status": "sent" },
{ "channel": "push", "status": "queued" }
]
}
List notifications
GET /v1/notifications?tenant_id=t_123&user_id=u_456&status=sent
Register push token
POST /v1/users/{user_id}/devices
{
"platform": "ios",
"push_token": "abc123",
"app_version": "1.2.3"
}
Update preferences
PUT /v1/users/{user_id}/notification-preferences
{
"email": true,
"push": true,
"types": {
"marketing": false,
"billing": true
}
}
3) Recommended architecture
Components
- API service: receives notification requests
- Queue: async processing (SQS, RabbitMQ, Kafka, Redis queue)
- Worker(s): send email/push
- Provider adapters:
- Email: SES, SendGrid, Mailgun
- Push: FCM, APNs
- DB: store notifications, deliveries, templates, preferences
Flow
- Client calls
POST /notifications - API validates request and stores record
- API enqueues jobs for each channel
- Workers send via providers
- Delivery status updated in DB/webhooks
4) Important design features
Idempotency
Support Idempotency-Key header for safe retries.
Scheduling
Allow scheduled_for:
{
"scheduled_for": "2026-01-20T10:00:00Z"
}
Personalization
Template variables like:
{{first_name}}{{invoice_id}}{{deep_link}}
Multi-tenant support
Always isolate by tenant_id.
Delivery tracking
Store:
- provider message id
- error code
- retry count
- timestamps
Retry policy
- Retry transient errors
- Dead-letter failed jobs
- Exponential backoff
Webhooks
Optional callback for delivery events:
notification.sentnotification.deliverednotification.failed
5) Minimal data model
notifications
idtenant_idtyperecipient_user_idpayload_jsonstatusscheduled_forcreated_at
notification_deliveries
idnotification_idchannelproviderprovider_message_idstatuserror_codeerror_messagesent_atdelivered_at
user_devices
iduser_idplatformpush_tokenis_activecreated_at
notification_templates
idtenant_idchanneltypesubjecttitlebody
6) Security considerations
- Authenticate all endpoints with API keys or OAuth
- Validate tenant ownership
- Rate limit by tenant/user
- Sanitize template variables
- Protect push tokens and PII
- Audit log sends and preference changes
7) Example email + push payload
{
"type": "order_shipped",
"channels": ["email", "push"],
"recipient": { "user_id": "u_123" },
"template_id": "tpl_order_shipped",
"data": {
"order_id": "ord_555",
"tracking_url": "https://example.com/track/ord_555"
}
}
Push-specific:
{
"title": "Your order has shipped",
"body": "Order #ord_555 is on the way.",
"data": {
"deep_link": "myapp://orders/ord_555"
}
}
Email-specific:
{
"subject": "Your order has shipped",
"html": "<p>Your order <strong>#ord_555</strong> is on the way.</p>"
}
If you want, I can next give you one of these:
- a full REST API spec
- a database schema
- a Node.js/TypeScript implementation
- a FastAPI implementation