Notification API
Base URL: https://notification-api.pcampus.co
Send Notification
POST /v1/notifications/send
Send a notification to a single recipient.
POST https://notification-api.pcampus.co/v1/notifications/send
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"channel": "line",
"recipientId": "cust_001",
"templateId": "tmpl_winback",
"variables": {
"customerName": "สมชาย",
"productName": "Amlodipine 5mg",
"couponCode": "WINBACK10"
}
}channel options: line | push | sms | email (email delegates to the Mail service)
Response:
{
"notificationId": "ntf_xxx",
"channel": "line",
"recipientId": "cust_001",
"status": "sent",
"sentAt": "2026-07-15T10:00:00.000Z"
}POST /v1/notifications/batch
Send notifications to multiple recipients simultaneously (segment blast).
POST https://notification-api.pcampus.co/v1/notifications/batch
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"channel": "line",
"recipientIds": ["cust_001", "cust_002", "cust_003"],
"templateId": "tmpl_monthly_promo",
"variables": {
"month": "กรกฎาคม",
"discount": "15%"
},
"scheduledAt": "2026-07-16T09:00:00.000Z"
}Response:
{
"batchId": "bat_xxx",
"recipientCount": 3,
"status": "scheduled",
"scheduledAt": "2026-07-16T09:00:00.000Z"
}Delivery Status
GET /v1/notifications/:notificationId
GET https://notification-api.pcampus.co/v1/notifications/ntf_xxx
Authorization: Bearer <pip_api_key>Response:
{
"notificationId": "ntf_xxx",
"channel": "line",
"status": "delivered",
"sentAt": "2026-07-15T10:00:00.000Z",
"deliveredAt": "2026-07-15T10:00:03.000Z",
"attempts": 1
}Status values: queued | sent | delivered | failed | bounced
Templates
GET /v1/templates
GET https://notification-api.pcampus.co/v1/templates
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idPOST /v1/templates — Text
POST https://notification-api.pcampus.co/v1/templates
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"templateId": "tmpl_winback",
"name": "Win-back Campaign",
"channel": "line",
"type": "text",
"body": "สวัสดีครับ {{customerName}} เราคิดถึงนะครับ {{productName}} ใกล้หมดรึยัง? ใช้โค้ด {{couponCode}} รับส่วนลด 10% ครับ",
"variables": ["customerName", "productName", "couponCode"]
}POST /v1/templates — Flex Message
Send type: "flex_message" with Flex JSON in flexContent:
POST https://notification-api.pcampus.co/v1/templates
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"templateId": "tmpl_order_card",
"name": "Order Confirmation Card",
"channel": "line",
"type": "flex_message",
"altText": "ยืนยันคำสั่งซื้อ #{{orderId}}",
"flexContent": {
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{ "type": "text", "text": "สวัสดีครับ {{customerName}}", "weight": "bold", "size": "xl" },
{ "type": "text", "text": "คำสั่งซื้อ #{{orderId}}", "color": "#aaaaaa", "size": "sm" },
{ "type": "separator", "margin": "md" },
{
"type": "box", "layout": "horizontal", "margin": "md",
"contents": [
{ "type": "text", "text": "{{productName}}", "size": "sm", "flex": 3 },
{ "type": "text", "text": "{{total}}", "size": "sm", "align": "end" }
]
}
]
},
"footer": {
"type": "box", "layout": "vertical",
"contents": [
{
"type": "button", "style": "primary",
"action": { "type": "uri", "label": "ดูรายละเอียด", "uri": "{{orderUrl}}" }
}
]
}
},
"variables": ["customerName", "orderId", "productName", "total", "orderUrl"]
}At send time, the system traverses the flexContent JSON and replaces every {{variable}} with its real value before delivering to the LINE Messaging API.
POST /v1/templates/:templateId/preview
Preview a template with test variables — the response is Flex JSON with substitutions applied:
POST https://notification-api.pcampus.co/v1/templates/tmpl_order_card/preview
Authorization: Bearer <pip_api_key>
{
"variables": {
"customerName": "สมชาย",
"orderId": "ORD-001",
"productName": "Amlodipine 5mg 30 เม็ด",
"total": "฿180",
"orderUrl": "https://pharmacy-app.co.th/orders/ORD-001"
}
}The response can be tested directly in the LINE Flex Message Simulator (opens in a new tab).
PATCH /v1/templates/:templateId
DELETE /v1/templates/:templateId
Scheduler
Manage scheduled broadcasts — create, list, update, and cancel.
GET /v1/scheduler/broadcasts
List all scheduled broadcasts.
GET https://notification-api.pcampus.co/v1/scheduler/broadcasts?status=scheduled&from=2026-07-01&to=2026-07-31
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-idQuery params:
| Param | Type | Description |
|---|---|---|
status | string | scheduled | sending | sent | cancelled | failed |
channel | string | line | push | sms |
from | date | Start date (ISO 8601) |
to | date | End date |
Response:
{
"data": [
{
"broadcastId": "bcast_xxx",
"name": "VIP Loyalty Tier Up",
"channel": "line",
"templateId": "tmpl_loyalty_tier",
"recipientCount": 1532,
"segmentId": "seg_vip",
"scheduledAt": "2026-07-17T10:00:00.000Z",
"status": "scheduled",
"recurrence": null
},
{
"broadcastId": "bcast_yyy",
"name": "Weekly Winback LINE",
"channel": "line",
"templateId": "tmpl_winback_flex",
"recipientCount": 3241,
"scheduledAt": "2026-07-21T09:00:00.000Z",
"status": "scheduled",
"recurrence": { "cron": "0 9 * * 1", "timezone": "Asia/Bangkok" }
}
]
}POST /v1/scheduler/broadcasts
Create a new scheduled broadcast.
POST https://notification-api.pcampus.co/v1/scheduler/broadcasts
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"name": "Flash Sale LINE Friday",
"channel": "line",
"templateId": "tmpl_flash_sale_flex",
"recipients": {
"type": "segment",
"segmentId": "seg_active_customers"
},
"scheduledAt": "2026-07-18T14:00:00.000Z",
"recurrence": null,
"deliveryWindow": {
"start": "08:00",
"end": "21:00",
"timezone": "Asia/Bangkok"
},
"variables": {
"discountPercent": "20",
"saleEndTime": "18:00 น."
}
}recipients.type options: segment | list | ids
Recurrence broadcast:
{
"scheduledAt": "2026-07-21T09:00:00.000Z",
"recurrence": {
"cron": "0 9 * * 1",
"timezone": "Asia/Bangkok",
"endsAt": "2026-12-31T23:59:59.000Z"
}
}Response:
{
"broadcastId": "bcast_zzz",
"status": "scheduled",
"scheduledAt": "2026-07-18T14:00:00.000Z",
"estimatedRecipients": 8002
}GET /v1/scheduler/broadcasts/:broadcastId
View broadcast detail + delivery stats (if already sent).
PATCH /v1/scheduler/broadcasts/:broadcastId
Edit a scheduled broadcast — changes can be made up to 5 minutes before scheduledAt.
DELETE /v1/scheduler/broadcasts/:broadcastId
Cancel a scheduled broadcast (status → cancelled).
Fallback Chain
If the primary channel fails, the system falls back through the configured chain:
PATCH https://notification-api.pcampus.co/v1/config/fallback
Authorization: Bearer <pip_api_key>
x-tenant-id: your-tenant-id
{
"fallbackChain": ["line", "push", "email"],
"maxAttempts": 3,
"retryDelaySeconds": 60
}