Privacy & Newsletter API
Complete GDPR-compliant API documentation for cookie consent and newsletter management
Cookie Consent Management
POSTSave Cookie Consent
Save user's cookie consent preferences with automatic GDPR compliance tracking.
Endpoint
POST /api/cookies/consentsContent-Type
application/jsonRequest Body
{
"consent": {
"necessary": true,
"analytics": false,
"marketing": false,
"preferences": true,
"version": "1.0"
}
}Response (200)
{
"message": "Consent preferences saved successfully",
"consent": {
"necessary": true,
"analytics": false,
"marketing": false,
"preferences": true,
"timestamp": 1697234567890,
"version": "1.0"
}
}GETGet Cookie Consent
Retrieve current cookie consent preferences for the user.
Endpoint
GET /api/cookies/consentsResponse (200)
{
"consent": {
"necessary": true,
"analytics": true,
"marketing": false,
"preferences": true,
"timestamp": 1697234567890,
"version": "1.0"
}
}GETCookie Statistics
Get aggregated statistics about cookie consent rates and trends.
Endpoint
GET /api/cookies/statsResponse (200)
{
"message": "Cookie statistics retrieved successfully",
"data": {
"totalConsents": 1250,
"acceptanceRates": {
"necessary": 100,
"analytics": 68.5,
"marketing": 45.2,
"preferences": 72.8
},
"dailyStats": [...],
"topCountries": [...]
}
}Newsletter Management
POSTSubscribe to Newsletter
Subscribe user to newsletter with category preferences and frequency settings.
Endpoint
POST /api/newsletter/subscribeRequest Body
{
"email": "user@example.com",
"categories": ["development", "tutorials"],
"frequency": "weekly"
}Available Categories
developmenttutorialsprojectsindustry
Frequency Options
dailyweeklymonthly
GETGet Subscription
Retrieve newsletter subscription details for a specific email.
Endpoint
GET /api/newsletter?email=user@example.comIntegration Guide
Quick Setup
1. Install the Components
import {
PrivacyManager,
CookieBanner,
NewsletterSignup
} from '@/components/privacy';2. Wrap Your App
function App({ children }) {
return (
<PrivacyManager>
{children}
</PrivacyManager>
);
}3. Add Newsletter Component
<NewsletterSignup variant="compact" />
GDPR Compliance
🔒 Data Protection
- • Automatic consent expiration (6 months)
- • User identification via IP + User-Agent
- • Cookie cleanup on consent changes
- • Right to be forgotten implementation
📊 Audit Trail
- • Timestamped consent records
- • Version tracking for consent changes
- • User agent and IP logging
- • Export functionality for compliance