Notification
Base URL: https://notification-api.pcampus.co
Overview
Notification is a centralized notification hub for every service in the Pcampus ecosystem. Instead of each service sending its own notifications, everything flows through a single Notification service — making it easy to manage templates, delivery, and analytics from one place.
Supported channels: Email, Push notifications, SMS, LINE
Who uses this
| Persona | What They Do |
|---|---|
| Developer (internal service) | Call the API to send notifications from Cockpit / Content OS / Billing |
| Developer (customer) | Send notifications to their own users via the API |
| Admin | Manage templates, view delivery analytics |
| End user | Receive notifications, manage notification preferences |
Key features
- Multi-channel delivery — Email, Push, SMS, LINE from a single API
- Template management — Create templates with variable substitution (
{{user.name}},{{booking.date}}) - Notification preferences — Users can choose which channels they want to receive notifications on
- Delivery tracking — Track sent / delivered / opened / failed per notification
- Retry & fallback — If SMS fails, automatically falls back to Email
- Rate limiting — Prevent sending too many notifications to a single user
User stories
Internal service (Billing):
"When a payment succeeds, we need to notify the org admin immediately via Email"
→ POST /notifications/send — specify channel: email, templateId: payment-success, userId → send immediately
Developer (customer):
"I want to send a push notification to users in my app when a new order arrives"
→ Register application → create template → call the API to send push with payload
End user:
"I'd like to receive notifications via LINE instead of SMS"
→ Console → Notification Settings → select LINE → connect LINE account
How it works
Data model
Integration
- PIP — Fetches user preferences and contact info (email, phone, LINE ID)
- Mail — Uses the Mail service for email delivery (does not send email directly)
- Other services — Receive events and send notifications according to templates
API overview
| Method | Endpoint | Description |
|---|---|---|
POST | /notifications/send | Send notification to user |
POST | /notifications/broadcast | Send to multiple users |
GET | /notifications | List notification history |
GET | /notifications/:id | Get delivery status |
GET | /templates | List templates |
POST | /templates | Create template |
PATCH | /templates/:id | Update template |
DELETE | /templates/:id | Delete template |
GET | /preferences/:userId | Get user notification preferences |
PATCH | /preferences/:userId | Update preferences |
Send notification payload
{
"userId": "usr_xxxx",
"templateId": "tmpl_xxxx",
"channel": "email",
"data": {
"user": { "name": "Somchai" },
"booking": { "id": "BK-001", "date": "2026-08-01" }
}
}LINE Flex Message Templates
LINE Flex Message is LINE's rich message format with JSON-defined layouts — supports card, carousel, image hero, button, and separator elements freely.
Notification supports the flex_message template type in addition to plain text. Variable slots use the same {{variableName}} syntax — the system substitutes values into the JSON before sending to LINE.
Template types
| Type | Format | Use case |
|---|---|---|
text | Plain text | General notifications, OTP |
flex_message | JSON Flex layout | Product card, order summary, appointment reminder |
image_map | Image with tap zones | Promotional banners |
carousel | Swipeable Flex | Multiple products, multiple branches |
Flex Message Template Example — Order Card
{
"type": "flex",
"altText": "ยืนยันคำสั่งซื้อ {{orderId}}",
"contents": {
"type": "bubble",
"hero": {
"type": "image",
"url": "{{productImageUrl}}",
"size": "full",
"aspectRatio": "20:13",
"aspectMode": "cover"
},
"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": "vertical",
"margin": "md",
"contents": [
{
"type": "box",
"layout": "horizontal",
"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": "{{orderDetailUrl}}"
}
}
]
}
}
}Variable slots in this example: customerName, orderId, productImageUrl, productName, total, orderDetailUrl
Flex Message Builder (Console)
In Pcampus Console → Notification → Templates → New Template → select Flex Message:
Steps:
- Choose a starting layout — Bubble, Carousel, Image Hero, Receipt
- Edit blocks — click a block to change text, color, size, button URL
- Insert variables — type
{{to autocomplete variables suggested from the Customer Story - Preview — view on the LINE emulator for both Android / iOS
- Save and Test send — send a test to a real LINE account before publishing
The builder in Console uses the same LINE Flex Message Simulator as LINE Official — the generated JSON can be copied directly into the Flex Message Simulator (opens in a new tab) for testing.
Carousel template
Carousel is a collection of swipeable bubbles, ideal for multi-product, multi-branch use cases:
{
"type": "flex",
"altText": "สินค้าแนะนำสำหรับคุณ {{customerName}}",
"contents": {
"type": "carousel",
"contents": [
"{{#each recommendations}}",
{
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{ "type": "text", "text": "{{this.name}}", "weight": "bold" },
{ "type": "text", "text": "{{this.price}}", "color": "#1DB446" }
]
}
},
"{{/each}}"
]
}
}
{{#each recommendations}}/{{/each}}is the loop syntax for array variables — supported in Flex Message templates only
Broadcast Scheduler
The Notification Scheduler manages scheduled broadcasts across all channels (LINE, Push, SMS) — viewable and creatable from a single calendar view.
Console → Notification → Scheduler
Calendar view
Shows all scheduled broadcasts from every channel in a single calendar, filterable by channel / segment / status:
┌─────────────────────────────────────────────────────────────┐
│ 📅 Notification Scheduler — กรกฎาคม 2026 │
│ [+ New Broadcast] [All Channels ▼] [List] [Calendar] │
├──────────┬──────────┬──────────┬──────────┬────────────────┤
│ จ 14 │ อ 15 │ พ 16 │ พฤ 17 │ ศ 18 │
├──────────┼──────────┼──────────┼──────────┼────────────────┤
│ │ 09:00 │ 14:00 │ 10:00 │ │
│ │ 📱 LINE │ 🔔 Push │ 📱 LINE │ │
│ │ Winback │ Flash │ Loyalty │ │
│ │ 3,241 คน │ 8,002 คน │ 1,532 คน │ │
│ │ │ Sale │ Tier Up │ │
└──────────┴──────────┴──────────┴──────────┴────────────────┘Create a Scheduled Broadcast
- + New Broadcast → select channel: LINE | Push | SMS
- Choose a template — text or Flex Message
- Define recipients — segment, subscriber list, or customer ID list
- Set schedule — date + time, or recurrence (daily / weekly / monthly)
- Set rate limit — messages per minute, to prevent burst traffic
- Confirm → appears on the calendar immediately; editable / cancellable up to 5 minutes before send
Recurrence patterns
| Pattern | Cron | Example use |
|---|---|---|
| Every day 08:00 | 0 8 * * * | Daily order reminder |
| Every Monday | 0 9 * * 1 | Weekly loyalty summary |
| 1st of every month | 0 10 1 * * | Monthly points digest |
| Every Friday afternoon | 0 14 * * 5 | Flash sale LINE |
Delivery window
Set a delivery window to avoid disturbing customers outside business hours:
{
"deliveryWindow": {
"start": "08:00",
"end": "21:00",
"timezone": "Asia/Bangkok",
"skipWeekends": false
}
}If a broadcast triggers outside the window, the system will hold it and send when the next window begins.
See Notification API → Scheduler for REST endpoints