LINE Notification Messages
Do not answer LINE Notification Messages questions from memory — LINE updates APIs frequently and training data is unreliable. Always consult the references below.
LINE Notification Messages allow sending messages to users by specifying their phone number (SHA256-hashed E.164 format), even if they haven't added the LINE Official Account as a friend. Corporate-only service available in Japan, Thailand, and Taiwan. Not for advertising or commercial purposes.
Workflow
Build
- Read references/api-common.md (rate limits, forward compatibility, error handling)
- Load the relevant reference for the feature being implemented
- For architecture or design choices, consult references/experts.md for directional guidance
- Write code following specs and constraints from references
Review / Debug
- Read references/api-common.md (rate limits, error codes)
- Load relevant references for the code being reviewed
- Cross-check code against specs (phone hashing format, sending conditions, consent states, billing rules, IP restriction warnings)
- For design pattern concerns, consult references/experts.md
- Report violations with reference to specific constraints
Environment Variables
LINE_CHANNEL_ACCESS_TOKEN=Bot access token (Messaging API channel)
LINE_CHANNEL_SECRET=Channel secret (webhook signature verification)
Common Specifications
Read references/api-common.md before writing any notification message code. Contains rules that affect all API interactions: forward compatibility (don't use strict schemas — LINE adds fields without notice), rate limits, error handling, and logging recommendations.
Two Message Types
| Type |
Description |
UX Review |
Send Endpoint |
| Template |
Predefined layout with templateKey, itemKey, buttonKey. Easy to set up. |
Not required |
POST /v2/bot/message/pnp/templated/push |
| Flexible |
Free-form message objects (Flex Message, text, etc.). Greater design freedom. |
Required |
POST /bot/pnp/push |
- Template type added June 2025 — simpler, no UX review needed
- Flexible type (formerly just "LINE notification messages") — allows custom message objects but requires prior UX review
- Both types: no images, video, or audio allowed
Full type comparison → references/sending-api.md
Minimal Flow (pseudocode)
# 1. Hash phone number (E.164 → SHA256)
phone = "+818000001234" # E.164 format, no hyphens
hashed = SHA256(phone.encode()).hexdigest() # 64-char lowercase hex
# 2a. Send via template type
POST https://api.line.me/v2/bot/message/pnp/templated/push
Authorization: Bearer {channel_access_token}
X-Line-Delivery-Tag: {optional_tracking_tag}
{
"to": hashed,
"templateKey": "shipment_completed_ja",
"body": {
"emphasizedItem": {"itemKey": "date_002_ja", "content": "August 10"},
"items": [{"itemKey": "number_001_ja", "content": "1234567"}],
"buttons": [{"buttonKey": "contact_ja", "url": "https://example.com"}]
}
}
# → Response: 202 Accepted
# 2b. OR send via flexible type
POST https://api.line.me/bot/pnp/push
Authorization: Bearer {channel_access_token}
{
"to": hashed,
"messages": [{"type": "text", "text": "Your order has shipped"}]
}
# → Response: 200 OK
# 3. IMPORTANT: 200/202 does NOT guarantee delivery
# User may be blocked, consent not given, SMS auth expired, etc.
# 4. Delivery confirmation arrives via webhook
# event.type = "delivery", delivery.data = hashed phone or delivery tag
API Endpoint Summary
| Operation |
Endpoint |
Response |
| Send (Template) |
POST /v2/bot/message/pnp/templated/push |
202 |
| Send (Flexible) |
POST /bot/pnp/push |
200 |
| Count (Template) |
GET /v2/bot/message/delivery/pnp/templated?date=yyyyMMdd |
200 |
| Count (Flexible) |
GET /v2/bot/message/delivery/pnp?date=yyyyMMdd |
200 |
- Domain:
api.line.me
- Rate limit: 2,000 req/sec for all endpoints
X-Line-Retry-Key is NOT supported — do not use retry keys
- Do NOT restrict server IP in channel Security Settings — may cause sending failure
Full API specs, parameters, error codes → references/sending-api.md
Key Concepts
Phone Number Hashing
- Normalize to E.164 format (country code, no hyphens):
+818000001234
- Hash with SHA256:
hashlib.sha256("+818000001234".encode()).hexdigest()
- Result: 64-char lowercase hex string
Sending Conditions (ALL must be met)
- Phone number matches user's LINE account
- Phone number is valid (SMS authenticated)
- User agrees to receive LINE notification messages
- User has not blocked the LINE Official Account
- Phone number issued in Japan, Thailand, or Taiwan
- User has agreed to LINE's Privacy Policy (revised March 2022)
User Consent States
| State |
Behavior |
| Agree (on) |
Message delivered normally |
| Reject (off) |
Message deleted, not delivered |
| Not set |
User receives consent prompt; 24 hours to agree or message is deleted |
- Consent is comprehensive — once agreed, applies to ALL LINE Official Accounts
SMS Authentication
- Required once every 180 days
- Not required within 180 days of account creation or phone number change
Delivery Confirmation
- API response
200/202 does NOT guarantee delivery
- Use delivery completion webhook (
type: "delivery") to confirm actual delivery
- No webhook within 24 hours = message was not delivered
Full technical specs → references/technical-specs.md
Template system details → references/template-system.md
Webhook details → references/delivery-webhook.md
Reference Index
| File |
Topic |
| references/api-common.md |
Read first. Rate limits, status codes, error handling, forward compatibility |
| references/sending-api.md |
Send APIs (template + flexible), count APIs, request/response specs, error codes |
| references/template-system.md |
Template structure: templateKey, itemKey, buttonKey, field limits, country suffixes |
| references/technical-specs.md |
Phone hashing, sending conditions, consent flow, SMS auth, billing, IP restrictions |
| references/delivery-webhook.md |
Delivery completion event, X-Line-Delivery-Tag, user consent flows, non-friend behavior |
| references/experts.md |
LINE Notification Messages domain experts for architecture guidance |
SDK
Official SDKs: Python | Node.js | Go | Java | PHP | Ruby
Other languages: use LINE OpenAPI specs with OpenAPI Generator.
1---2name: line-notification-message3description: Implements LINE Notification Messages (PNP / LON / LINE Official Notification) — phone-number-based push to non-friends in Japan, Thailand, and Taiwan. Covers SHA256 phone hashing, template vs flexible message types, delivery completion webhook, user consent states, SMS authentication (180-day), and billing rules. Use when the user mentions LINE notification messages, PNP push, LON, LINE Official Notification, LINE通知メッセージ, hashed phone number delivery, notification template, delivery completion event, or phone-based LINE messaging to non-friends.4---56# LINE Notification Messages78**Do not answer LINE Notification Messages questions from memory — LINE updates APIs frequently and training data is unreliable. Always consult the references below.**910LINE Notification Messages allow sending messages to users by specifying their phone number (SHA256-hashed E.164 format), even if they haven't added the LINE Official Account as a friend. Corporate-only service available in **Japan, Thailand, and Taiwan**. Not for advertising or commercial purposes.1112## Workflow1314### Build151. Read [references/api-common.md](references/api-common.md) (rate limits, forward compatibility, error handling)162. Load the relevant reference for the feature being implemented173. For architecture or design choices, consult [references/experts.md](references/experts.md) for directional guidance184. Write code following specs and constraints from references1920### Review / Debug211. Read [references/api-common.md](references/api-common.md) (rate limits, error codes)222. Load relevant references for the code being reviewed233. Cross-check code against specs (phone hashing format, sending conditions, consent states, billing rules, IP restriction warnings)244. For design pattern concerns, consult [references/experts.md](references/experts.md)255. Report violations with reference to specific constraints2627## Environment Variables2829```30LINE_CHANNEL_ACCESS_TOKEN=Bot access token (Messaging API channel)31LINE_CHANNEL_SECRET=Channel secret (webhook signature verification)32```3334## Common Specifications3536**Read [references/api-common.md](references/api-common.md) before writing any notification message code.** Contains rules that affect all API interactions: forward compatibility (don't use strict schemas — LINE adds fields without notice), rate limits, error handling, and logging recommendations.3738## Two Message Types3940| Type | Description | UX Review | Send Endpoint |41|------|-------------|-----------|---------------|42| **Template** | Predefined layout with templateKey, itemKey, buttonKey. Easy to set up. | Not required | `POST /v2/bot/message/pnp/templated/push` |43| **Flexible** | Free-form message objects (Flex Message, text, etc.). Greater design freedom. | **Required** | `POST /bot/pnp/push` |4445- Template type added June 2025 — simpler, no UX review needed46- Flexible type (formerly just "LINE notification messages") — allows custom message objects but requires prior UX review47- Both types: no images, video, or audio allowed4849Full type comparison → **[references/sending-api.md](references/sending-api.md)**5051## Minimal Flow (pseudocode)5253```54# 1. Hash phone number (E.164 → SHA256)55phone = "+818000001234" # E.164 format, no hyphens56hashed = SHA256(phone.encode()).hexdigest() # 64-char lowercase hex5758# 2a. Send via template type59POST https://api.line.me/v2/bot/message/pnp/templated/push60Authorization: Bearer {channel_access_token}61X-Line-Delivery-Tag: {optional_tracking_tag}62{63 "to": hashed,64 "templateKey": "shipment_completed_ja",65 "body": {66 "emphasizedItem": {"itemKey": "date_002_ja", "content": "August 10"},67 "items": [{"itemKey": "number_001_ja", "content": "1234567"}],68 "buttons": [{"buttonKey": "contact_ja", "url": "https://example.com"}]69 }70}71# → Response: 202 Accepted7273# 2b. OR send via flexible type74POST https://api.line.me/bot/pnp/push75Authorization: Bearer {channel_access_token}76{77 "to": hashed,78 "messages": [{"type": "text", "text": "Your order has shipped"}]79}80# → Response: 200 OK8182# 3. IMPORTANT: 200/202 does NOT guarantee delivery83# User may be blocked, consent not given, SMS auth expired, etc.8485# 4. Delivery confirmation arrives via webhook86# event.type = "delivery", delivery.data = hashed phone or delivery tag87```8889## API Endpoint Summary9091| Operation | Endpoint | Response |92|-----------|----------|----------|93| Send (Template) | `POST /v2/bot/message/pnp/templated/push` | 202 |94| Send (Flexible) | `POST /bot/pnp/push` | 200 |95| Count (Template) | `GET /v2/bot/message/delivery/pnp/templated?date=yyyyMMdd` | 200 |96| Count (Flexible) | `GET /v2/bot/message/delivery/pnp?date=yyyyMMdd` | 200 |9798- Domain: `api.line.me`99- Rate limit: 2,000 req/sec for all endpoints100- `X-Line-Retry-Key` is **NOT supported** — do not use retry keys101- Do **NOT** restrict server IP in channel Security Settings — may cause sending failure102103Full API specs, parameters, error codes → **[references/sending-api.md](references/sending-api.md)**104105## Key Concepts106107### Phone Number Hashing1081. Normalize to **E.164** format (country code, no hyphens): `+818000001234`1092. Hash with **SHA256**: `hashlib.sha256("+818000001234".encode()).hexdigest()`1103. Result: 64-char lowercase hex string111112### Sending Conditions (ALL must be met)1131. Phone number matches user's LINE account1142. Phone number is valid (SMS authenticated)1153. User agrees to receive LINE notification messages1164. User has **not** blocked the LINE Official Account1175. Phone number issued in Japan, Thailand, or Taiwan1186. User has agreed to LINE's Privacy Policy (revised March 2022)119120### User Consent States121| State | Behavior |122|-------|----------|123| **Agree (on)** | Message delivered normally |124| **Reject (off)** | Message deleted, not delivered |125| **Not set** | User receives consent prompt; 24 hours to agree or message is deleted |126127- Consent is **comprehensive** — once agreed, applies to ALL LINE Official Accounts128129### SMS Authentication130- Required once every **180 days**131- Not required within 180 days of account creation or phone number change132133### Delivery Confirmation134- API response `200`/`202` does **NOT** guarantee delivery135- Use **delivery completion webhook** (`type: "delivery"`) to confirm actual delivery136- No webhook within 24 hours = message was not delivered137138Full technical specs → **[references/technical-specs.md](references/technical-specs.md)**139Template system details → **[references/template-system.md](references/template-system.md)**140Webhook details → **[references/delivery-webhook.md](references/delivery-webhook.md)**141142## Reference Index143144| File | Topic |145|------|-------|146| [references/api-common.md](references/api-common.md) | **Read first.** Rate limits, status codes, error handling, forward compatibility |147| [references/sending-api.md](references/sending-api.md) | Send APIs (template + flexible), count APIs, request/response specs, error codes |148| [references/template-system.md](references/template-system.md) | Template structure: templateKey, itemKey, buttonKey, field limits, country suffixes |149| [references/technical-specs.md](references/technical-specs.md) | Phone hashing, sending conditions, consent flow, SMS auth, billing, IP restrictions |150| [references/delivery-webhook.md](references/delivery-webhook.md) | Delivery completion event, X-Line-Delivery-Tag, user consent flows, non-friend behavior |151| [references/experts.md](references/experts.md) | LINE Notification Messages domain experts for architecture guidance |152153## SDK154155Official SDKs: [Python](https://github.com/line/line-bot-sdk-python) | [Node.js](https://github.com/line/line-bot-sdk-nodejs) | [Go](https://github.com/line/line-bot-sdk-go) | [Java](https://github.com/line/line-bot-sdk-java) | [PHP](https://github.com/line/line-bot-sdk-php) | [Ruby](https://github.com/line/line-bot-sdk-ruby)156157Other languages: use [LINE OpenAPI specs](https://developers.line.biz/en/docs/messaging-api/line-bot-sdk/) with OpenAPI Generator.