Skip to main content

Notifications API

Configure how and when you receive notifications across email, push, SMS, and in-app channels.

Get Notifications

curl "https://api.affilync.com/api/notifications?limit=50&offset=0" \
-H "Authorization: Bearer YOUR_TOKEN"

Query Parameters:

ParameterTypeDefaultDescription
limitint50Number of notifications to return (1-100)
offsetint0Number of notifications to skip for pagination
unread_onlyboolfalseReturn only unread notifications
notification_typestringFilter by notification type (e.g., commission_earned, payout_processed)

Response (200):

[
{
"id": "notif_abc123",
"type": "commission_earned",
"channel": "in_app",
"title": "Commission Earned",
"message": "You earned $25.00 from Spring Sale campaign",
"priority": "normal",
"status": "sent",
"action_url": "/campaigns/camp_123",
"action_label": "View Campaign",
"entity_type": "campaign",
"entity_id": "camp_123",
"read_at": null,
"created_at": "2026-03-24T10:15:00Z",
"sent_at": "2026-03-24T10:15:01Z",
"metadata": {
"commission_id": "comm_abc123",
"amount": "25.00",
"campaign_name": "Spring Sale"
}
}
]

Get Notification Preferences

curl https://api.affilync.com/api/notifications/preferences \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"email_enabled": true,
"email_frequency": "instant",
"push_enabled": true,
"sms_enabled": false,
"in_app_enabled": true,
"quiet_hours_enabled": false,
"quiet_hours_start": null,
"quiet_hours_end": null,
"quiet_hours_timezone": "UTC",
"dnd_enabled": false,
"dnd_start": null,
"dnd_end": null
}

Update Notification Preferences

curl -X PUT https://api.affilync.com/api/notifications/preferences \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email_enabled": true,
"email_frequency": "daily",
"push_enabled": true,
"quiet_hours_enabled": true,
"quiet_hours_start": "22:00",
"quiet_hours_end": "08:00"
}'

Frequency Values:

  • instant - Send immediately
  • daily - Daily digest
  • weekly - Weekly digest
  • never - Disable notifications

Response (200):

{
"success": true,
"message": "Notification preferences updated successfully",
"preferences": {
"email_enabled": true,
"email_frequency": "daily",
"push_enabled": true,
"sms_enabled": false,
"in_app_enabled": true,
"quiet_hours_enabled": true,
"quiet_hours_start": "22:00",
"quiet_hours_end": "08:00",
"quiet_hours_timezone": "UTC",
"dnd_enabled": false
}
}

Unread Count

Lightweight endpoint for badge counts.

curl https://api.affilync.com/api/notifications/count \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"unread_count": 5
}

Mark as Read

Mark a specific notification as read.

curl -X POST https://api.affilync.com/api/notifications/{notification_id}/read \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"success": true,
"message": "Notification marked as read"
}

Mark All as Read

Mark all notifications as read for the current user.

curl -X POST https://api.affilync.com/api/notifications/read-all \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"success": true,
"message": "Marked 5 notifications as read",
"count": 5
}

Delete Notification

Delete a specific notification.

curl -X DELETE https://api.affilync.com/api/notifications/{notification_id} \
-H "Authorization: Bearer YOUR_TOKEN"

Response (200):

{
"success": true,
"message": "Notification deleted successfully"
}

Send Test Notification

Send a test notification to verify your notification settings.

curl -X POST "https://api.affilync.com/api/notifications/test?channel=email" \
-H "Authorization: Bearer YOUR_TOKEN"

Query Parameters:

ParameterTypeRequiredDescription
channelstringyesNotification channel: email, push, sms, or in_app

Response (200):

{
"success": true,
"message": "Test notification sent via email",
"notification_id": "notif_test123"
}

Notification Types

Affiliate and brand users see different notification types based on their role.

Affiliate Notifications:

TypeDescription
commission_earnedNew commission recorded
commission_approvedCommission approved for payout
commission_deniedCommission denied or disputed
payout_processedPayout completed or failed
campaign_createdNew campaign available to join
campaign_launchedCampaign you're part of is now live
campaign_endedCampaign you're part of has ended
campaign_updatedCampaign details have changed
application_approvedYour campaign application was approved
application_rejectedYour campaign application was rejected
security_alertSecurity alert: new login, 2FA change, suspicious activity

Brand Notifications:

TypeDescription
campaign_createdCampaign you created is live
campaign_launchedCampaign launch event
campaign_endedCampaign ended
campaign_updatedCampaign details changed
payout_processedAffiliate payout completed
application_approvedAffiliate application approved
application_rejectedAffiliate application rejected
security_alertSecurity alert: new login, 2FA change, suspicious activity

Notification Categories

Notifications are organized by category for filtering and user preferences:

CategoryDescription
systemPlatform announcements and system events
campaignCampaign-related notifications
commissionCommission and earnings notifications (affiliates only)
payoutPayment and payout notifications
applicationCampaign application status changes
securitySecurity alerts and authentication events
call_trackingCall tracking notifications
billingBilling and subscription notifications
generalGeneral notifications

Notification Channels

Notifications can be delivered via multiple channels:

ChannelDescription
emailEmail delivery (subject to email preferences)
pushBrowser/mobile push notifications
smsSMS text message (requires phone number)
in_appIn-app notification badge

Admin: Send Notification

Admin only - Send a notification to a specific user.

curl -X POST https://api.affilync.com/api/notifications/admin/send \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user_abc123",
"notification_type": "security_alert",
"channel": "email",
"title": "Security Alert",
"message": "A new login was detected on your account",
"priority": "high",
"action_url": "/settings/security",
"action_label": "Review Activity"
}'

Parameters:

ParameterTypeRequiredDescription
user_idUUIDyesTarget user ID
notification_typestringyesType of notification
channelstringyesDelivery channel (email, push, sms, in_app)
titlestringyesNotification title
messagestringyesNotification message
prioritystringnoPriority level: low, normal, high, urgent (default: normal)
action_urlstringnoOptional action link
action_labelstringnoOptional action button text

Response (200):

{
"success": true,
"message": "Notification sent successfully",
"notification_id": "notif_sent123"
}

Error Responses

Invalid Notification Type (400):

{
"detail": "Invalid notification type: invalid_type"
}

Notification Not Found (404):

{
"detail": "Notification not found or already read"
}

Unauthorized (401):

{
"detail": "Not authenticated"
}

Best Practices

  1. Respect User Preferences - Always check the user's notification settings before sending
  2. Use Categories - Filter notifications by category for better organization
  3. Set Priority Appropriately - Use high/urgent only for critical notifications
  4. Include Action URLs - Provide direct links to relevant resources when possible
  5. Test First - Use the /test endpoint to verify setup before production use
  6. Batch Operations - Mark all as read rather than individual notifications when appropriate