Email API
createEmailMessage
Anchor link toสร้างข้อความอีเมล
POST https://api.pushwoosh.com/json/1.3/createEmailMessage
Request body parameters
Anchor link to| Name | Type | Required | Description |
|---|---|---|---|
| auth | string | Yes | API access token จาก Pushwoosh Control Panel |
| application | string | Yes | Pushwoosh application code |
| notifications | array | Yes | JSON array ที่มีรายละเอียดข้อความอีเมล ดูตาราง Notifications Parameters ด้านล่าง |
Notifications parameters
Anchor link to| Name | Type | Required | Description |
|---|---|---|---|
| send_date | string | Yes | กำหนดเวลาส่งอีเมล รูปแบบ: YYYY-MM-DD HH:mm หรือ "now" |
| preset | string | Yes | Email preset code คัดลอกได้จากแถบ URL ของ Email Content Editor ใน Pushwoosh Control Panel |
| subject | string หรือ object | No | หัวเรื่องของอีเมล อีเมลจะอยู่ในภาษาของเนื้อหาเสมอ หาก subject ไม่มีภาษาที่ตรงกับ content หัวเรื่องจะว่างเปล่า |
| content | string หรือ object | No | เนื้อหาของอีเมล สามารถเป็น string สำหรับเนื้อหา HTML ธรรมดา หรือ object สำหรับเวอร์ชันที่แปลเป็นภาษาท้องถิ่น |
| attachments | array | No | ไฟล์แนบอีเมล สามารถแนบได้เพียง 2 ไฟล์ แต่ละไฟล์ต้องมีขนาดไม่เกิน 1MB (base64 encoded) |
| list_unsubscribe | string | No | อนุญาตให้ตั้งค่า URL ที่กำหนดเองสำหรับ header “Link-Unsubscribe” |
| campaign | string | No | Campaign code เพื่อเชื่อมโยงอีเมลกับแคมเปญที่ระบุ |
| ignore_user_timezone | boolean | No | หากเป็น true จะส่งอีเมลทันทีโดยไม่คำนึงถึงเขตเวลาของผู้ใช้ |
| timezone | string | No | ส่งอีเมลตามเขตเวลาของผู้ใช้ ตัวอย่าง: "America/New_York" |
| filter | string | No | ส่งอีเมลไปยังผู้ใช้ที่ตรงกับ เงื่อนไขตัวกรองที่ระบุ |
| devices | array | No | รายการที่อยู่อีเมล (สูงสุด 1000) เพื่อส่งอีเมลแบบเจาะจง หากใช้ พารามิเตอร์นี้ข้อความจะถูกส่งไปยังที่อยู่เหล่านี้เท่านั้น จะถูกละเว้นหากใช้ Application Group |
| use_auto_registration | boolean | No | หากเป็น true จะลงทะเบียนอีเมลจากพารามิเตอร์ devices โดยอัตโนมัติ |
| users | array | No | หากระบุ ข้อความอีเมลจะถูกส่งไปยัง User ID ที่ระบุเท่านั้น (ลงทะเบียนผ่านการเรียก /registerEmail) ไม่เกิน 1000 user ID ใน array หากระบุพารามิเตอร์ “devices” พารามิเตอร์ “users” จะถูกละเว้น |
| dynamic_content_placeholders | object | No | Placeholders สำหรับเนื้อหาแบบไดนามิกแทนค่า device tag |
| conditions | array | No | เงื่อนไขการแบ่งกลุ่ม (Segmentation) โดยใช้ tags ตัวอย่าง: [["Country", "EQ", "BR"]] |
| from | object | No | ระบุชื่อผู้ส่งและอีเมลที่กำหนดเอง โดยจะแทนที่ค่าเริ่มต้นในคุณสมบัติของแอปพลิเคชัน |
| reply-to | object | No | ระบุอีเมลตอบกลับที่กำหนดเอง โดยจะแทนที่ค่าเริ่มต้นในคุณสมบัติของแอปพลิเคชัน |
| transactionId | string | No | ตัวระบุข้อความที่ไม่ซ้ำกันเพื่อป้องกันการส่งซ้ำในกรณีที่มีปัญหาเครือข่าย เก็บไว้ที่ฝั่ง Pushwoosh เป็นเวลา 5 นาที |
| capping_days | integer | No | จำนวนวัน (สูงสุด 30) ที่จะใช้ frequency capping ต่ออุปกรณ์ หมายเหตุ: ตรวจสอบให้แน่ใจว่าได้กำหนดค่า Global frequency capping ใน Control Panel แล้ว |
| capping_count | integer | No | จำนวนอีเมลสูงสุดที่สามารถส่งจากแอปเฉพาะไปยังอุปกรณ์เฉพาะภายในระยะเวลา capping_days ในกรณีที่ข้อความที่สร้างขึ้นเกินขีดจำกัด capping_count สำหรับอุปกรณ์ ข้อความนั้นจะไม่ถูกส่งไปยังอุปกรณ์นั้น |
| capping_exclude | boolean | No | หากตั้งค่าเป็น true อีเมลนี้จะไม่ถูกนับรวมใน capping สำหรับอีเมลในอนาคต |
| capping_avoid | boolean | No | หากตั้งค่าเป็น true capping จะไม่ถูกนำมาใช้กับอีเมลนี้ |
| send_rate | integer | No | จำกัดจำนวนข้อความที่สามารถส่งได้ต่อวินาทีสำหรับผู้ใช้ทั้งหมด ช่วยป้องกัน backend overload ในระหว่างการส่งปริมาณมาก |
| send_rate_avoid | boolean | No | หากตั้งค่าเป็น true ขีดจำกัดการควบคุมความเร็ว (throttling limit) จะไม่ถูกนำมาใช้กับอีเมลนี้ |
Request example
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" }], "list_unsubscribe": "URL", // optional. Allow to set custom URL for "Link-Unsubscribe" header "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. "send_rate": 100, // optional. Throttling limit. // Limit how many messages can be sent per second across all users. // Helps prevent backend overload during high-volume sends. "send_rate_avoid": true, // optional. If set to true, throttling limit will not be applied to // this specific email. }] }}Response examples
Anchor link to{ "status_code": 200, "status_message": "OK", "response": null}{ "status_code": 403, "status_message": "Token restrictions forbid this operation", "response": null}Tag conditions
Anchor link toเงื่อนไข tag แต่ละรายการคือ array เช่น [tagName, operator, operand] โดยที่
- tagName: ชื่อของ tag
- operator: “EQ” | “IN” | “NOTEQ” | “NOTIN” | “LTE” | “GTE” | “BETWEEN”
- operand: string | integer | array | date
Operand description
Anchor link to- EQ: ค่า tag เท่ากับ operand;
- IN: ค่า tag ตัดกัน (intersect) กับ operand (operand ต้องเป็น array เสมอ);
- NOTEQ: ค่า tag ไม่เท่ากับ operand;
- NOTIN: ค่า tag ไม่ตัดกัน (intersect) กับ operand (operand ต้องเป็น array เสมอ);
- GTE: ค่า tag มากกว่าหรือเท่ากับ operand;
- LTE: ค่า tag น้อยกว่าหรือเท่ากับ operand;
- BETWEEN: ค่า tag มากกว่าหรือเท่ากับค่า min operand แต่น้อยกว่าหรือเท่ากับค่า max operand (operand ต้องเป็น array เสมอ)
String tags
Anchor link toValid operators: EQ, IN, NOTEQ, NOTIN
Valid operands:
- EQ, NOTEQ: operand ต้องเป็น string;
- IN, NOTIN: operand ต้องเป็น array ของ strings เช่น
["value 1", "value 2", "value N"];
Integer tags
Anchor link toValid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
Valid operands:
- EQ, NOTEQ, GTE, LTE: operand ต้องเป็น integer;
- IN, NOTIN: operand ต้องเป็น array ของ integers เช่น
[value 1, value 2, value N]; - BETWEEN: operand ต้องเป็น array ของ integers เช่น
[min_value, max_value]
Date tags
Anchor link toValid operators: EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
Valid operands:
"YYYY-MM-DD 00:00"(string)- unix timestamp
1234567890(integer) "N days ago"(string) สำหรับ operators EQ, BETWEEN, GTE, LTE
Boolean tags
Anchor link toValid operators: EQ
Valid operands: 0, 1, true, false
List tags
Anchor link toValid operators: IN
Valid operands: operand ต้องเป็น array ของ strings เช่น ["value 1", "value 2", "value N"]
registerEmail
Anchor link toลงทะเบียนที่อยู่อีเมลสำหรับแอป
POST https://api.pushwoosh.com/json/1.3/registerEmail
Request headers
Anchor link to| Name | Required | Value | Description |
|---|---|---|---|
| Authorization | Yes | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
Request body
Anchor link to| Name | Type | Description |
|---|---|---|
| application* | string | Pushwoosh application code |
| email* | string | ที่อยู่อีเมล |
| language | string | Language locale ของอุปกรณ์ ต้องเป็นรหัสตัวอักษรพิมพ์เล็กสองตัวตามมาตรฐาน ISO-639-1 |
| userId | string | User ID ที่จะเชื่อมโยงกับที่อยู่อีเมล |
| tz_offset | integer | Timezone offset เป็นวินาที |
| tags | object | ค่า Tag ที่จะกำหนดให้กับอุปกรณ์ที่ลงทะเบียน |
{ "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
Request headers
Anchor link to| Name | Required | Value | Description |
|---|---|---|---|
| Authorization | Yes | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
Request body
Anchor link to| Name | Type | Description |
|---|---|---|
| application | string | Pushwoosh application code |
| string | ที่อยู่อีเมลที่ใช้ใน request /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ตั้งค่า tag ให้กับที่อยู่อีเมล
POST https://api.pushwoosh.com/json/1.3/setEmailTags
Request headers
Anchor link to| Name | Required | Value | Description |
|---|---|---|---|
| Authorization | Yes | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
Request body
Anchor link to| Name | Type | Description |
|---|---|---|
| application | string | Pushwoosh application code |
| string | ที่อยู่อีเมล | |
| tags | object | JSON object ของ tags ที่จะตั้งค่า ส่ง ‘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’)
Request headers
Anchor link to| Name | Required | Value | Description |
|---|---|---|---|
| Authorization | Yes | Token XXXX | API Device Token เพื่อเข้าถึง Device API แทนที่ XXXX ด้วย Device API token จริงของคุณ |
Request body
Anchor link to| Name | Type | Description |
|---|---|---|
| application* | string | Pushwoosh application code |
| email* | string | ที่อยู่อีเมล |
| userId* | string | User ID ที่จะเชื่อมโยงกับที่อยู่อีเมล |
| tz_offset | integer | Timezone offset เป็นวินาที |
{ "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. }}