ข้ามไปยังเนื้อหา

การอ้างอิงเพย์โหลดอีเมล

การอ้างอิงสำหรับข้อความ EmailPayload ที่ใช้โดย Notify เมื่อส่งอีเมล

EmailPayload

Anchor link to
  • subject (map<string, string>): บรรทัดหัวเรื่องที่กำหนดโดย locale เช่น {"en": "Hello!", "es": "¡Hola!"}
  • body (string): เนื้อหา HTML ของอีเมล สำหรับเนื้อหา HTML ตามแต่ละ locale ให้ใช้ email_template กับ Email Template ที่กำหนดค่าไว้ใน Control Panel
  • attachments (array of Attachment): ไฟล์แนบ
  • list_unsubscribe (string): URL ที่กำหนดเองสำหรับเฮดเดอร์ List-Unsubscribe
  • from (Address): แทนที่ค่า From เริ่มต้นที่กำหนดค่าไว้ในการตั้งค่าอีเมลของแอป
  • reply_to (Address): แทนที่ค่า Reply-To เริ่มต้นที่กำหนดค่าไว้ในการตั้งค่าอีเมลของแอป
  • email_template (string): รหัสของ Email Template ที่จะใช้แทน body แบบอินไลน์

Attachment

Anchor link to
{
"name": "invoice.pdf",
"content": "<base64-encoded bytes>"
}
ฟิลด์ประเภทคำอธิบาย
namestringชื่อไฟล์ตามที่ผู้รับเห็น
contentstringเนื้อหาไฟล์ที่เข้ารหัสแบบ Base64
{
"name": "Pushwoosh",
"email": "support@example.com"
}

ทั้งสองฟิลด์เป็นทางเลือก หากไม่ระบุ name ผู้รับจะเห็นที่อยู่อีเมลโดยตรง

ตัวอย่าง: ส่งอีเมลไปยัง segment

Anchor link to
Terminal window
curl -X POST https://api.pushwoosh.com/messaging/v2/notify \
-H "Authorization: Token YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"segment": {
"application": "XXXXX-XXXXX",
"platforms": ["EMAIL"],
"code": "newsletter_subscribers",
"email_payload": {
"subject": { "en": "Our May updates", "es": "Novedades de mayo" },
"email_template": "may-digest-2026",
"from": { "name": "Pushwoosh Team", "email": "news@example.com" },
"reply_to": { "email": "replies@example.com" }
},
"schedule": { "at": "2026-05-01T09:00:00Z" },
"message_type": "MESSAGE_TYPE_MARKETING"
}
}'

ตัวอย่าง: อีเมลธุรกรรมพร้อมไฟล์แนบ

Anchor link to
Terminal window
curl -X POST https://api.pushwoosh.com/messaging/v2/notify \
-H "Authorization: Token YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"transactional": {
"application": "XXXXX-XXXXX",
"platforms": ["EMAIL"],
"users": { "list": ["customer-42"] },
"email_payload": {
"subject": { "en": "Your invoice" },
"body": "<p>Please find your invoice attached.</p>",
"attachments": [
{ "name": "invoice.pdf", "content": "JVBERi0xLjQKJe..." }
]
},
"schedule": { "at": "2026-05-01T12:00:00Z" },
"message_type": "MESSAGE_TYPE_TRANSACTIONAL"
}
}'