sendgrid-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSendGrid Automation via Rube MCP
通过Rube MCP实现SendGrid自动化
Automate SendGrid email delivery workflows including marketing campaigns (Single Sends), contact and list management, sender identity setup, and email analytics through Composio's SendGrid toolkit.
通过Composio的SendGrid工具包自动化SendGrid邮件交付工作流,包括营销活动(单次发送)、联系人与列表管理、发件人身份设置及邮件数据分析。
Prerequisites
前提条件
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active SendGrid connection via with toolkit
RUBE_MANAGE_CONNECTIONSsendgrid - Always call first to get current tool schemas
RUBE_SEARCH_TOOLS
- 必须已连接Rube MCP(需提供RUBE_SEARCH_TOOLS)
- 已通过连接活跃的SendGrid,工具包为
RUBE_MANAGE_CONNECTIONSsendgrid - 请始终先调用获取最新的工具架构
RUBE_SEARCH_TOOLS
Setup
设置步骤
Get Rube MCP: Add as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
https://rube.app/mcp- Verify Rube MCP is available by confirming responds
RUBE_SEARCH_TOOLS - Call with toolkit
RUBE_MANAGE_CONNECTIONSsendgrid - If connection is not ACTIVE, follow the returned auth link to complete SendGrid API key authentication
- Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加作为MCP服务器。无需API密钥 —— 只需添加端点即可使用。
https://rube.app/mcp- 确认可响应,以此验证Rube MCP是否可用
RUBE_SEARCH_TOOLS - 调用,工具包指定为
RUBE_MANAGE_CONNECTIONSsendgrid - 如果连接状态不是ACTIVE,请按照返回的认证链接完成SendGrid API密钥认证
- 在运行任何工作流之前,确认连接状态显示为ACTIVE
Core Workflows
核心工作流
1. Create and Send Marketing Campaigns (Single Sends)
1. 创建并发送营销活动(单次发送)
When to use: User wants to create and send a marketing email campaign to a contact list or segment.
Tool sequence:
- - List available marketing lists to target [Prerequisite]
SENDGRID_RETRIEVE_ALL_LISTS - - Create a new list if needed [Optional]
SENDGRID_CREATE_A_LIST - - Add contacts to the list [Optional]
SENDGRID_ADD_OR_UPDATE_A_CONTACT - - Get verified sender ID [Prerequisite]
SENDGRID_GET_ALL_SENDER_IDENTITIES - - Create the campaign with content, sender, and recipients [Required]
SENDGRID_CREATE_SINGLE_SEND
Key parameters for SENDGRID_CREATE_SINGLE_SEND:
- : Campaign name (required)
name - : Email subject line
email__config__subject - : HTML body content
email__config__html__content - : Plain text version
email__config__plain__content - : Verified sender identity ID
email__config__sender__id - : Use instead of html_content for pre-built designs
email__config__design__id - : Array of list UUIDs to send to
send__to__list__ids - : Array of segment UUIDs
send__to__segment__ids - : true to send to all contacts
send__to__all - or
email__config__suppression__group__id: One required for complianceemail__config__custom__unsubscribe__url
Pitfalls:
- Setting on CREATE does NOT schedule the send; it only prepopulates the UI date; use the Schedule endpoint separately
send_at - is only valid with the Schedule endpoint, not CREATE
send_at: "now" - Must provide either or
suppression_group_idfor unsubscribe compliancecustom_unsubscribe_url - Sender must be verified before use; check with
SENDGRID_GET_ALL_SENDER_IDENTITIES - Nested params use double-underscore notation (e.g., )
email__config__subject
适用场景:用户需要创建并向联系人列表或细分群体发送营销邮件活动。
工具执行顺序:
- - 列出可用的营销目标列表 [前提步骤]
SENDGRID_RETRIEVE_ALL_LISTS - - 按需创建新列表 [可选]
SENDGRID_CREATE_A_LIST - - 向列表中添加联系人 [可选]
SENDGRID_ADD_OR_UPDATE_A_CONTACT - - 获取已验证的发件人ID [前提步骤]
SENDGRID_GET_ALL_SENDER_IDENTITIES - - 创建包含内容、发件人和收件人的活动 [必填]
SENDGRID_CREATE_SINGLE_SEND
SENDGRID_CREATE_SINGLE_SEND关键参数:
- : 活动名称(必填)
name - : 邮件主题
email__config__subject - : HTML邮件正文
email__config__html__content - : 纯文本版本
email__config__plain__content - : 已验证的发件人身份ID
email__config__sender__id - : 若使用预构建模板,可替代html_content
email__config__design__id - : 目标列表UUID数组
send__to__list__ids - : 目标细分群体UUID数组
send__to__segment__ids - : 设置为true则发送给所有联系人
send__to__all - 或
email__config__suppression__group__id: 合规要求二选一email__config__custom__unsubscribe__url
注意事项:
- 在CREATE操作中设置不会调度发送;仅会填充UI日期,需单独使用Schedule端点
send_at - 仅在Schedule端点有效,CREATE操作不支持
send_at: "now" - 必须提供或
suppression_group_id以满足退订合规要求custom_unsubscribe_url - 发件人必须先验证才能使用;可通过检查
SENDGRID_GET_ALL_SENDER_IDENTITIES - 嵌套参数使用双下划线表示(例如:)
email__config__subject
2. Manage Contacts and Lists
2. 管理联系人与列表
When to use: User wants to create contact lists, add/update contacts, search for contacts, or remove contacts from lists.
Tool sequence:
- - List all marketing lists [Required]
SENDGRID_RETRIEVE_ALL_LISTS - - Create a new contact list [Optional]
SENDGRID_CREATE_A_LIST - - Get list details and sample contacts [Optional]
SENDGRID_GET_A_LIST_BY_ID - - Upsert contacts with list association [Required]
SENDGRID_ADD_OR_UPDATE_A_CONTACT - - Look up contacts by email [Optional]
SENDGRID_GET_CONTACTS_BY_EMAILS - - Look up contacts by email, phone, or external ID [Optional]
SENDGRID_GET_CONTACTS_BY_IDENTIFIERS - - Verify contact count after operations [Optional]
SENDGRID_GET_LIST_CONTACT_COUNT - - Remove contacts from a list without deleting [Optional]
SENDGRID_REMOVE_CONTACTS_FROM_A_LIST - - Delete an entire list [Optional]
SENDGRID_REMOVE_LIST_AND_OPTIONAL_CONTACTS - - Bulk import from CSV [Optional]
SENDGRID_IMPORT_CONTACTS
Key parameters for SENDGRID_ADD_OR_UPDATE_A_CONTACT:
- : Array of contact objects (max 30,000 or 6MB), each with at least one identifier:
contacts,email,phone_number_id, orexternal_id(required)anonymous_id - : Array of list UUID strings to associate contacts with
list_ids
Pitfalls:
- is asynchronous; returns 202 with
SENDGRID_ADD_OR_UPDATE_A_CONTACT; contacts may take 10-30 seconds to appearjob_id - List IDs are UUIDs (e.g., "ca7a3796-e8a8-4029-9ccb-df8937940562"), not integers
- List names must be unique; duplicate names cause 400 errors
- uses the legacy API; prefer
SENDGRID_ADD_A_SINGLE_RECIPIENT_TO_A_LISTwithSENDGRID_ADD_OR_UPDATE_A_CONTACTlist_ids - is irreversible; require explicit user confirmation
SENDGRID_REMOVE_LIST_AND_OPTIONAL_CONTACTS - Email addresses are automatically lowercased by SendGrid
适用场景:用户需要创建联系人列表、添加/更新联系人、搜索联系人或从列表中移除联系人。
工具执行顺序:
- - 列出所有营销列表 [必填]
SENDGRID_RETRIEVE_ALL_LISTS - - 创建新联系人列表 [可选]
SENDGRID_CREATE_A_LIST - - 获取列表详情及联系人样本 [可选]
SENDGRID_GET_A_LIST_BY_ID - - 批量插入/更新联系人并关联列表 [必填]
SENDGRID_ADD_OR_UPDATE_A_CONTACT - - 通过邮箱查找联系人 [可选]
SENDGRID_GET_CONTACTS_BY_EMAILS - - 通过邮箱、电话或外部ID查找联系人 [可选]
SENDGRID_GET_CONTACTS_BY_IDENTIFIERS - - 操作后验证联系人数量 [可选]
SENDGRID_GET_LIST_CONTACT_COUNT - - 从列表中移除联系人但不删除 [可选]
SENDGRID_REMOVE_CONTACTS_FROM_A_LIST - - 删除整个列表 [可选]
SENDGRID_REMOVE_LIST_AND_OPTIONAL_CONTACTS - - 从CSV批量导入联系人 [可选]
SENDGRID_IMPORT_CONTACTS
SENDGRID_ADD_OR_UPDATE_A_CONTACT关键参数:
- : 联系人对象数组(最多30,000个或6MB),每个对象至少包含一个标识符:
contacts、email、phone_number_id或external_id(必填)anonymous_id - : 联系人需关联的列表UUID字符串数组
list_ids
注意事项:
- 为异步操作;返回202状态码及
SENDGRID_ADD_OR_UPDATE_A_CONTACT;联系人可能需要10-30秒才会显示job_id - 列表ID为UUID格式(例如:"ca7a3796-e8a8-4029-9ccb-df8937940562"),而非整数
- 列表名称必须唯一;重复名称会导致400错误
- 使用旧版API;优先使用带
SENDGRID_ADD_A_SINGLE_RECIPIENT_TO_A_LIST参数的list_idsSENDGRID_ADD_OR_UPDATE_A_CONTACT - 操作不可逆;需用户明确确认
SENDGRID_REMOVE_LIST_AND_OPTIONAL_CONTACTS - SendGrid会自动将邮箱地址转换为小写
3. Manage Sender Identities
3. 管理发件人身份
When to use: User wants to set up or view sender identities (From addresses) for sending emails.
Tool sequence:
- - List all existing sender identities [Required]
SENDGRID_GET_ALL_SENDER_IDENTITIES - - Create a new sender identity [Optional]
SENDGRID_CREATE_A_SENDER_IDENTITY - - View details for a specific sender [Optional]
SENDGRID_VIEW_A_SENDER_IDENTITY - - Update sender details [Optional]
SENDGRID_UPDATE_A_SENDER_IDENTITY - - Create and verify a new sender [Optional]
SENDGRID_CREATE_VERIFIED_SENDER_REQUEST - - Set up domain authentication for auto-verification [Optional]
SENDGRID_AUTHENTICATE_A_DOMAIN
Key parameters for SENDGRID_CREATE_A_SENDER_IDENTITY:
- : From email address (required)
from__email - : Display name (required)
from__name - : Reply-to address (required)
reply__to__email - : Internal identifier (required)
nickname - ,
address,city: Physical address for CAN-SPAM compliance (required)country
Pitfalls:
- New senders must be verified before use; if domain is not authenticated, a verification email is sent
- Up to 100 unique sender identities per account
- Avoid using domains with strict DMARC policies (gmail.com, yahoo.com) as from addresses
- sends a verification email; sender is unusable until verified
SENDGRID_CREATE_VERIFIED_SENDER_REQUEST
适用场景:用户需要设置或查看用于发送邮件的发件人身份(发件地址)。
工具执行顺序:
- - 列出所有现有发件人身份 [必填]
SENDGRID_GET_ALL_SENDER_IDENTITIES - - 创建新的发件人身份 [可选]
SENDGRID_CREATE_A_SENDER_IDENTITY - - 查看特定发件人的详情 [可选]
SENDGRID_VIEW_A_SENDER_IDENTITY - - 更新发件人详情 [可选]
SENDGRID_UPDATE_A_SENDER_IDENTITY - - 创建并验证新的发件人 [可选]
SENDGRID_CREATE_VERIFIED_SENDER_REQUEST - - 设置域名认证以实现自动验证 [可选]
SENDGRID_AUTHENTICATE_A_DOMAIN
SENDGRID_CREATE_A_SENDER_IDENTITY关键参数:
- : 发件邮箱地址(必填)
from__email - : 显示名称(必填)
from__name - : 回复邮箱地址(必填)
reply__to__email - : 内部标识符(必填)
nickname - ,
address,city: 符合CAN-SPAM合规要求的物理地址(必填)country
注意事项:
- 新的发件人必须先验证才能使用;若域名未认证,系统会发送验证邮件
- 每个账户最多支持100个唯一的发件人身份
- 避免使用带有严格DMARC策略的域名(如gmail.com、yahoo.com)作为发件地址
- 会发送验证邮件;发件人在验证完成前无法使用
SENDGRID_CREATE_VERIFIED_SENDER_REQUEST
4. View Email Statistics and Activity
4. 查看邮件统计与活动记录
When to use: User wants to review email delivery stats, bounce rates, open/click metrics, or message activity.
Tool sequence:
- - Get account-wide delivery metrics [Required]
SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS - - Discover available categories for filtering [Optional]
SENDGRID_GET_ALL_CATEGORIES - - Get stats broken down by category [Optional]
SENDGRID_RETRIEVE_EMAIL_STATISTICS_FOR_CATEGORIES - - Search email activity feed by recipient, status, or date [Optional]
SENDGRID_FILTER_ALL_MESSAGES - - Get detailed events for a specific message [Optional]
SENDGRID_FILTER_MESSAGES_BY_MESSAGE_ID - - Export activity data as CSV for large datasets [Optional]
SENDGRID_REQUEST_CSV - - Download the exported CSV file [Optional]
SENDGRID_DOWNLOAD_CSV
Key parameters for SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS:
- : Start date YYYY-MM-DD (required)
start_date - : End date YYYY-MM-DD
end_date - : "day", "week", or "month"
aggregated_by - /
limit: Pagination (default 500)offset
Key parameters for SENDGRID_FILTER_ALL_MESSAGES:
- : SQL-like query string, e.g.,
query,status="delivered", date ranges withto_email="user@example.com"BETWEEN TIMESTAMP - : 1-1000 (default 10)
limit
Pitfalls:
- requires the "30 Days Additional Email Activity History" paid add-on; returns 403 without it
SENDGRID_FILTER_ALL_MESSAGES - Global statistics are nested under , not a flat structure
details[].stats[0].metrics - Category statistics are only available for the previous 13 months
- Maximum 10 categories per request in
SENDGRID_RETRIEVE_EMAIL_STATISTICS_FOR_CATEGORIES - CSV export is limited to one request per 12 hours; link expires after 3 days
适用场景:用户需要查看邮件交付统计、退信率、打开/点击指标或消息活动记录。
工具执行顺序:
- - 获取账户级别的交付指标 [必填]
SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS - - 查看可用于筛选的分类 [可选]
SENDGRID_GET_ALL_CATEGORIES - - 获取按分类拆分的统计数据 [可选]
SENDGRID_RETRIEVE_EMAIL_STATISTICS_FOR_CATEGORIES - - 按收件人、状态或日期搜索邮件活动记录 [可选]
SENDGRID_FILTER_ALL_MESSAGES - - 获取特定消息的详细事件记录 [可选]
SENDGRID_FILTER_MESSAGES_BY_MESSAGE_ID - - 将活动数据导出为CSV格式(适用于大型数据集)[可选]
SENDGRID_REQUEST_CSV - - 下载导出的CSV文件 [可选]
SENDGRID_DOWNLOAD_CSV
SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS关键参数:
- : 开始日期(格式YYYY-MM-DD,必填)
start_date - : 结束日期(格式YYYY-MM-DD)
end_date - : 聚合维度,可选"day"、"week"或"month"
aggregated_by - /
limit: 分页参数(默认500条)offset
SENDGRID_FILTER_ALL_MESSAGES关键参数:
- : SQL风格的查询字符串,例如
query、status="delivered",日期范围使用to_email="user@example.com"BETWEEN TIMESTAMP - : 1-1000条(默认10条)
limit
注意事项:
- 需要付费附加功能“30天额外邮件活动历史”;若无此功能会返回403错误
SENDGRID_FILTER_ALL_MESSAGES - 全局统计数据嵌套在下,并非扁平结构
details[].stats[0].metrics - 分类统计数据仅可查询过去13个月的记录
- 每次请求最多支持10个分类
SENDGRID_RETRIEVE_EMAIL_STATISTICS_FOR_CATEGORIES - CSV导出限制为每12小时一次;下载链接3天后过期
5. Manage Suppressions
5. 管理退订列表
When to use: User wants to check or manage unsubscribe groups for email compliance.
Tool sequence:
- - List all suppression groups [Required]
SENDGRID_GET_SUPPRESSION_GROUPS - - Check suppression status for a specific email [Optional]
SENDGRID_RETRIEVE_ALL_SUPPRESSION_GROUPS_FOR_AN_EMAIL_ADDRESS
Pitfalls:
- Suppressed addresses remain undeliverable even if present on marketing lists
- Campaign send counts may be lower than list counts due to suppressions
适用场景:用户需要检查或管理用于邮件合规的退订组。
工具执行顺序:
- - 列出所有退订组 [必填]
SENDGRID_GET_SUPPRESSION_GROUPS - - 检查特定邮箱的退订状态 [可选]
SENDGRID_RETRIEVE_ALL_SUPPRESSION_GROUPS_FOR_AN_EMAIL_ADDRESS
注意事项:
- 已退订的地址即使在营销列表中也无法收到邮件
- 由于退订原因,活动实际发送数量可能低于列表中的联系人数量
Common Patterns
通用模式
ID Resolution
ID解析
Always resolve names to IDs before operations:
- List name -> list_id: and match by name
SENDGRID_RETRIEVE_ALL_LISTS - Sender name -> sender_id: and match
SENDGRID_GET_ALL_SENDER_IDENTITIES - Contact email -> contact_id: with email array
SENDGRID_GET_CONTACTS_BY_EMAILS - Template name -> template_id: Use the SendGrid UI or template endpoints
在执行操作前,务必将名称解析为对应的ID:
- 列表名称 -> list_id: 使用并按名称匹配
SENDGRID_RETRIEVE_ALL_LISTS - 发件人名称 -> sender_id: 使用并匹配
SENDGRID_GET_ALL_SENDER_IDENTITIES - 联系人邮箱 -> contact_id: 使用并传入邮箱数组
SENDGRID_GET_CONTACTS_BY_EMAILS - 模板名称 -> template_id: 使用SendGrid UI或模板端点获取
Pagination
分页
- : Token-based with
SENDGRID_RETRIEVE_ALL_LISTSandpage_token(max 1000)page_size - : Offset-based with
SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS(max 500) andlimitoffset - Always paginate list retrieval to avoid missing existing lists
- : 基于令牌的分页,参数为
SENDGRID_RETRIEVE_ALL_LISTS和page_token(最大1000条)page_size - : 基于偏移量的分页,参数为
SENDGRID_RETRIEVE_GLOBAL_EMAIL_STATISTICS(最大500条)和limitoffset - 检索列表时务必使用分页,避免遗漏现有列表
Async Operations
异步操作
Contact operations (, ) are asynchronous:
ADD_OR_UPDATE_A_CONTACTIMPORT_CONTACTS- Returns 202 with a
job_id - Wait 10-30 seconds before verifying with
GET_CONTACTS_BY_EMAILS - Use to confirm list growth
GET_LIST_CONTACT_COUNT
联系人操作(、)为异步操作:
ADD_OR_UPDATE_A_CONTACTIMPORT_CONTACTS- 返回202状态码及
job_id - 等待10-30秒后,使用验证操作结果
GET_CONTACTS_BY_EMAILS - 使用确认列表联系人数量增长
GET_LIST_CONTACT_COUNT
Known Pitfalls
已知注意事项
ID Formats
ID格式
- Marketing list IDs are UUIDs (e.g., "ca7a3796-e8a8-4029-9ccb-df8937940562")
- Legacy list IDs are integers; do not mix with Marketing API endpoints
- Sender identity IDs are integers
- Template IDs: Dynamic templates start with "d-", legacy templates are UUIDs
- Contact IDs are UUIDs
- 营销列表ID为UUID格式(例如:"ca7a3796-e8a8-4029-9ccb-df8937940562")
- 旧版列表ID为整数;请勿与营销API端点混用
- 发件人身份ID为整数
- 模板ID:动态模板以"d-"开头,旧版模板为UUID格式
- 联系人ID为UUID格式
Rate Limits
速率限制
- SendGrid may return HTTP 429; respect headers
Retry-After - CSV export limited to one request per 12 hours
- Bulk contact upsert max: 30,000 contacts or 6MB per request
- SendGrid可能返回HTTP 429错误;请遵循响应头的指示
Retry-After - CSV导出限制为每12小时一次
- 批量联系人插入/更新上限:每次请求最多30,000个联系人或6MB数据
Parameter Quirks
参数特殊说明
- Nested params use double-underscore: ,
email__config__subjectfrom__email - on CREATE_SINGLE_SEND only sets a UI default, does NOT schedule
send_at - uses legacy API;
SENDGRID_ADD_A_SINGLE_RECIPIENT_TO_A_LISTis Base64-encoded lowercase emailrecipient_id - and
SENDGRID_RETRIEVE_ALL_LISTSboth exist; prefer RETRIEVE_ALL_LISTS for Marketing APISENDGRID_GET_ALL_LISTS - Contact adds are async (202); always verify after a delay
- 嵌套参数使用双下划线:、
email__config__subjectfrom__email - CREATE_SINGLE_SEND中的仅设置UI默认值,不会实际调度发送
send_at - 使用旧版API;
SENDGRID_ADD_A_SINGLE_RECIPIENT_TO_A_LIST为Base64编码的小写邮箱recipient_id - 同时存在和
SENDGRID_RETRIEVE_ALL_LISTS;优先使用RETRIEVE_ALL_LISTS(营销API)SENDGRID_GET_ALL_LISTS - 联系人添加为异步操作(返回202);务必延迟后验证结果
Legacy vs Marketing API
旧版API vs 营销API
- Some tools use the legacy Contact Database API () which may return 403 on newer accounts
/v3/contactdb/ - Prefer Marketing API tools: ,
SENDGRID_ADD_OR_UPDATE_A_CONTACT,SENDGRID_RETRIEVE_ALL_LISTSSENDGRID_CREATE_SINGLE_SEND
- 部分工具使用旧版联系人数据库API(),在新账户上可能返回403错误
/v3/contactdb/ - 优先使用营销API工具:、
SENDGRID_ADD_OR_UPDATE_A_CONTACT、SENDGRID_RETRIEVE_ALL_LISTSSENDGRID_CREATE_SINGLE_SEND
Quick Reference
快速参考
| Task | Tool Slug | Key Params |
|---|---|---|
| List marketing lists | | |
| Create list | | |
| Get list by ID | | |
| Get list count | | |
| Add/update contacts | | |
| Search contacts by email | | |
| Search by identifiers | | |
| Remove from list | | |
| Delete list | | |
| Import contacts CSV | | field mappings |
| Create Single Send | | |
| List sender identities | | (none) |
| Create sender | | |
| Verify sender | | |
| Authenticate domain | | |
| Global email stats | | |
| Category stats | | |
| Filter email activity | | |
| Message details | | |
| Export CSV | | |
| Download CSV | | |
| List categories | | (none) |
| Suppression groups | | (none) |
| Get template | | |
| Duplicate template | | |
| 任务 | 工具标识 | 关键参数 |
|---|---|---|
| 列出营销列表 | | |
| 创建列表 | | |
| 通过ID获取列表 | | |
| 获取列表联系人数量 | | |
| 添加/更新联系人 | | |
| 通过邮箱搜索联系人 | | |
| 通过标识符搜索联系人 | | |
| 从列表移除联系人 | | |
| 删除列表 | | |
| CSV导入联系人 | | 字段映射 |
| 创建单次发送活动 | | |
| 列出发件人身份 | | 无 |
| 创建发件人 | | |
| 验证发件人 | | |
| 域名认证 | | |
| 全局邮件统计 | | |
| 分类统计 | | |
| 筛选邮件活动 | | |
| 消息详情 | | |
| 导出CSV | | |
| 下载CSV | | |
| 列出分类 | | 无 |
| 退订组 | | 无 |
| 获取模板 | | |
| 复制模板 | | |