Overview
The Complaints API provides endpoints for retrieving and analyzing email complaints received from email service providers (primarily Amazon SES). Complaints occur when recipients mark emails as spam or report abuse. Base URL:/complaint
Complaint Model
Complaints have the following structure:id(UUID) - Unique complaint identifiernotification_id(UUID) - ID of the notification that generated the complaintservice_id(UUID) - Service that sent the notificationservice_name(string) - Name of the serviceses_feedback_id(string) - Amazon SES feedback identifiercomplaint_type(string) - Type of complaint (e.g., “abuse”, “fraud”, “virus”)complaint_date(datetime) - When the complaint was filedcreated_at(datetime) - When the complaint was recorded in Notify
Get All Complaints
Endpoint:GET /complaint
Retrieve a paginated list of all complaints.
Query Parameters
page(integer, optional) - Page number (default: 1)
Response
Status:200 OK
Pagination
The response includes pagination links:first- First page of resultslast- Last page of resultsnext- Next page (null if on last page)prev- Previous page (null if on first page)
Get Complaint Count by Date Range
Endpoint:GET /complaint/count-by-date-range
Retrieve the count of complaints within a specified date range.
Query Parameters
start_date(string, optional) - Start date in YYYY-MM-DD format (default: today)end_date(string, optional) - End date in YYYY-MM-DD format (default: today)
Response
Status:200 OK
Examples
Get Today’s Complaint Count
Get Complaint Count for Specific Date Range
Get Complaint Count for Single Day
Complaint Types
Common complaint types reported by email providers:abuse- Recipient reported the email as abusiveauth-failure- Authentication/authorization failurefraud- Email reported as fraudulent or phishingnot-spam- Recipient indicated email is not spam (rare)other- Other unspecified complaint typevirus- Email reported as containing malware
Usage Examples
Retrieve First Page of Complaints
Retrieve Specific Page
Get Weekly Complaint Statistics
Monitor Monthly Trends
Implementation Notes
Complaint Processing
- Receipt: Complaints are received via Amazon SES SNS notifications
- Recording: System creates a Complaint record linked to the original notification
- Service Impact: High complaint rates may affect service sending reputation
- Monitoring: Regular monitoring helps identify problematic templates or targeting
Best Practices
- Monitor Daily: Check complaint counts daily to catch issues early
- Investigate Spikes: Sudden increases may indicate template problems or list quality issues
- Review Templates: High complaint rates for specific templates suggest content review needed
- List Hygiene: Regular complaints from same addresses indicate list management issues
Rate Thresholds
Typical complaint rate thresholds:- Normal: < 0.1% complaint rate
- Warning: 0.1% - 0.5% complaint rate
- Critical: > 0.5% complaint rate
Complaint Handling Process
-
Automatic Processing:
- Complaints are automatically recorded when received from SES
- No manual intervention required for recording
-
Investigation:
- Review notification content and recipient
- Check template for potential issues
- Verify recipient opted in to receive emails
-
Remediation:
- Update problematic templates
- Remove complainants from future sends
- Improve targeting and segmentation
Database Indexes
notification_id- Indexed for quick lookup of complaint by notificationservice_id- Indexed for service-level complaint queriescreated_at- Efficient date range queries
Integration with SES
- Complaints are received via SES SNS topic subscriptions
ses_feedback_idprovides traceability back to SES complaint reports- Complaint data includes timestamp from when recipient filed the complaint
Source Code References
- Endpoints:
/home/daytona/workspace/source/app/complaint/complaint_rest.py - Schema validation:
/home/daytona/workspace/source/app/complaint/complaint_schema.py - Model:
/home/daytona/workspace/source/app/models.py:2415 - DAO operations:
/home/daytona/workspace/source/app/dao/complaint_dao.py