Email API
createEmailMessage
Anchor link to创建一封电子邮件消息。
POST https://api.pushwoosh.com/json/1.3/createEmailMessage
请求体参数
Anchor link to| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| auth | string | 是 | 来自 Pushwoosh 控制面板的 API Access Token。 |
| application | string | 是 | Pushwoosh Application Code |
| notifications | array | 是 | 包含电子邮件消息详情的 JSON 数组。请参阅下方的 Notifications 参数 表。 |
Notifications 参数
Anchor link to| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| send_date | string | 是 | 定义发送电子邮件的时间。格式:YYYY-MM-DD HH:mm 或 "now"。 |
| preset | string | 是 | Email Content Code。从 Pushwoosh 控制面板中 Email Content Editor 的 URL 栏复制。 |
| subject | string 或 object | 否 | 电子邮件的主题行。电子邮件将始终采用内容的语言。如果 subject 不包含与 content 匹配的语言,则主题将为空。 |
| content | string 或 object | 否 | 电子邮件正文内容。可以是纯 HTML 内容的字符串,也可以是本地化版本的对象。 |
| attachments | array | 否 | 电子邮件附件。仅支持两个附件。每个附件不得超过 1MB(base64 编码)。 |
| list_unsubscribe | string | 否 | 允许为 “Link-Unsubscribe” 头部设置自定义 URL。 |
| campaign | string | 否 | 用于将电子邮件与特定活动关联的 Campaign Code。 |
| 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。 |
| capping_count | integer | 否 | 在 capping_days 期间内,特定应用可以向特定设备发送的最大电子邮件数量。如果创建的消息超过了设备的 capping_count 限制,则不会发送给该设备。 |
| capping_exclude | boolean | 否 | 如果设置为 true,此电子邮件将不计入未来电子邮件的频次上限。 |
| capping_avoid | boolean | 否 | 如果设置为 true,频次上限将不应用于此特定电子邮件。 |
| send_rate | integer | 否 | 限制所有用户每秒可以发送的消息数量。有助于防止大批量发送期间后端过载。 |
| send_rate_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" }], "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. }] }}响应示例
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: string | integer | array | date
操作数描述
Anchor link to- EQ: 标签值等于操作数;
- IN: 标签值与操作数相交(操作数必须始终为数组);
- NOTEQ: 标签值不等于操作数;
- NOTIN: 标签值与操作数不相交(操作数必须始终为数组);
- GTE: 标签值大于或等于操作数;
- LTE: 标签值小于或等于操作数;
- BETWEEN: 标签值大于或等于最小操作数值,但小于或等于最大操作数值(操作数必须始终为数组)。
String 标签
Anchor link to有效运算符:EQ, IN, NOTEQ, NOTIN
有效操作数:
- EQ, NOTEQ: 操作数必须是字符串;
- IN, NOTIN: 操作数必须是字符串数组,如
["value 1", "value 2", "value N"];
Integer 标签
Anchor link to有效运算符:EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
有效操作数:
- EQ, NOTEQ, GTE, LTE: 操作数必须是整数;
- IN, NOTIN: 操作数必须是整数数组,如
[value 1, value 2, value N]; - BETWEEN: 操作数必须是整数数组,如
[min_value, max_value]。
Date 标签
Anchor link to有效运算符:EQ, IN, NOTEQ, NOTIN, BETWEEN, GTE, LTE
有效操作数:
"YYYY-MM-DD 00:00"(string)- unix timestamp
1234567890(integer) "N days ago"(string) 适用于运算符 EQ, BETWEEN, GTE, LTE
Boolean 标签
Anchor link to有效运算符:EQ
有效操作数:0, 1, true, false
List 标签
Anchor link to有效运算符:IN
有效操作数:操作数必须是字符串数组,如 ["value 1", "value 2", "value N"]。
registerEmail
Anchor link to为应用注册电子邮件地址。
POST https://api.pushwoosh.com/json/1.3/registerEmail
| 名称 | 必填 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh Application Code |
| 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
| 名称 | 必填 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application | string | Pushwoosh Application Code |
| 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
| 名称 | 必填 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application | string | Pushwoosh Application Code |
| 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
可用于 /createEmailMessage API 调用(‘users’ 参数)。
| 名称 | 必填 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh Application Code |
| 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. }}