技能标识:brevo
Brevo (formerly Sendinblue) email marketing API for managing contacts, lists, sending transactional emails, and campaigns. Use when importing contacts, sending emails, managing subscriptions, or working with email automation.
通过 Brevo 的 REST API 管理联系人、发送邮件并自动化营销。
bash
BREVOKEY=$(cat ~/.config/brevo/apikey)
所有请求都需要包含请求头:api-key: $BREVO_KEY
https://api.brevo.com/v3
| 操作 | 方法 | 端点 |
|---|---|---|
| 创建联系人 | POST | /contacts |
| 获取联系人 |
| 操作 | 方法 | 端点 |
|---|---|---|
| 获取所有列表 | GET | /contacts/lists |
| 创建列表 |
| 操作 | 方法 | 端点 |
|---|---|---|
| 发送事务邮件 | POST | /smtp/email |
| 发送营销活动 |
bash
curl -X POST https://api.brevo.com/v3/contacts \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
email: user@example.com,
listIds: [10],
updateEnabled: true,
attributes: {
NOMBRE: John,
APELLIDOS: Doe
}
}
bash
curl https://api.brevo.com/v3/contacts/user@example.com \
-H api-key: $BREVO_KEY
bash
curl -X PUT https://api.brevo.com/v3/contacts/user@example.com \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
listIds: [10, 15],
attributes: {
CUSTOM_FIELD: value
}
}
bash
curl -X POST https://api.brevo.com/v3/smtp/email \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
sender: {name: My App, email: noreply@example.com},
to: [{email: user@example.com, name: John}],
subject: Welcome!,
htmlContent:
Hello {{params.name}}
,bash
curl -X POST https://api.brevo.com/v3/smtp/email \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
to: [{email: user@example.com}],
templateId: 34,
params: {
NOMBRE: John,
FECHA: 2026-02-01
}
}
bash
curl https://api.brevo.com/v3/contacts/lists?limit=50 \
-H api-key: $BREVO_KEY
bash
curl -X POST https://api.brevo.com/v3/contacts/lists/10/contacts/add \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
emails: [user1@example.com, user2@example.com]
}
导入联系人时,始终尊重退订:
python
import requests
BREVO_KEY = your-api-key
HEADERS = {api-key: BREVO_KEY, Content-Type: application/json}
BASE = https://api.brevo.com/v3
def get_blacklisted():
获取所有退订/黑名单邮件
blacklisted = set()
offset = 0
while True:
r = requests.get(
f{BASE}/contacts?limit=100&offset={offset}&emailBlacklisted=true,
headers=HEADERS
)
contacts = r.json().get(contacts, [])
if not contacts:
break
for c in contacts:
blacklisted.add(c[email].lower())
offset += 100
return blacklisted
def safeimport(emails, listid):
导入联系人,尊重退订
blacklisted = get_blacklisted()
for email in emails:
if email.lower() in blacklisted:
print(f已跳过(已退订):{email})
continue
r = requests.post(f{BASE}/contacts, headers=HEADERS, json={
email: email,
listIds: [list_id],
updateEnabled: True
})
if r.status_code in [200, 201, 204]:
print(f已导入:{email})
else:
print(f错误:{email} - {r.text[:50]})
Brevo 使用自定义属性存储联系人数据:
json
{
attributes: {
NOMBRE: John,
APELLIDOS: Doe,
FECHA_ALTA: 2026-01-15,
PLAN: premium,
CUSTOM_FIELD: any value
}
}
在 Brevo 控制面板中创建属性:联系人 → 设置 → 联系人属性。
| 代码 | 含义 |
|---|---|
| 200 | 成功(GET) |
| 201 |
Brevo 自动化触发条件:
手动触发自动化:
bash
curl -X POST https://api.brevo.com/v3/contacts/import \
-H api-key: $BREVO_KEY \
-H Content-Type: application/json \
-d {
listIds: [10],
emailBlacklist: false,
updateExistingContacts: true,
emptyContactsAttributes: false,
jsonBody: [
{email: user@example.com, attributes: {NOMBRE: John}}
]
}
bash
以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:
帮我安装 SkillHub 和 brevo-1776379464 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 brevo-1776379464 技能
skillhub install brevo-1776379464
文件大小: 2.7 KB | 发布时间: 2026-4-17 16:16