通过统一认证入口管理 Constant Contact 的联系人、列表、营销活动、标签和分析数据。
集成
SendGrid
通过托管 OAuth 调用 SendGrid v3 接口,发送邮件并管理联系人、模板与发件人。
它能做什么
覆盖 Mail Send、营销联系人与列表、分群、模板、发件人以及抑制管理(退回、屏蔽)。请求经 Maton 代理转发,在 Authorization 头中传入 MATON_API_KEY 即可认证;多账号场景可通过 Maton-Connection 头指定目标连接。所有写入操作都需要用户明确确认;邮件发送会触达真实收件人;SendGrid API 密钥管理会生成独立于会话的长期凭证。
什么时候用它
- 发送事务性或营销邮件
- 管理营销联系人、列表与分群
- 创建并维护动态模板版本
- 查看并清理退回、屏蔽记录
技能文档
SendGrid
Access the SendGrid API with managed OAuth authentication. Send transactional and marketing emails, manage contacts, templates, suppressions, and analyze email performance.
Quick Start
# Get user profile
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/sendgrid/v3/user/profile')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Base URL
https://api.maton.ai/sendgrid/{native-api-path}
Maton proxies requests to api.sendgrid.com and automatically injects your OAuth token.
Authentication
All requests require the Maton API key in the Authorization header:
Authorization: Bearer $MATON_API_KEY
Environment Variable: Set your API key as MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
Getting Your API Key
- Sign in or create an account at maton.ai
- Go to maton.ai/settings
- Copy your API key
Connection Management
Manage your SendGrid OAuth connections at https://api.maton.ai.
List Connections
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections?app=sendgrid&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Create Connection
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'sendgrid'}).encode()
req = urllib.request.Request('https://api.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Get Connection
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Response:
{
"connection": {
"connection_id": "{connection_id}",
"status": "ACTIVE",
"creation_time": "2026-02-11T10:53:41.817938Z",
"last_updated_time": "2026-02-11T10:54:05.554084Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "sendgrid",
"metadata": {}
}
}
Open the returned url in a browser to complete OAuth authorization.
Delete Connection
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Specifying Connection
If you have multiple SendGrid connections, specify which one to use with the Maton-Connection header:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/sendgrid/v3/user/profile')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '{connection_id}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
If you have multiple connections, always include this header to ensure requests go to the intended account.
Security & Permissions
- Access is scoped to email sending, contacts, lists, templates, sender identities, suppressions, unsubscribe groups, statistics, and SendGrid API key management within the connected SendGrid account.
- All write operations require explicit user approval. Before executing any create, update, or delete call, confirm the target resource and intended effect with the user.
- Email sending delivers messages to real recipients. Always confirm the recipient(s), subject, content, and sender identity with the user before sending.
- API key management creates, updates, or deletes SendGrid API keys. These are long-lived credentials that persist independently of the Maton connection. Only invoke when the user explicitly requests key management. Never expose created key values in output.
API Reference
All SendGrid API endpoints follow this pattern:
/sendgrid/v3/{resource}
Mail Send
Send Email
POST /sendgrid/v3/mail/send
Content-Type: application/json
{
"personalizations": [
{
"to": [{"email": "[email protected]", "name": "Recipient"}],
"subject": "Hello from SendGrid"
}
],
"from": {"email": "[email protected]", "name": "Sender"},
"content": [
{
"type": "text/plain",
"value": "This is a test email."
}
]
}
With HTML content:
POST /sendgrid/v3/mail/send
Content-Type: application/json
{
"personalizations": [
{
"to": [{"email": "[email protected]"}],
"subject": "HTML Email"
}
],
"from": {"email": "[email protected]"},
"content": [
{
"type": "text/html",
"value": "HelloThis is an HTML email."
}
]
}
With template:
POST /sendgrid/v3/mail/send
Content-Type: application/json
{
"personalizations": [
{
"to": [{"email": "[email protected]"}],
"dynamic_template_data": {
"first_name": "John",
"order_id": "12345"
}
}
],
"from": {"email": "[email protected]"},
"template_id": "d-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
User Profile
Get User Profile
GET /sendgrid/v3/user/profile
Response:
{
"type": "user",
"userid": 59796657
}
Get Account Details
GET /sendgrid/v3/user/account
Marketing Contacts
List Contacts
GET /sendgrid/v3/marketing/contacts
Response:
{
"result": [],
"contact_count": 0,
"_metadata": {
"self": "https://api.sendgrid.com/v3/marketing/contacts"
}
}
Search Contacts
POST /sendgrid/v3/marketing/contacts/search
Content-Type: application/json
{
"query": "email LIKE '%@example.com%'"
}
Add/Update Contacts
PUT /sendgrid/v3/marketing/contacts
Content-Type: application/json
{
"contacts": [
{
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
]
}
Response:
{
"job_id": "2387e363-4104-4225-8960-4a5758492351"
}
Note: Contact operations are asynchronous. Use the job status endpoint to check progress.
Get Import Job Status
GET /sendgrid/v3/marketing/contacts/imports/{job_id}
Response:
{
"id": "2387e363-4104-4225-8960-4a5758492351",
"status": "pending",
"job_type": "upsert_contacts",
"results": {
"requested_count": 1,
"created_count": 1
},
"started_at": "2026-02-11T11:00:14Z"
}
Delete Contacts
DELETE /sendgrid/v3/marketing/contacts?ids=contact_id_1,contact_id_2
Get Contact by ID
GET /sendgrid/v3/marketing/contacts/{contact_id}
Get Contact by Email
POST /sendgrid/v3/marketing/contacts/search/emails
Content-Type: application/json
{
"emails": ["[email protected]"]
}
Marketing Lists
List All Lists
GET /sendgrid/v3/marketing/lists
Response:
{
"result": [],
"_metadata": {
"self": "https://api.sendgrid.com/v3/marketing/lists?page_size=100&page_token="
}
}
Create List
POST /sendgrid/v3/marketing/lists
Content-Type: application/json
{
"name": "My Contact List"
}
Response:
{
"name": "My Contact List",
"id": "b050f139-4231-47c8-bf32-94ad76376d3b",
"contact_count": 0,
"_metadata": {
"self": "https://api.sendgrid.com/v3/marketing/lists/b050f139-4231-47c8-bf32-94ad76376d3b"
}
}
Get List by ID
GET /sendgrid/v3/marketing/lists/{list_id}
Update List
PATCH /sendgrid/v3/marketing/lists/{list_id}
Content-Type: application/json
{
"name": "Updated List Name"
}
Delete List
DELETE /sendgrid/v3/marketing/lists/{list_id}
Add Contacts to List
PUT /sendgrid/v3/marketing/contacts
Content-Type: application/json
{
"list_ids": ["list_id"],
"contacts": [
{"email": "[email protected]"}
]
}
Segments
List Segments
GET /sendgrid/v3/marketing/segments
Create Segment
POST /sendgrid/v3/marketing/segments
Content-Type: application/json
{
"name": "Active Users",
"query_dsl": "email_clicks > 0"
}
Get Segment by ID
GET /sendgrid/v3/marketing/segments/{segment_id}
Delete Segment
DELETE /sendgrid/v3/marketing/segments/{segment_id}
Templates
List Templates
GET /sendgrid/v3/templates
With generation filter:
GET /sendgrid/v3/templates?generations=dynamic
Create Template
POST /sendgrid/v3/templates
Content-Type: application/json
{
"name": "My Template",
"generation": "dynamic"
}
Response:
{
"id": "d-ffcdb43ed8a04beba48a702e1717ddb5",
"name": "My Template",
"generation": "dynamic",
"updated_at": "2026-02-11 11:00:20",
"versions": []
}
Get Template by ID
GET /sendgrid/v3/templates/{template_id}
Update Template
PATCH /sendgrid/v3/templates/{template_id}
Content-Type: application/json
{
"name": "Updated Template Name"
}
Delete Template
DELETE /sendgrid/v3/templates/{template_id}
Create Template Version
POST /sendgrid/v3/templates/{template_id}/versions
Content-Type: application/json
{
"name": "Version 1",
"subject": "{{subject}}",
"html_content": "Hello {{name}}",
"active": 1
}
Response:
{
"id": "54230a99-1e89-4edf-821d-d4925b40c64b",
"template_id": "d-ffcdb43ed8a04beba48a702e1717ddb5",
"active": 1,
"name": "Version 1",
"html_content": "Hello {{name}}",
"plain_content": "Hello {{name}}",
"generate_plain_content": true,
"subject": "{{subject}}",
"editor": "code",
"thumbnail_url": "//..."
}
Senders
List Senders
GET /sendgrid/v3/senders
Create Sender
POST /sendgrid/v3/senders
Content-Type: application/json
{
"nickname": "My Sender",
"from": {"email": "[email protected]", "name": "Sender Name"},
"reply_to": {"email": "[email protected]", "name": "Reply To"},
"address": "123 Main St",
"city": "San Francisco",
"country": "USA"
}
Response:
{
"id": 8513177,
"nickname": "My Sender",
"from": {"email": "[email protected]", "name": "Sender Name"},
"reply_to": {"email": "[email protected]", "name": "Reply To"},
"address": "123 Main St",
"city": "San Francisco",
"country": "USA",
"verified": {"status": false, "reason": null},
"updated_at": 1770786031,
"created_at": 1770786031,
"locked": false
}
Note: Sender verification is required before use. Check verified.status.
Get Sender by ID
GET /sendgrid/v3/senders/{sender_id}
Update Sender
PATCH /sendgrid/v3/senders/{sender_id}
Content-Type: application/json
{
"nickname": "Updated Sender Name"
}
Delete Sender
DELETE /sendgrid/v3/senders/{sender_id}
Suppressions
Bounces
# List bounces
GET /sendgrid/v3/suppression/bounces
# Get bounce by email
GET /sendgrid/v3/suppression/bounces/{email}
# Delete bounces
DELETE /sendgrid/v3/suppression/bounces
Content-Type: application/json
{
"emails": ["[email protected]"]
}
Blocks
# List blocks
GET /sendgrid/v3/suppression/blocks
# Get block by email
GET /sendgrid/v3/suppression/blocks/{email}
# Delete blocks
DELETE /sendgrid/v3/suppression/blocks
Content-Type: application/json
{
"emails": ["[email protected]"]
}
Invalid Emails
# List invalid emails
GET /sendgrid/v3/suppression/invalid_emails
# Delete invalid emails
DELETE /sendgrid/v3/suppression/invalid_emails
Content-Type: application/json
{
"emails": ["[email protected]"]
}
Spam Reports
# List spam reports
GET /sendgrid/v3/suppression/spam_reports
# Delete spam reports
DELETE /sendgrid/v3/suppression/spam_reports
Content-Type: application/json
{
"emails": ["[email protected]"]
}
Global Unsubscribes
# List global unsubscribes
GET /sendgrid/v3/suppression/unsubscribes
# Add to global unsubscribes
POST /sendgrid/v3/asm/suppressions/global
Content-Type: application/json
{
"recipient_emails": ["[email protected]"]
}
Unsubscribe Groups (ASM)
List Groups
GET /sendgrid/v3/asm/groups
Create Group
POST /sendgrid/v3/asm/groups
Content-Type: application/json
{
"name": "Weekly Newsletter",
"description": "Weekly newsletter updates"
}
Response:
{
"name": "Weekly Newsletter",
"id": 122741,
"description": "Weekly newsletter updates",
"is_default": false
}
Get Group by ID
GET /sendgrid/v3/asm/groups/{group_id}
Update Group
PATCH /sendgrid/v3/asm/groups/{group_id}
Content-Type: application/json
{
"name": "Updated Group Name"
}
Delete Group
DELETE /sendgrid/v3/asm/groups/{group_id}
Add Suppressions to Group
POST /sendgrid/v3/asm/groups/{group_id}/suppressions
Content-Type: application/json
{
"recipient_emails": ["[email protected]"]
}
List Suppressions in Group
GET /sendgrid/v3/asm/groups/{group_id}/suppressions
Statistics
Get Global Stats
GET /sendgrid/v3/stats?start_date=2026-02-01
With end date:
GET /sendgrid/v3/stats?start_date=2026-02-01&end_date=2026-02-28
Response:
[
{
"date": "2026-02-01",
"stats": [
{
"metrics": {
"blocks": 0,
"bounce_drops": 0,
"bounces": 0,
"clicks": 0,
"deferred": 0,
"delivered": 0,
"invalid_emails": 0,
"opens": 0,
"processed": 0,
"requests": 0,
"spam_report_drops": 0,
"spam_reports": 0,
"unique_clicks": 0,
"unique_opens": 0,
"unsubscribe_drops": 0,
"unsubscribes": 0
}
}
]
}
]
Category Stats
GET /sendgrid/v3/categories/stats?start_date=2026-02-01&categories=category1,category2
Mailbox Provider Stats
GET /sendgrid/v3/mailbox_providers/stats?start_date=2026-02-01
Browser Stats
GET /sendgrid/v3/browsers/stats?start_date=2026-02-01
API Keys
Credential management. API key operations create, modify, or delete long-lived SendGrid credentials that persist independently of the Maton OAuth session. A created key can be used outside this integration. Only invoke when the user explicitly requests API key management. Never log or display created key values.
List API Keys
GET /sendgrid/v3/api_keys
Response:
{
"result": [
{
"name": "MatonTest",
"api_key_id": "WJBgv5EKR8y0nn2F8Qfk5w"
}
]
}
Create API Key
POST /sendgrid/v3/api_keys
Content-Type: application/json
{
"name": "New API Key",
"scopes": ["mail.send", "alerts.read"]
}
Get API Key by ID
GET /sendgrid/v3/api_keys/{api_key_id}
Update API Key
PATCH /sendgrid/v3/api_keys/{api_key_id}
Content-Type: application/json
{
"name": "Updated Key Name"
}
Delete API Key
DELETE /sendgrid/v3/api_keys/{api_key_id}
Pagination
SendGrid uses token-based pagination for marketing endpoints:
GET /sendgrid/v3/marketing/lists?page_size=100&page_token={token}
Response includes:
{
"result": [...],
"_metadata": {
"self": "https://api.sendgrid.com/v3/marketing/lists?page_size=100&page_token=",
"next": "https://api.sendgrid.com/v3/marketing/lists?page_size=100&page_token=abc123"
}
}
For suppression endpoints, use limit and offset:
GET /sendgrid/v3/suppression/bounces?limit=100&offset=0
Code Examples
JavaScript
// Send an email
const response = await fetch(
'https://api.maton.ai/sendgrid/v3/mail/send',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
personalizations: [{
to: [{email: '[email protected]'}],
subject: 'Hello'
}],
from: {email: '[email protected]'},
content: [{type: 'text/plain', value: 'Hello World'}]
})
}
);
Python
import os
import requests
# Get email stats
response = requests.get(
'https://api.maton.ai/sendgrid/v3/stats',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
params={'start_date': '2026-02-01'}
)
data = response.json()
for day in data:
metrics = day['stats'][0]['metrics']
print(f"{day['date']}: {metrics['delivered']} delivered, {metrics['opens']} opens")
Notes
- All requests use JSON content type
- Dates are in YYYY-MM-DD format
- Template IDs for dynamic templates start with
d- - Mail send returns 202 Accepted on success (not 200)
- Marketing contact operations are asynchronous - use job status endpoints
- Suppression endpoints support date filtering with
start_timeandend_time(Unix timestamps) - IMPORTANT: When using curl commands, use
curl -gwhen URLs contain brackets to disable glob parsing - IMPORTANT: When piping curl output to
jqor other commands, environment variables like$MATON_API_KEYmay not expand correctly in some shell environments
Error Handling
| Status | Meaning |
|---|---|
| 400 | Bad request or validation error |
| 401 | Invalid or missing Maton API key |
| 403 | Insufficient permissions |
| 404 | Resource not found |
| 429 | Rate limited |
| 500 | Internal server error |
Troubleshooting: API Key Issues
- Check that the
MATON_API_KEYenvironment variable is set:
[ -n "$MATON_API_KEY" ] && echo "MATON_API_KEY is set" || echo "MATON_API_KEY is not set"
- Verify the API key is valid by listing connections:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Troubleshooting: Invalid App Name
- Ensure your URL path starts with
sendgrid. For example:
- Correct:
https://api.maton.ai/sendgrid/v3/user/profile - Incorrect:
https://api.maton.ai/v3/user/profile
Resources
常见问题
- 如何完成认证?
- 在 Authorization 头中传入 MATON_API_KEY,Maton 会将请求代理到 api.sendgrid.com 并注入对应的 OAuth 令牌。连接了多个 SendGrid 账号时,使用 Maton-Connection 头指定要访问的连接。
- 写入操作如何把关?
- 所有创建、更新、删除调用,以及任何邮件发送,都必须先与用户确认目标资源与预期效果后再执行;新创建的 SendGrid API 密钥值不得在输出中暴露。
- 支持哪些资源?
- 邮件发送、用户资料与账户、营销联系人与列表、分群、模板及其版本、发件人、抑制管理(退回、屏蔽)、退订组、统计数据,以及 SendGrid API 密钥管理,范围限定在已连接的 SendGrid 账户内。
相关技能
把 SendGrid 请求路由到对应子技能:发送事务性邮件,或通过 Inbound Parse Webhook 接收邮件。
通过托管 OAuth 以编程方式访问 ClickFunnels 2.0 的联系人、商品、订单、课程、表单和 Webhook。
通过托管认证调用 Instantly API v2,统一管理冷邮件活动、线索、发件账户与分析数据。
通过托管 OAuth 连接,读写 Google Merchant Center 的商品、库存、促销与账户数据。
通过托管 OAuth 连接,管理 beehiiv 出版物、订阅者、帖子、自定义字段、用户分群、订阅分层与自动化流程。