ส่งข้อความ LINE Notify POST
ส่งข้อความ (และรูปภาพแบบไม่บังคับ) ผ่าน LINE Notify token ที่ผูกกับบัญชีของคุณ มีอีก path หนึ่งคือ POST /line/send2 ซึ่งทำงานเหมือนกันทุกอย่าง (คงไว้เพื่อความเข้ากันได้กับระบบเดิม)
WARNING
LINE ยุติบริการ LINE Notify ไปแล้วตั้งแต่ 31 มีนาคม 2025 — endpoint นี้คงไว้เพื่อความเข้ากันได้กับระบบเดิมเท่านั้น การส่งจริงอาจล้มเหลวและได้ status 500 กลับมา ไม่แนะนำให้ใช้กับการเชื่อมต่อใหม่
Authorization
ใช้ API Key (การยืนยันตัวตน) — ส่ง header Authorization: Bearer <API_KEY> (API Key ขึ้นต้นด้วย smsk_)
HTTP Request
http
POST https://public-api.smsup-plus.com/line/sendContent Type
application/json
Parameter Description
| Property | Type | Required | Description |
|---|---|---|---|
tokenId | string | Required | รหัส LINE Notify token ของบัญชีคุณ (ดูได้จาก รายการ LINE token) |
message | string | Required | ข้อความที่ต้องการส่ง |
imageUrl | string | Optional | URL รูปภาพที่จะแนบไปกับข้อความ (ใช้เป็นทั้งภาพย่อและภาพเต็ม) |
Response Description
| Property | Type | Description |
|---|---|---|
status | number | ผลลัพธ์ — 200 เมื่อส่งสำเร็จ (ดูค่าอื่นในตาราง Error) |
description | string | ข้อความอธิบายผลลัพธ์ |
ตัวอย่าง Request
bash
curl -X POST 'https://public-api.smsup-plus.com/line/send' \
-H 'Authorization: Bearer <API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"tokenId": "3f2b8c1e-7a4d-4e9b-9c11-5d6e7f8a9b0c",
"message": "แจ้งเตือน: คำสั่งซื้อ #10023 จัดส่งแล้ว",
"imageUrl": "https://www.example.com/images/shipped.png"
}'js
const res = await fetch('https://public-api.smsup-plus.com/line/send', {
method: 'POST',
headers: { Authorization: 'Bearer <API_KEY>', 'Content-Type': 'application/json' },
body: JSON.stringify({
tokenId: '3f2b8c1e-7a4d-4e9b-9c11-5d6e7f8a9b0c',
message: 'แจ้งเตือน: คำสั่งซื้อ #10023 จัดส่งแล้ว',
imageUrl: 'https://www.example.com/images/shipped.png',
}),
})
console.log(await res.json())ตัวอย่าง Response
json
{
"status": 200,
"description": "LINE notification sent."
}Error ที่อาจเจอ
endpoint นี้ตอบ HTTP 200 เสมอ (ยกเว้น error การยืนยันตัวตน) — ให้ตรวจผลลัพธ์จากฟิลด์ status ใน body
| HTTP | Response | สาเหตุ |
|---|---|---|
| 200 | {"status":400,"description":"tokenId and message are required."} | body ไม่ใช่ JSON หรือไม่ได้ส่ง tokenId / message |
| 200 | {"status":404,"description":"LINE token not found."} | ไม่พบ tokenId นี้ในบัญชีของคุณ |
| 200 | {"status":403,"description":"LINE token is inactive."} | token ถูกปิดใช้งานแล้ว |
| 200 | {"status":500,"description":"Failed to send LINE notification."} | LINE ปฏิเสธหรือส่งไม่สำเร็จ (เช่น token หมดอายุ / บริการ LINE Notify ยุติแล้ว) |
| 200 | {"status":503,"description":"LINE gateway not configured."} | ระบบยังไม่เปิดให้บริการส่ง LINE |
| 200 | {"status":401,"description":"Unauthorized."} | ไม่สามารถระบุบัญชีจากข้อมูลยืนยันตัวตนได้ |
| 401 | {"error":"invalid api key"} | API Key ไม่ถูกต้อง — ดู Error |
