Email API
createEmailMessage
Anchor link toสร้างข้อความอีเมล
POST
https://api.pushwoosh.com/json/1.3/createEmailMessage
พารามิเตอร์ของคำขอ
Anchor link toชื่อ | ประเภท | จำเป็น | คำอธิบาย |
---|---|---|---|
auth | string | ใช่ | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
application | string | ใช่ | รหัสแอปพลิเคชัน Pushwoosh |
notifications | array | ใช่ | อาร์เรย์ JSON ที่มีรายละเอียดข้อความอีเมล ดูตาราง พารามิเตอร์ Notifications ด้านล่าง |
พารามิเตอร์ Notifications
Anchor link toชื่อ | ประเภท | จำเป็น | คำอธิบาย |
---|---|---|---|
send_date | string | ใช่ | กำหนดเวลาที่จะส่งอีเมล รูปแบบ: YYYY-MM-DD HH:mm หรือ "now" |
preset | string | ใช่ | รหัสพรีเซ็ตอีเมล คัดลอกจากแถบ URL ของ Email Content Editor ใน Pushwoosh Control Panel |
subject | string หรือ object | ไม่ | หัวเรื่องของอีเมล อีเมลจะใช้ภาษาเดียวกับเนื้อหาเสมอ หาก subject ไม่มีภาษาที่ตรงกับ content หัวเรื่องจะว่างเปล่า |
content | string หรือ object | ไม่ | เนื้อหาของอีเมล อาจเป็นสตริงสำหรับเนื้อหา HTML ธรรมดา หรืออ็อบเจกต์สำหรับเวอร์ชันที่แปลเป็นภาษาท้องถิ่น |
attachments | array | ไม่ | ไฟล์แนบอีเมล สามารถแนบไฟล์ได้เพียงสองไฟล์เท่านั้น แต่ละไฟล์ต้องมีขนาดไม่เกิน 1MB (เข้ารหัสแบบ base64) |
campaign | string | ไม่ | รหัสแคมเปญเพื่อเชื่อมโยงอีเมลกับแคมเปญที่ระบุ |
ignore_user_timezone | boolean | ไม่ | หากเป็น true จะส่งอีเมลทันทีโดยไม่สนใจไทม์โซนของผู้ใช้ |
timezone | string | ไม่ | ส่งอีเมลตามไทม์โซนของผู้ใช้ ตัวอย่าง: "America/New_York" |
filter | string | ไม่ | ส่งอีเมลไปยังผู้ใช้ที่ตรงกับเงื่อนไขตัวกรองที่ระบุ |
devices | array | ไม่ | รายการที่อยู่อีเมล (สูงสุด 1000) เพื่อส่งอีเมลแบบกำหนดเป้าหมาย หากใช้พารามิเตอร์นี้ ข้อความจะถูกส่งไปยังที่อยู่เหล่านี้เท่านั้น จะถูกละเว้นหากใช้ Application Group |
use_auto_registration | boolean | ไม่ | หากเป็น true จะลงทะเบียนอีเมลจากพารามิเตอร์ devices โดยอัตโนมัติ |
users | array | ไม่ | หากตั้งค่าไว้ ข้อความอีเมลจะถูกส่งไปยัง User ID ที่ระบุเท่านั้น (ลงทะเบียนผ่านการเรียก /registerEmail) ไม่เกิน 1000 User ID ในอาร์เรย์ หากระบุพารามิเตอร์ “devices” พารามิเตอร์ “users” จะถูกละเว้น |
dynamic_content_placeholders | object | ไม่ | ตัวยึดตำแหน่งสำหรับเนื้อหาแบบไดนามิกแทนค่าแท็กของอุปกรณ์ |
conditions | array | ไม่ | เงื่อนไขการแบ่งกลุ่มโดยใช้แท็ก ตัวอย่าง: [["Country", "EQ", "BR"]] |
from | object | ไม่ | ระบุชื่อผู้ส่งและอีเมลที่กำหนดเอง เพื่อแทนที่ค่าเริ่มต้นในคุณสมบัติของแอปพลิเคชัน |
reply-to | object | ไม่ | ระบุอีเมลสำหรับตอบกลับที่กำหนดเอง เพื่อแทนที่ค่าเริ่มต้นในคุณสมบัติของแอปพลิเคชัน |
transactionId | string | ไม่ | ตัวระบุข้อความที่ไม่ซ้ำกันเพื่อป้องกันการส่งซ้ำในกรณีที่เกิดปัญหาเกี่ยวกับเครือข่าย จัดเก็บไว้ที่ฝั่ง Pushwoosh เป็นเวลา 5 นาที |
capping_days | integer | ไม่ | จำนวนวัน (สูงสุด 30) ที่จะใช้การจำกัดความถี่ต่ออุปกรณ์ หมายเหตุ: ตรวจสอบให้แน่ใจว่าได้กำหนดค่า Global frequency capping ใน Control Panel แล้ว |
capping_count | integer | ไม่ | จำนวนอีเมลสูงสุดที่สามารถส่งจากแอปที่ระบุไปยังอุปกรณ์หนึ่งๆ ภายในระยะเวลา capping_days ในกรณีที่ข้อความที่สร้างขึ้นเกินขีดจำกัด capping_count สำหรับอุปกรณ์นั้น ข้อความจะไม่ถูกส่งไปยังอุปกรณ์ดังกล่าว |
capping_exclude | boolean | ไม่ | หากตั้งค่าเป็น true อีเมลนี้จะไม่ถูกนับรวมในการจำกัดความถี่สำหรับอีเมลในอนาคต |
capping_avoid | boolean | ไม่ | หากตั้งค่าเป็น true การจำกัดความถี่จะไม่ถูกนำไปใช้กับอีเมลฉบับนี้โดยเฉพาะ |
ตัวอย่างคำขอ
Anchor link to{ "request": { "auth": "API_ACCESS_TOKEN", // required. API access token from Pushwoosh Control Panel "application": "APPLICATION_CODE", // required. Pushwoosh application code. "notifications": [{ "send_date": "now", // required. YYYY-MM-DD HH:mm OR 'now' "preset": "ERXXX-32XXX", // required. Copy Email preset code from the URL bar of // the Email Content editor page in Pushwoosh Control Panel. "subject": { // optional. Email message subject line. "de": "subject de", "en": "subject en" }, "content": { // optional. Email body content. "de": "<html><body>de Hello, moto</body></html>", "default": "<html><body>default Hello, moto</body></html>" }, "attachments": [{ // optional. Email attachments "name": "image.png", // "name" - file name "content": "iVBANA...AFTkuQmwC" // "content" - base64 encoded content of the file }, { "name": "file.pdf", "content": "JVBERi...AFTarEGC" }], "campaign": "CAMPAIGN_CODE", // optional. To assign this email message to a particular campaign, // add a campaign code here. "ignore_user_timezone": true, // optional. "timezone": "America/New_York", // optional. Specify to send the message according to // timezone set on user's device. "filter": "FILTER_NAME", // optional. Send the message to specific users meeting filter conditions. "devices": [ // optional. Specify email addresses to send targeted email messages. "email_address1", // Not more than 1000 addresses in an array. "email_address2" // If set, the message will only be sent to the addresses on ], // the list. Ignored if the Application Group is used. "use_auto_registration": true, // optional. Automatically register emails specified in "devices" parameter "users": [ // optional. If set, the email message will only be delivered to the "userId1", // specified user IDs (registered via /registerEmail call). "userId2" // Not more than 1000 user IDs in an array. ], // If the "devices" parameter is specified, // the "users" parameter will be ignored. "dynamic_content_placeholders": { // optional. Placeholders for dynamic content instead of device tag values. "firstname": "John", "firstname_en": "John" }, "conditions": [ // optional. Segmentation conditions, see remark below. ["Country", "EQ", "BR"], ["Language", "EQ", "pt"] ], "from": { // optional. Specify a sender name and sender email address "name": "alias from", // to replace the default "From name" and "From email" "email": "from-email@email.com" // set up in application properties. }, "reply-to": { // optional. Specify an email address to replace the "name": "alias reply to ", // default "Reply to" set up in application properties. "email": "reply-to@email.com" }, "transactionId": "unique UUID", // optional. Unique message identifier to prevent re-sending // in case of network problems. Stored on the side // of Pushwoosh for 5 minutes. // Frequency capping params. Ensure that Global frequency capping is configured in the Control Panel. "capping_days": 30, // optional. Amount of days for frequency capping (max 30 days) "capping_count": 10, // optional. The max number of emails that can be sent from a // specific app to a particular device within a 'capping_days' // period. In case the message created exceeds the // 'capping_count' limit for a device, it won't // be sent to that device. "capping_exclude": true, // optional. If set to true, this email will not // be counted towards the capping for future emails. "capping_avoid": true // optional. If set to true, capping will not be applied to // this specific email. }] }}
ตัวอย่างการตอบกลับ
Anchor link to{ "status_code": 200, "status_message": "OK", "response": null}
{ "status_code": 403, "status_message": "Token restrictions forbid this operation", "response": null}
เงื่อนไขของแท็ก
Anchor link toเงื่อนไขของแท็กแต่ละรายการเป็นอาร์เรย์ในรูปแบบ [tagName, operator, operand]
โดยที่
- tagName: ชื่อของแท็ก
- operator: “EQ” | “IN” | “NOTEQ” | “NOTIN” | “LTE” | “GTE” | “BETWEEN”
- operand: สตริง | จำนวนเต็ม | อาร์เรย์ | วันที่
คำอธิบาย Operand
Anchor link to- EQ: ค่าแท็กเท่ากับ operand;
- IN: ค่าแท็กมีส่วนร่วมกับ operand (operand ต้องเป็นอาร์เรย์เสมอ);
- NOTEQ: ค่าแท็กไม่เท่ากับ operand;
- NOTIN: ค่าแท็กไม่มีส่วนร่วมกับ operand (operand ต้องเป็นอาร์เรย์เสมอ);
- GTE: ค่าแท็กมากกว่าหรือเท่ากับ operand;
- LTE: ค่าแท็กน้อยกว่าหรือเท่ากับ operand;
- BETWEEN: ค่าแท็กมากกว่าหรือเท่ากับค่าต่ำสุดของ operand แต่น้อยกว่าหรือเท่ากับค่าสูงสุดของ operand (operand ต้องเป็นอาร์เรย์เสมอ)
แท็กประเภทสตริง
Anchor link toโอเปอเรเตอร์ที่ใช้ได้: EQ, IN, NOTEQ, NOTIN
Operand ที่ใช้ได้:
- EQ, NOTEQ: operand ต้องเป็นสตริง;
- IN, NOTIN: operand ต้องเป็นอาร์เรย์ของสตริง เช่น
["value 1", "value 2", "value N"]
;
แท็กประเภทจำนวนเต็ม
Anchor link toโอเปอเรเตอร์ที่ใช้ได้: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
Operand ที่ใช้ได้:
- EQ, NOTEQ, GTE, LTE: operand ต้องเป็นจำนวนเต็ม;
- IN, NOTIN: operand ต้องเป็นอาร์เรย์ของจำนวนเต็ม เช่น
[value 1, value 2, value N]
; - BETWEEN: operand ต้องเป็นอาร์เรย์ของจำนวนเต็ม เช่น
[min_value, max_value]
แท็กประเภทวันที่
Anchor link toโอเปอเรเตอร์ที่ใช้ได้: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
Operand ที่ใช้ได้:
- (สตริง)
"YYYY-MM-DD 00:00"
- (จำนวนเต็ม) unix timestamp
1234567890
- (สตริง)
"N days ago"
สำหรับโอเปอเรเตอร์ EQ, BETWEEN, GTE, LTE
แท็กประเภทบูลีน
Anchor link toโอเปอเรเตอร์ที่ใช้ได้: EQ
Operand ที่ใช้ได้: 0, 1, true, false
แท็กประเภทรายการ
Anchor link toโอเปอเรเตอร์ที่ใช้ได้: IN
Operand ที่ใช้ได้: operand ต้องเป็นอาร์เรย์ของสตริง เช่น ["value 1", "value 2", "value N"]
registerEmail
Anchor link toลงทะเบียนที่อยู่อีเมลสำหรับแอป
POST
https://api.pushwoosh.com/json/1.3/registerEmail
ส่วนหัวของคำขอ
Anchor link toชื่อ | จำเป็น | ค่า | คำอธิบาย |
---|---|---|---|
Authorization | ใช่ | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
เนื้อหาของคำขอ
Anchor link toชื่อ | ประเภท | คำอธิบาย |
---|---|---|
application* | string | รหัสแอปพลิเคชัน Pushwoosh |
email* | string | ที่อยู่อีเมล |
language | string | ภาษาท้องถิ่นของอุปกรณ์ ต้องเป็นรหัสตัวอักษรพิมพ์เล็กสองตัวตามมาตรฐาน ISO-639-1 |
userId | string | User ID ที่จะเชื่อมโยงกับที่อยู่อีเมล |
tz_offset | integer | ค่าออฟเซ็ตของไทม์โซนในหน่วยวินาที |
tags | object | ค่าแท็กที่จะกำหนดให้กับอุปกรณ์ที่ลงทะเบียน |
{ "status_code": 200, "status_message": "OK", "response": null}
{ "request": { "application": "APPLICATION_CODE", // required. Pushwoosh application code. "email":"email@domain.com", // required. Email address to be registered. "language": "en", // optional. Language locale. "userId": "userId", // optional. User ID to associate with the email address. "tz_offset": 3600, // optional. Timezone offset in seconds. "tags": { // optional. Tag values to set for the device registered. "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1","string2"], // sets the list of values for Tags of List type "DateTag": "2024-10-02 22:11", // note the time should be in UTC "BooleanTag": true // valid values are: true, false } }}
deleteEmail
Anchor link toลบที่อยู่อีเมลออกจากฐานผู้ใช้ของคุณ
POST
https://api.pushwoosh.com/json/1.3/deleteEmail
ส่วนหัวของคำขอ
Anchor link toชื่อ | จำเป็น | ค่า | คำอธิบาย |
---|---|---|---|
Authorization | ใช่ | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
เนื้อหาของคำขอ
Anchor link toชื่อ | ประเภท | คำอธิบาย |
---|---|---|
application | string | รหัสแอปพลิเคชัน Pushwoosh |
string | ที่อยู่อีเมลที่ใช้ในคำขอ /registerEmail |
{ "status_code": 200, "status_message": "OK", "response": null}
{ "request": { "application": "APPLICATION_CODE", // required. Pushwoosh application code "email": "email@domain.com" // required. Email to delete from app subscribers. }}
setEmailTags
Anchor link toตั้งค่าแท็กสำหรับที่อยู่อีเมล
POST
https://api.pushwoosh.com/json/1.3/setEmailTags
ส่วนหัวของคำขอ
Anchor link toชื่อ | จำเป็น | ค่า | คำอธิบาย |
---|---|---|---|
Authorization | ใช่ | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
เนื้อหาของคำขอ
Anchor link toชื่อ | ประเภท | คำอธิบาย |
---|---|---|
application | string | รหัสแอปพลิเคชัน Pushwoosh |
string | ที่อยู่อีเมล | |
tags | object | อ็อบเจกต์ JSON ของแท็กที่จะตั้งค่า ส่ง ‘null’ เพื่อลบค่า |
userId | string | User ID ที่เชื่อมโยงกับที่อยู่อีเมล |
{ "status_code": 200, "status_message": "OK", "response": { "skipped": [] }}
{ "request": { "email": "email@domain.com", // required. Email address to set tags for. "application": "APPLICATION_CODE", // required. Pushwoosh application code. "tags": { "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], "DateTag": "2024-10-02 22:11", // time in UTC "BooleanTag": true // valid values are: true, false }, "userId": "userId" // optional. User ID associated with the email address. }}
registerEmailUser
Anchor link toเชื่อมโยง User ID ภายนอกกับที่อยู่อีเมลที่ระบุ
POST
https://api.pushwoosh.com/json/1.3/registerEmailUser
สามารถใช้ในการเรียก API /createEmailMessage (พารามิเตอร์ ‘users’)
ส่วนหัวของคำขอ
Anchor link toชื่อ | จำเป็น | ค่า | คำอธิบาย |
---|---|---|---|
Authorization | ใช่ | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
เนื้อหาของคำขอ
Anchor link toชื่อ | ประเภท | คำอธิบาย |
---|---|---|
application* | string | รหัสแอปพลิเคชัน Pushwoosh |
email* | string | ที่อยู่อีเมล |
userId* | string | User ID ที่จะเชื่อมโยงกับที่อยู่อีเมล |
tz_offset | integer | ค่าออฟเซ็ตของไทม์โซนในหน่วยวินาที |
{ "status_code": 200, "status_message": "OK", "response": null}
{ "status_code": 400, "status_message": "Request format is not valid."}
{ "status_code": 403, "status_message": "Forbidden."}
{ "request": { "application": "APPLICATION_CODE", // required. Pushwoosh application code. "email": "email@domain.com", // required. User email address. "userId": "userId", // required. User ID to associate with the email address. "tz_offset": 3600 // optional. Timezone offset in seconds. }}