Calendly
Calendly
通过托管的OAuth认证访问Calendly API。获取事件类型、预定事件、受邀者、可用性数据,并管理用于日程安排自动化的webhook订阅。
快速开始
# 获取当前用户
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/users/me')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
基础URL
https://gateway.maton.ai/calendly/{native-api-path}
将{native-api-path}替换为实际的Calendly API端点路径。网关将请求代理至api.calendly.com并自动注入您的OAuth令牌。
认证
所有请求都需要在Authorization头部包含Maton API密钥:
Authorization: Bearer $MATON_API_KEY
环境变量:将您的API密钥设置为MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
获取您的API密钥
- 登录或在以下网址创建账户:maton.ai
- 前往maton.ai/settings
- 复制您的API密钥
连接管理
在以下网址管理您的Calendly OAuth连接:https://ctrl.maton.ai。
列出连接
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=calendly&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
创建连接
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'calendly'}).encode()
req = urllib.request.Request('https://ctrl.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
获取连接
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.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
响应:
{
"connection": {
"connection_id": "21fd90f9-5935-43cd-b6c8-bde9d915ca80",
"status": "ACTIVE",
"creation_time": "2025-12-08T07:20:53.488460Z",
"last_updated_time": "2026-01-31T20:03:32.593153Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "calendly",
"metadata": {}
}
}
打开返回的网址在浏览器中完成 OAuth 授权。
删除连接
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.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
指定连接
如果您有多个 Calendly 连接,请使用Maton-Connection请求头来指定要使用哪一个:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/users/me')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '21fd90f9-5935-43cd-b6c8-bde9d915ca80')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
如果省略,网关将使用默认(最早创建的)活跃连接。
API 参考
用户
获取当前用户
GET /calendly/users/me
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/users/me')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"resource": {
"uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
"name": "Alice Johnson",
"slug": "alice-johnson",
"email": "alice.johnson@acme.com",
"scheduling_url": "https://calendly.com/alice-johnson",
"timezone": "America/New_York",
"avatar_url": "https://example.com/avatar.png",
"created_at": "2024-01-15T10:30:00.000000Z",
"updated_at": "2025-06-20T14:45:00.000000Z",
"current_organization": "https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB"
}
}
获取用户
GET /calendly/users/{uuid}
事件类型
列出事件类型
GET /calendly/event_types
查询参数:
用户- 用于筛选事件类型的用户URI组织- 用于筛选事件类型的组织URI激活状态- 按激活状态筛选(真/假)数量- 返回结果的数量(默认20,最大100)页面令牌- 用于分页的令牌排序- 排序顺序(例如,名称:升序),created_at:desc)
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/event_types?user=https://api.calendly.com/users/AAAAAAAAAAAAAAAA&active=true')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"collection": [
{
"uri": "https://api.calendly.com/event_types/CCCCCCCCCCCCCCCC",
"name": "30 分钟会议",
"active": true,
"slug": "30min",
"scheduling_url": "https://calendly.com/alice-johnson/30min",
"duration": 30,
"kind": "solo",
"type": "StandardEventType",
"color": "#0066FF",
"created_at": "2024-02-01T09:00:00.000000Z",
"updated_at": "2025-05-15T11:30:00.000000Z",
"description_plain": "一次快速的 30 分钟跟进通话",
"description_html": "<p>一次快速的 30 分钟跟进通话</p>",
"profile": {
"type": "User",
"name": "Alice Johnson",
"owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA"
}
}
],
"pagination": {
"count": 1,
"next_page_token": null
}
}
获取事件类型
GET /calendly/event_types/{uuid}
已安排事件
列出已安排事件
GET /calendly/scheduled_events
查询参数:
user- 用于筛选事件的用户 URIorganization- 用于筛选事件的组织 URIinvitee_email- 按受邀者邮箱筛选状态- 按状态筛选 (活跃、已取消)最小开始时间- 筛选在此时间之后开始的事件(ISO 8601格式)最大开始时间- 筛选在此时间之前开始的事件(ISO 8601格式)数量- 结果数量(默认20,最大100)页面令牌- 用于分页的令牌排序- 排序顺序(例如:开始时间:升序)
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/scheduled_events?user=https://api.calendly.com/users/AAAAAAAAAAAAAAAA&status=active&min_start_time=2025-03-01T00:00:00Z')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"collection": [
{
"uri": "https://api.calendly.com/scheduled_events/DDDDDDDDDDDDDDDD",
"name": "30 分钟会议",
"status": "active",
"start_time": "2025-03-15T14:00:00.000000Z",
"end_time": "2025-03-15T14:30:00.000000Z",
"event_type": "https://api.calendly.com/event_types/CCCCCCCCCCCCCCCC",
"location": {
"type": "zoom",
"join_url": "https://zoom.us/j/123456789"
},
"invitees_counter": {
"total": 1,
"active": 1,
"limit": 1
},
"created_at": "2025-03-10T09:15:00.000000Z",
"updated_at": "2025-03-10T09:15:00.000000Z",
"event_memberships": [
{
"user": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA"
}
]
}
],
"pagination": {
"count": 1,
"next_page_token": null
}
}
获取预定事件
GET /calendly/scheduled_events/{uuid}
取消预定事件
POST /calendly/scheduled_events/{uuid}/cancellation
Content-Type: application/json
{
"reason": "会议重新安排"
}
示例:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'reason': '会议重新安排'}).encode()
req = urllib.request.Request('https://gateway.maton.ai/calendly/scheduled_events/DDDDDDDDDDDDDDDD/cancellation', 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 /calendly/scheduled_events/{event_uuid}/invitees
查询参数:
status- 按状态过滤 (active,canceled电子邮件- 按受邀者电子邮件筛选数量- 结果数量(默认 20,最多 100)页面令牌- 用于分页的令牌排序- 排序顺序(例如:created_at:asc)示例:
python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://gateway.maton.ai/calendly/scheduled_events/DDDDDDDDDDDDDDDD/invitees') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF
响应:
{ "collection": [ { "uri": "https://api.calendly.com/scheduled_events/DDDDDDDDDDDDDDDD/invitees/EEEEEEEEEEEEEEEE", "email": "bob.smith@example.com", "name": "Bob Smith", "status": "active", "timezone": "America/Los_Angeles", "event": "https://api.calendly.com/scheduled_events/DDDDDDDDDDDDDDDD", "created_at": "2025-03-10T09:15:00.000000Z", "updated_at": "2025-03-10T09:15:00.000000Z", "questions_and_answers": [ { "question": "What would you like to discuss?", "answer": "Project timeline review", "position": 0 } ], "tracking": { "utm_source": null, "utm_medium": null, "utm_campaign": null }, "cancel_url": "https://calendly.com/cancellations/EEEEEEEEEEEEEEEE", "reschedule_url": "https://calendly.com/reschedulings/EEEEEEEEEEEEEEEE" } ], "pagination": { "count": 1, "next_page_token": null } }
获取受邀者
GET /calendly/scheduled_events/{event_uuid}/invitees/{invitee_uuid}
创建活动受邀者(Scheduling API)
通过创建受邀者以编程方式安排会议。需要付费的 Calendly 套餐。
Schedule a meeting programmatically by creating an invitee. Requires a paid Calendly plan.
POST /calendly/event_types/{event_type_uuid}/invitees
Content-Type: application/json
{
"start_time": "2025-03-20T15:00:00Z",
"email": "bob.smith@example.com",
"name": "Bob Smith",
"timezone": "America/Los_Angeles",
"location": {
"kind": "zoom"
},
"questions_and_answers": [
{
"question_uuid": "QQQQQQQQQQQQQQQ",
"answer": "Project timeline review"
}
]
}
示例:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'start_time': '2025-03-20T15:00:00Z', 'email': 'bob.smith@example.com', 'name': 'Bob Smith'}).encode()
req = urllib.request.Request('https://gateway.maton.ai/calendly/event_types/CCCCCCCCCCCCCCCC/invitees', 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
注意:start_time必须对应一个有效的可用时间段。请使用/event_type_available_times接口来查找可用时间。可用性
获取事件类型可用时间
GET /calendly/event_type_available_times
查询参数:
event_type
- 事件类型 URI(必需)start_time- 时间范围的开始时间(ISO 8601 格式,必需)end_time- 时间范围的结束时间(ISO 8601 格式,必需,最晚为开始时间后 7 天)- End of time range (ISO 8601, required, max 7 days from start)
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/event_type_available_times?event_type=https://api.calendly.com/event_types/CCCCCCCCCCCCCCCC&start_time=2025-03-15T00:00:00Z&end_time=2025-03-22T00:00:00Z')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"collection": [
{
"status": "available",
"invitees_remaining": 1,
"start_time": "2025-03-17T14:00:00.000000Z",
"scheduling_url": "https://calendly.com/alice-johnson/30min/2025-03-17T14:00:00Z"
},
{
"status": "available",
"invitees_remaining": 1,
"start_time": "2025-03-17T14:30:00.000000Z",
"scheduling_url": "https://calendly.com/alice-johnson/30min/2025-03-17T14:30:00Z"
}
]
}
获取用户繁忙时间
GET /calendly/user_busy_times
查询参数:
user- 用户 URI(必需)start_time- 时间范围的开始时间(ISO 8601 格式,必需)end_time- 时间范围的结束时间(ISO 8601 格式,必需,距离开始时间最多 7 天)
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/user_busy_times?user=https://api.calendly.com/users/AAAAAAAAAAAAAAAA&start_time=2025-03-15T00:00:00Z&end_time=2025-03-22T00:00:00Z')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"collection": [
{
"type": "calendly",
"start_time": "2025-03-17T10:00:00.000000Z",
"end_time": "2025-03-17T11:00:00.000000Z"
},
{
"type": "external",
"start_time": "2025-03-18T14:00:00.000000Z",
"end_time": "2025-03-18T15:00:00.000000Z"
}
]
}
获取用户可用性日程
GET /calendly/user_availability_schedules
查询参数:
用户- 用户 URI(必需)
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/user_availability_schedules?user=https://api.calendly.com/users/AAAAAAAAAAAAAAAA')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
组织
列出组织成员资格
GET /calendly/organization_memberships
查询参数:
组织- 组织 URI(必需)用户- 用于筛选的用户 URI电子邮件- 用于筛选的电子邮件数量- 结果数量(默认 20,最大 100)页面令牌- 用于分页的令牌
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/organization_memberships?organization=https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
响应:
{
"collection": [
{
"uri": "https://api.calendly.com/organization_memberships/FFFFFFFFFFFFFFFF",
"role": "admin",
"user": {
"uri": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA",
"name": "Alice Johnson",
"email": "alice.johnson@acme.com"
},
"organization": "https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB",
"created_at": "2024-01-15T10:30:00.000000Z",
"updated_at": "2025-06-20T14:45:00.000000Z"
}
],
"pagination": {
"count": 1,
"next_page_token": null
}
}
Webhooks
Webhooks 需要付费的 Calendly 套餐(Standard、Teams 或 Enterprise)。
列出 Webhook 订阅
GET /calendly/webhook_subscriptions
查询参数:
organization- 组织 URI(必需)scope- 按范围过滤(user、organization)user- 要过滤的用户 URI(当范围为user时)计数- 结果数量(默认20,最大100)页面令牌- 用于分页的令牌
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/webhook_subscriptions?organization=https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB&scope=organization')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
创建Webhook订阅
POST /calendly/webhook_subscriptions
Content-Type: application/json
{
"url": "https://example.com/webhook",
"events": ["invitee.created", "invitee.canceled"],
"organization": "https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB",
"scope": "organization",
"signing_key": "your-secret-key"
}
可用事件:
invitee.created- 当受邀者安排事件时触发invitee.canceled- 当受邀者取消事件时触发routing_form_submission.created- 当提交路由表单时触发
示例:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'url': 'https://example.com/webhook', 'events': ['invitee.created', 'invitee.canceled'], 'organization': 'https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB', 'scope': 'organization'}).encode()
req = urllib.request.Request('https://gateway.maton.ai/calendly/webhook_subscriptions', 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
响应:
{
"resource": {
"uri": "https://api.calendly.com/webhook_subscriptions/GGGGGGGGGGGGGGGG",
"callback_url": "https://example.com/webhook",
"created_at": "2025-03-01T12:00:00.000000Z",
"updated_at": "2025-03-01T12:00:00.000000Z",
"retry_started_at": null,
"state": "active",
"events": ["invitee.created", "invitee.canceled"],
"scope": "organization",
"organization": "https://api.calendly.com/organizations/BBBBBBBBBBBBBBBB",
"user": null,
"creator": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA"
}
}
获取 Webhook 订阅
GET /calendly/webhook_subscriptions/{uuid}
删除 Webhook 订阅
DELETE /calendly/webhook_subscriptions/{uuid}
示例:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/webhook_subscriptions/GGGGGGGGGGGGGGGG', 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
返回204 无内容表示成功。
分页
使用page_token进行分页。当存在更多结果时,响应中会包含pagination.next_page_token:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/calendly/scheduled_events?user=USER_URI&page_token=NEXT_PAGE_TOKEN')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
代码示例
JavaScript
const response = await fetch(
'https://gateway.maton.ai/calendly/scheduled_events?user=https://api.calendly.com/users/AAAAAAAAAAAAAAAA&status=active',
{
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`
}
}
);
const data = await response.json();
Python
import os
import requests
response = requests.get(
'https://gateway.maton.ai/calendly/scheduled_events',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
params={
'user': 'https://api.calendly.com/users/AAAAAAAAAAAAAAAA',
'status': 'active'
}
)
data = response.json()
备注
- 资源标识符是 URI(例如,
https://api.calendly.com/users/AAAAAAAAAAAAAAAA) - 时间戳采用 ISO 8601 格式
- 调度 API(创建事件受邀者)需要付费的 Calendly 计划
- Calendly 免费计划不支持 Webhook
- 可用性端点每个请求的最大时间范围为 7 天,且
start_time必须是将来的时间 - 该 API 不支持以编程方式创建或管理事件类型
- 重要提示:当通过管道将 curl 输出传递给
jq或其他命令时,环境变量如$MATON_API_KEY在某些 shell 环境中可能无法正确展开。通过管道传递时,您可能会收到“无效的 API 密钥”错误。
错误处理
| 状态码 | 含义 |
|---|---|
| 400 | 错误的请求或缺少Calendly连接 |
| 401 | 无效或缺少Maton API密钥 |
| 403 | 禁止访问 - 权限不足或受计划限制 |
| 404 | 未找到资源 |
| 424 | 外部日历错误(Calendly端的日历集成问题) |
| 429 | 请求频率受限 |
| 4xx/5xx | 来自Calendly API的直通错误 |
故障排除:API密钥问题
- 检查
MATON_API_KEY环境变量是否已设置:
echo $MATON_API_KEY
- 通过列出连接来验证API密钥是否有效:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.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
故障排除:无效的应用名称
- 请确保您的URL路径以
calendly开头。例如:
- 正确示例:
https://gateway.maton.ai/calendly/users/me - 错误示例:
https://gateway.maton.ai/users/me


微信扫一扫,打赏作者吧~