跳到内容

Email API

createEmailMessage

Anchor link to

创建一封电子邮件消息。

POST https://api.pushwoosh.com/json/1.3/createEmailMessage

请求体参数

Anchor link to
名称类型
必填描述
authstring来自 Pushwoosh 控制面板的 API Access Token
applicationstringPushwoosh Application Code
notificationsarray包含电子邮件消息详情的 JSON 数组。请参阅下方的 Notifications 参数 表。

Notifications 参数

Anchor link to
名称类型
必填描述
send_datestring定义发送电子邮件的时间。格式:YYYY-MM-DD HH:mm"now"
presetstringEmail Content Code。从 Pushwoosh 控制面板中 Email Content Editor 的 URL 栏复制。
subjectstringobject电子邮件的主题行。电子邮件将始终采用内容的语言。如果 subject 不包含与 content 匹配的语言,则主题将为空。
contentstringobject电子邮件正文内容。可以是纯 HTML 内容的字符串,也可以是本地化版本的对象。
attachmentsarray电子邮件附件。仅支持两个附件。每个附件不得超过 1MB(base64 编码)。
list_unsubscribestring允许为 “Link-Unsubscribe” 头部设置自定义 URL。
campaignstring用于将电子邮件与特定活动关联的 Campaign Code
ignore_user_timezoneboolean如果为 true,则立即发送电子邮件,忽略用户时区。
timezonestring根据用户的时区发送电子邮件。示例:"America/New_York"
filterstring将电子邮件发送给符合 特定筛选条件 的用户。
devicesarray用于发送定向电子邮件的电子邮件地址列表(最多 1000 个)。如果使用此参数,消息仅发送到这些地址。如果使用了 Application Group,则忽略此参数。
use_auto_registrationboolean如果为 true,自动注册 devices 参数中的电子邮件。
usersarray如果设置,电子邮件消息将仅发送给指定的 User ID(通过 /registerEmail 调用注册)。数组中最多 1000 个 User ID。如果指定了 “devices” 参数,“users” 参数将被忽略。
dynamic_content_placeholdersobject用于动态内容的占位符,代替设备标签值。
conditionsarray使用标签的分群条件。示例:[["Country", "EQ", "BR"]]
fromobject指定自定义发件人名称和电子邮件,覆盖应用程序属性中的默认值。
reply-toobject指定自定义回复电子邮件,覆盖应用程序属性中的默认值。
transactionIdstring唯一消息标识符,用于防止网络问题导致的重复发送。在 Pushwoosh 端存储 5 分钟。
capping_daysinteger每个设备应用频次上限的天数(最多 30 天)。注意: 确保在控制面板中配置了 Global frequency capping
capping_countintegercapping_days 期间内,特定应用可以向特定设备发送的最大电子邮件数量。如果创建的消息超过了设备的 capping_count 限制,则不会发送给该设备。
capping_excludeboolean如果设置为 true,此电子邮件将不计入未来电子邮件的频次上限。
capping_avoidboolean如果设置为 true,频次上限将不应用于此特定电子邮件。
send_rateinteger限制所有用户每秒可以发送的消息数量。有助于防止大批量发送期间后端过载。
send_rate_avoidboolean如果设置为 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
}

标签条件

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

名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。
名称类型描述
application*stringPushwoosh Application Code
email*string电子邮件地址。
languagestring设备的语言区域设置。必须是符合 ISO-639-1 标准的小写双字母代码。
userIdstring与电子邮件地址关联的 User ID
tz_offsetinteger以秒为单位的时区偏移量。
tagsobject分配给注册设备的标签值。
{
"status_code": 200,
"status_message": "OK",
"response": null
}
Example
{
"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

名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。
名称类型描述
applicationstringPushwoosh Application Code
emailstring/registerEmail 请求中使用的电子邮件地址。
{
"status_code": 200,
"status_message": "OK",
"response": null
}
Example
{
"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

名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。
名称类型描述
applicationstringPushwoosh Application Code
emailstring电子邮件地址。
tagsobject要设置的标签的 JSON 对象,发送 ‘null’ 以移除该值。
userIdstring与电子邮件地址关联的 User ID
{
"status_code": 200,
"status_message": "OK",
"response": {
"skipped": []
}
}
Example
{
"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’ 参数)。

名称必填描述
AuthorizationToken XXXX用于访问 Device API 的 Device API Token。将 XXXX 替换为您的实际 Device API Token。
名称类型描述
application*stringPushwoosh Application Code
email*string电子邮件地址。
userId*string与电子邮件地址关联的 User ID
tz_offsetinteger以秒为单位的时区偏移量。
{
"status_code": 200,
"status_message": "OK",
"response": null
}
Example
{
"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.
}
}