Skip to main content

Notification API

Complete API reference for sending notifications and managing notification preferences.

Base Endpoint

/api/v1/notifications

Send Notification

Send a push notification to one or more customers.

POST /api/v1/notifications/send

Request Body

{
"customer_ids": ["cus_12345", "cus_67890"],
"title": "Special Offer",
"body": "Get 20% off your next purchase!",
"image": "https://...",
"action_url": "https://...",
"channel": "wechat_mini_program",
"priority": "high",
"schedule_at": "2024-01-20T15:00:00Z"
}

Example Response

{
"data": {
"notification_id": "notif_123",
"status": "scheduled",
"total_recipients": 2,
"scheduled_at": "2024-01-20T15:00:00Z"
}
}

Send to Segment

Send notification to a customer segment.

POST /api/v1/notifications/send-to-segment

Request Body

{
"segment_id": "seg_123",
"title": "Exclusive Offer for Gold Members",
"body": "Special promotion just for you!",
"channel": "wechat_mini_program"
}

Get Notification Status

Get notification delivery status.

GET /api/v1/notifications/{notification_id}

Example Response

{
"data": {
"id": "notif_123",
"title": "Special Offer",
"body": "Get 20% off your next purchase!",
"status": "completed",
"total_recipients": 1000,
"delivered": 950,
"failed": 50,
"opened": 450,
"clicked": 200,
"created_at": "2024-01-20T15:00:00Z",
"sent_at": "2024-01-20T15:00:01Z",
"completed_at": "2024-01-20T15:05:00Z"
}
}

List Notifications

Get list of sent notifications.

GET /api/v1/notifications

Query Parameters

ParameterTypeDescription
statusstringFilter by status
channelstringFilter by channel
date_fromstringFilter from date
date_tostringFilter to date
pageintegerPage number
limitintegerItems per page

Customer Notification Preferences

Get Customer Preferences

Get notification preferences for a customer.

GET /api/v1/customers/{customer_id}/notifications/preferences

Example Response

{
"data": {
"customer_id": "cus_12345",
"channels": {
"wechat": true,
"sms": false,
"email": true
},
"categories": {
"promotions": true,
"loyalty": true,
"transactions": true,
"campaigns": true
},
"quiet_hours": {
"enabled": true,
"start": "22:00",
"end": "08:00"
}
}
}

Update Customer Preferences

Update notification preferences.

PATCH /api/v1/customers/{customer_id}/notifications/preferences

Request Body

{
"channels": {
"wechat": true,
"sms": false
},
"categories": {
"promotions": true,
"loyalty": false
},
"quiet_hours": {
"enabled": true,
"start": "22:00",
"end": "08:00"
}
}

Notification Templates

List Templates

Get notification templates.

GET /api/v1/notifications/templates

Create Template

Create a notification template.

POST /api/v1/notifications/templates

Request Body

{
"name": "Welcome Message",
"title": "Welcome to SBM CRM!",
"body": "Hi {{customer_name}}, welcome! You've earned {{points}} points.",
"channel": "wechat_mini_program",
"variables": ["customer_name", "points"]
}