通过托管 OAuth 调用 SendGrid v3 接口,发送邮件并管理联系人、模板与发件人。
集成
beehiiv
通过托管 OAuth 连接,管理 beehiiv 出版物、订阅者、帖子、自定义字段、用户分群、订阅分层与自动化流程。
它能做什么
调用时向 https://api.maton.ai/beehiiv/v2/ 发起请求,Authorization 头中以 Bearer 方式携带 MATON_API_KEY,由网关代理至 api.beehiiv.com 并自动注入 OAuth 令牌。可用接口覆盖出版物、订阅者(列表、按 ID 或邮箱查询、创建、更新、删除)、帖子、自定义字段、用户分群、订阅分层、自动化流程以及推荐计划。订阅者分页推荐使用游标(next_cursor),单页 1–100 条;页码分页已弃用,最深 100 页。多账号场景需通过 Maton-Connection 头指定连接 ID。
什么时候用它
- 按状态、分层或邮箱筛选订阅者列表
- 为出版物创建或更新自定义字段
- 管理付费通讯录的订阅分层与用户分群
- 查询某出版物下的自动化流程与帖子记录
技能文档
beehiiv
Access the beehiiv API with managed OAuth authentication. Manage newsletter publications, subscriptions, posts, custom fields, segments, tiers, and automations.
Quick Start
# List publications
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://api.maton.ai/beehiiv/v2/publications')
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/beehiiv/{native-api-path}
Maton proxies requests to api.beehiiv.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 beehiiv 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=beehiiv&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': 'beehiiv'}).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-11T00:25:10.464852Z",
"last_updated_time": "2026-02-11T00:27:00.816431Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "beehiiv",
"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 beehiiv 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/beehiiv/v2/publications')
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 newsletter publications, subscriptions, posts, custom fields, segments, and automations within the connected beehiiv 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.
API Reference
All beehiiv API endpoints follow this pattern:
/beehiiv/v2/{resource}
Publications
List Publications
GET /beehiiv/v2/publications
Query Parameters:
| Parameter | Description |
|---|---|
limit | Results per page (1-100, default: 10) |
page | Page number (default: 1) |
expand[] | Expand with: stats, stat_active_subscriptions, stat_average_open_rate, etc. |
order_by | Sort by: created or name |
direction | Sort direction: asc or desc |
Response:
{
"data": [
{
"id": "pub_c6c521e4-91ac-4c14-8a52-06987b7e32f2",
"name": "My Newsletter",
"organization_name": "My Organization",
"referral_program_enabled": true,
"created": 1770767522
}
],
"page": 1,
"limit": 10,
"total_results": 1,
"total_pages": 1
}
Get Publication
GET /beehiiv/v2/publications/{publication_id}
Subscriptions
List Subscriptions
GET /beehiiv/v2/publications/{publication_id}/subscriptions
Query Parameters:
| Parameter | Description |
|---|---|
limit | Results per page (1-100, default: 10) |
cursor | Cursor for pagination (recommended) |
page | Page number (deprecated, max 100 pages) |
email | Filter by exact email (case-insensitive) |
status | Filter: validating, invalid, pending, active, inactive, all |
tier | Filter: free, premium, all |
expand[] | Expand with: stats, custom_fields, referrals |
order_by | Sort field (default: created) |
direction | Sort direction: asc or desc |
Response:
{
"data": [
{
"id": "sub_c27d9640-f418-43a8-a0f9-528c20a05002",
"email": "[email protected]",
"status": "active",
"created": 1770767524,
"subscription_tier": "free",
"subscription_premium_tier_names": [],
"utm_source": "direct",
"utm_medium": "",
"utm_channel": "website",
"utm_campaign": "",
"referring_site": "",
"referral_code": "gBZbSVal1X",
"stripe_customer_id": ""
}
],
"limit": 10,
"has_more": false,
"next_cursor": null
}
Get Subscription by ID
GET /beehiiv/v2/publications/{publication_id}/subscriptions/{subscription_id}
Query Parameters:
| Parameter | Description |
|---|---|
expand[] | Expand with: stats, custom_fields, referrals, tags |
Get Subscription by Email
GET /beehiiv/v2/publications/{publication_id}/subscriptions/by_email/{email}
Create Subscription
POST /beehiiv/v2/publications/{publication_id}/subscriptions
Content-Type: application/json
{
"email": "[email protected]",
"utm_source": "api",
"send_welcome_email": false,
"reactivate_existing": false
}
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Subscriber email address |
reactivate_existing | boolean | No | Reactivate if previously unsubscribed |
send_welcome_email | boolean | No | Send welcome email |
utm_source | string | No | UTM source for tracking |
utm_medium | string | No | UTM medium |
referring_site | string | No | Referral code of referring subscriber |
custom_fields | object | No | Custom field values (fields must exist) |
double_opt_override | string | No | on or off to override double opt-in |
tier | string | No | Subscription tier |
premium_tier_names | array | No | Premium tier names to assign |
Update Subscription
PATCH /beehiiv/v2/publications/{publication_id}/subscriptions/{subscription_id}
Content-Type: application/json
{
"utm_source": "updated-source",
"custom_fields": [
{"name": "First Name", "value": "John"}
]
}
Delete Subscription
DELETE /beehiiv/v2/publications/{publication_id}/subscriptions/{subscription_id}
Posts
List Posts
GET /beehiiv/v2/publications/{publication_id}/posts
Query Parameters:
| Parameter | Description |
|---|---|
limit | Results per page (1-100, default: 10) |
page | Page number |
status | Filter by status |
expand[] | Expand with additional data |
Response:
{
"data": [],
"page": 1,
"limit": 10,
"total_results": 0,
"total_pages": 0
}
Get Post
GET /beehiiv/v2/publications/{publication_id}/posts/{post_id}
Delete Post
DELETE /beehiiv/v2/publications/{publication_id}/posts/{post_id}
Custom Fields
List Custom Fields
GET /beehiiv/v2/publications/{publication_id}/custom_fields
Response:
{
"data": [
{
"id": "95c9653f-a1cf-45f0-a140-97feef19057b",
"kind": "string",
"display": "Last Name",
"created": 1770767523
},
{
"id": "4cfe081e-c89b-4da5-9c1a-52a4fb8ba69e",
"kind": "string",
"display": "First Name",
"created": 1770767523
}
],
"page": 1,
"limit": 10,
"total_results": 2,
"total_pages": 1
}
Field Kinds: string, integer, boolean, date, datetime, list, double
Create Custom Field
POST /beehiiv/v2/publications/{publication_id}/custom_fields
Content-Type: application/json
{
"display": "Company",
"kind": "string"
}
Update Custom Field
PATCH /beehiiv/v2/publications/{publication_id}/custom_fields/{custom_field_id}
Content-Type: application/json
{
"display": "Company Name"
}
Delete Custom Field
DELETE /beehiiv/v2/publications/{publication_id}/custom_fields/{custom_field_id}
Segments
List Segments
GET /beehiiv/v2/publications/{publication_id}/segments
Response:
{
"data": [],
"page": 1,
"limit": 10,
"total_results": 0,
"total_pages": 0
}
Get Segment
GET /beehiiv/v2/publications/{publication_id}/segments/{segment_id}
Delete Segment
DELETE /beehiiv/v2/publications/{publication_id}/segments/{segment_id}
Tiers
List Tiers
GET /beehiiv/v2/publications/{publication_id}/tiers
Get Tier
GET /beehiiv/v2/publications/{publication_id}/tiers/{tier_id}
Create Tier
POST /beehiiv/v2/publications/{publication_id}/tiers
Content-Type: application/json
{
"name": "Premium",
"description": "Premium tier with exclusive content"
}
Update Tier
PATCH /beehiiv/v2/publications/{publication_id}/tiers/{tier_id}
Content-Type: application/json
{
"name": "Updated Tier Name"
}
Automations
List Automations
GET /beehiiv/v2/publications/{publication_id}/automations
Get Automation
GET /beehiiv/v2/publications/{publication_id}/automations/{automation_id}
Referral Program
Get Referral Program
GET /beehiiv/v2/publications/{publication_id}/referral_program
Pagination
beehiiv supports two pagination methods:
Cursor-Based (Recommended)
GET /beehiiv/v2/publications/{publication_id}/subscriptions?limit=10&cursor={next_cursor}
Response includes:
{
"data": [...],
"limit": 10,
"has_more": true,
"next_cursor": "eyJ0aW1lc3RhbXAiOiIyMDI0LTA3LTAyVDE3OjMwOjAwLjAwMDAwMFoifQ=="
}
Use the next_cursor value for subsequent requests.
Page-Based (Deprecated)
GET /beehiiv/v2/publications?page=2&limit=10
Response includes:
{
"data": [...],
"page": 2,
"limit": 10,
"total_results": 50,
"total_pages": 5
}
Note: Page-based pagination is limited to 100 pages maximum.
Code Examples
JavaScript
const response = await fetch(
'https://api.maton.ai/beehiiv/v2/publications',
{
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
}
}
);
const data = await response.json();
console.log(data.data);
Python
import os
import requests
response = requests.get(
'https://api.maton.ai/beehiiv/v2/publications',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}
)
data = response.json()
for pub in data['data']:
print(f"{pub['id']}: {pub['name']}")
Notes
- Publication IDs start with
pub_ - Subscription IDs start with
sub_ - Timestamps are Unix timestamps (seconds since epoch)
- Custom fields must be created before use in subscriptions
- Cursor-based pagination is recommended for better performance
- Page-based pagination is deprecated and limited to 100 pages
- 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 invalid parameters |
| 401 | Invalid or missing Maton API key |
| 403 | Forbidden - insufficient permissions or plan limitation |
| 404 | Resource not found |
| 429 | Rate limited |
| 500 | Internal server error |
Troubleshooting: API Key Issues
- Check that the
MATON_API_KEYenvironment variable is set:
echo $MATON_API_KEY
- 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
beehiiv. For example:
- Correct:
https://api.maton.ai/beehiiv/v2/publications - Incorrect:
https://api.maton.ai/v2/publications
Resources
相关技能
通过托管 OAuth 以编程方式访问 ClickFunnels 2.0 的联系人、商品、订单、课程、表单和 Webhook。
通过统一认证入口管理 Constant Contact 的联系人、列表、营销活动、标签和分析数据。
通过托管认证调用 Instantly API v2,统一管理冷邮件活动、线索、发件账户与分析数据。
通过托管 OAuth 连接,读写 Google Merchant Center 的商品、库存、促销与账户数据。
通过托管 OAuth 代理调用 Apollo.io API,完成人员与公司搜索、联系人补全和销售数据管理。