开发者工作流
使用 MyCaly 构建集成: REST API 与 Webhooks
了解 MyCaly 接口如何串联协作,完成预约排期、网络研讨会报名、CRM 联系人同步以及实时签名 Webhook 通知。
无需翻阅数十个零散接口。选择下方的真实集成流程,按步骤查看请求与响应的串联方式,并在交互式文档中在线调试。
https://saifmeetup.mycaly.io/api/v1
- JSON REST API v1(60 次/分钟)
- Sanctum Bearer 令牌认证
- HMAC-SHA256 签名 Webhooks
curl -X POST "https://saifmeetup.mycaly.io/api/v1/auth/login" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"email": "you@company.com",
"password": "your-password",
"device_name": "CRM Integration"
}'
# Include the returned token on protected endpoints:
# Authorization: Bearer 1|9xK3...token_hash
在控制台的 API 与 Webhooks 页面(或通过 POST /api/v1/auth/login)生成个人访问令牌,并在受保护请求中附加 Bearer 请求头。
认证方式与接口如何协同工作
受保护接口需要携带 Bearer 令牌且订阅方案已启用 REST API 权限;而公开接口可让预约组件和报名表单安全地在前端调用。
创建 API 访问令牌
在控制台“集成 -> API 与 Webhooks”中生成个人令牌,或通过 POST /api/v1/auth/tokens 以编程方式签发。
携带 Bearer 授权头
在受保护请求中添加 Authorization: Bearer <token> 与 Accept: application/json。所有响应统一使用 { success, message, data } 格式。
公开客户端接口
直接在页面组件中调用 GET /events/{id}/available-slots 与 POST /webinars/{id}/register,无需暴露私密令牌。
端到端请求链路详解
选择一个工作流并点击各个步骤,查看 ID 与时间段如何在接口之间传递。
打造定制化预约体验
加载已启用的活动类型,查询指定日期的可预约时段,然后完成创建、改期或取消预约。
curl -X GET "https://saifmeetup.mycaly.io/api/v1/events?per_page=10" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Events retrieved successfully.",
"data": {
"events": [
{
"id": 12,
"name": "30-Min Consultation",
"event_link": "30-min-consultation",
"slot_time": 30,
"event_location": 2,
"status": true,
"share_url": "/s/ali/30-min-consultation"
}
],
"pagination": { "total": 1, "per_page": 10, "current_page": 1, "last_page": 1 }
}
}
curl -X GET "https://saifmeetup.mycaly.io/api/v1/events/12/available-slots?date=2026-12-10&timezone=America/New_York" \
-H "Accept: application/json"
{
"success": true,
"message": "Available slots retrieved successfully.",
"data": {
"event_id": 12,
"event_name": "30-Min Consultation",
"slot_duration_minutes": 30,
"date": "2026-12-10",
"slots": [
"09:00 AM - 09:30 AM",
"10:00 AM - 10:30 AM",
"02:00 PM - 02:30 PM"
]
}
}
curl -X POST "https://saifmeetup.mycaly.io/api/v1/bookings" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"event_id": 12,
"schedule_date": "2026-12-10",
"slot_time": "09:00 AM - 09:30 AM",
"name": "Alex Rivera",
"email": "alex@example.com",
"phone_number": "+14155550140"
}'
{
"success": true,
"message": "Appointment booked successfully.",
"data": {
"id": 408,
"uuid": "8f3c2e10-7b1d-4d62-a210-91b7c4f0192e",
"event_id": 12,
"schedule_date": "2026-12-10",
"slot_time": "09:00 AM - 09:30 AM",
"status": 1,
"status_text": "Booked",
"source": "api",
"meeting": {
"meeting_url": "https://meethour.io/room-408",
"meeting_id": "mh_408"
}
}
}
POST /bookings/{id}/reschedule
POST /bookings/{id}/cancel
自动化直播研讨会与参会报名
通过 API 创建网络研讨会,直接从外部落地页收集报名,并同步或取消参会人记录。
curl -X POST "https://saifmeetup.mycaly.io/api/v1/webinars" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "Product Launch Live Q&A",
"event_link": "launch-qa",
"slot_time": 60,
"event_location": 2,
"schedule_from": "2026-12-15 14:00:00",
"schedule_to": "2026-12-15 15:00:00"
}'
{
"success": true,
"message": "Webinar created successfully.",
"data": {
"id": 54,
"name": "Product Launch Live Q&A",
"event_link": "launch-qa",
"schedule_from": "2026-12-15 14:00:00",
"schedule_to": "2026-12-15 15:00:00",
"slot_time": 60,
"status": true,
"share_url": "/s/ali/launch-qa"
}
}
PATCH /webinars/{id}/status
curl -X POST "https://saifmeetup.mycaly.io/api/v1/webinars/54/register" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "Sara Kim",
"email": "sara@example.com",
"phone_number": "+14155550192"
}'
{
"success": true,
"message": "Webinar registration successful.",
"data": {
"id": 915,
"event_id": 54,
"schedule_date": "2026-12-15",
"slot_time": "10:00 AM - 11:00 AM",
"guest": {
"name": "Sara Kim",
"email": "sara@example.com",
"phone": "+14155550192"
},
"status_text": "Booked"
}
}
curl -X GET "https://saifmeetup.mycaly.io/api/v1/webinars/54/attendees?per_page=50" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Webinar attendees retrieved successfully.",
"data": {
"webinar_id": 54,
"webinar_name": "Product Launch Live Q&A",
"attendees": [
{
"id": 915,
"schedule_date": "2026-12-15",
"guest": { "name": "Sara Kim", "email": "sara@example.com" },
"status_text": "Booked"
}
],
"pagination": { "total": 1, "per_page": 50, "current_page": 1, "last_page": 1 }
}
}
POST /webinars/{id}/attendees/{attendeeId}/cancel
同步客户联系人与历史预约
检索现有联系人,按邮箱幂等创建或更新线索不留重复,并拉取关联的预约记录。
curl -X GET "https://saifmeetup.mycaly.io/api/v1/contacts?search=alex&per_page=20" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Contacts retrieved successfully.",
"data": {
"contacts": [
{
"id": 77,
"name": "Alex Rivera",
"email": "alex@example.com",
"phone_number": "+14155550140",
"billing_address": "123 Market St, San Francisco, CA"
}
],
"pagination": { "total": 1, "per_page": 20, "current_page": 1, "last_page": 1 }
}
}
curl -X POST "https://saifmeetup.mycaly.io/api/v1/contacts" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "Alex Rivera",
"email": "alex@example.com",
"phone_number": "+14155550140",
"billing_address": "123 Market St, San Francisco, CA"
}'
{
"success": true,
"message": "Contact saved successfully.",
"data": {
"id": 77,
"name": "Alex Rivera",
"email": "alex@example.com",
"phone_number": "+14155550140",
"billing_address": "123 Market St, San Francisco, CA"
}
}
PUT /contacts/{id}
curl -X GET "https://saifmeetup.mycaly.io/api/v1/contacts/77" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Contact details retrieved successfully.",
"data": {
"contact": {
"id": 77,
"name": "Alex Rivera",
"email": "alex@example.com"
},
"bookings": [
{
"id": 408,
"event_id": 12,
"schedule_date": "2026-12-10",
"slot_time": "09:00 AM - 09:30 AM",
"status_text": "Booked"
}
]
}
}
订阅、测试并审计实时 Webhooks
为预约、研讨会、联系人及支付事件注册 HTTPS 接收地址,立即发送测试验证并查看投递日志。
curl -X POST "https://saifmeetup.mycaly.io/api/v1/webhooks" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "CRM Listener",
"target_url": "https://api.yourapp.com/webhooks/mycaly",
"events": ["booking.created", "booking.rescheduled", "webinar.registrant_added"]
}'
{
"success": true,
"message": "Webhook subscription registered successfully.",
"data": {
"id": 9,
"name": "CRM Listener",
"target_url": "https://api.yourapp.com/webhooks/mycaly",
"secret": "a9c8f7d6e5b4...",
"events": ["booking.created", "booking.rescheduled", "webinar.registrant_added"],
"is_active": true
}
}
curl -X POST "https://saifmeetup.mycaly.io/api/v1/webhooks/9/test" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Test webhook dispatched.",
"data": {
"id": 102,
"webhook_endpoint_id": 9,
"event_type": "endpoint.test",
"response_status": 200,
"attempt": 1,
"delivered_at": "2026-12-03T12:45:00+00:00",
"error_message": null
}
}
curl -X GET "https://saifmeetup.mycaly.io/api/v1/webhooks/9/deliveries?per_page=20" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
{
"success": true,
"message": "Delivery logs retrieved successfully.",
"data": {
"deliveries": [
{
"id": 102,
"webhook_endpoint_id": 9,
"event_type": "endpoint.test",
"response_status": 200,
"attempt": 1,
"delivered_at": "2026-12-03T12:45:00+00:00",
"error_message": null
}
],
"pagination": { "total": 1, "per_page": 20, "current_page": 1, "last_page": 1 }
}
}
使用 HMAC-SHA256 校验每一条传入 Webhook
每次 Webhook 推送都附带三个自定义请求头与标准 JSON 信封,便于服务端在执行业务逻辑前验证来源真伪。
MyCaly 发送的请求头
-
X-Signature使用您的端点密钥对原始 JSON 请求体计算的十六进制 HMAC-SHA256 摘要。
-
X-Event-Type点分隔的事件名称,例如 booking.created、booking.rescheduled 或 webinar.registrant_confirmed。
-
X-Event-Id唯一事件 ID(evt_...),用于在重试场景下做幂等去重。
核心支持事件
注册 Webhook 端点时可指定具体事件名称或使用 "*" 订阅全部事件。
booking.created, booking.pending_approval, booking.confirmed, booking.declined, booking.rescheduled, booking.cancelled
webinar.created, webinar.updated, webinar.registrant_added, webinar.registrant_confirmed, webinar.registrant_cancelled
contact.created, contact.updated, contact.deleted, payment.completed, payment.failed
签名校验示例
使用端点密钥对原始 HTTP 请求体计算 HMAC-SHA256,并使用恒定时间比较函数进行校验。
import crypto from 'node:crypto';
// Use express.raw({ type: 'application/json' }) so req.body stays unparsed
const expected = crypto
.createHmac('sha256', process.env.MYCALY_WEBHOOK_SECRET)
.update(req.body)
.digest('hex');
const signature = req.get('X-Signature') || '';
const isValid =
expected.length === signature.length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
if (!isValid) return res.status(401).send('Invalid webhook signature');
const payload = JSON.parse(req.body.toString('utf8'));
$rawBody = file_get_contents('php://input');
$headerSignature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
$expected = hash_hmac('sha256', $rawBody, $webhookSecret);
if (! hash_equals($expected, $headerSignature)) {
http_response_code(401);
exit('Invalid webhook signature');
}
$event = json_decode($rawBody, true);
// Process $event['id'], $event['event'], $event['data']
{
"id": "evt_7f8e9d10c2b3a4f5e6d7c8b9",
"event": "booking.created",
"timestamp": "2026-12-03T12:45:00+00:00",
"data": {
"id": 408,
"event_id": 12,
"schedule_date": "2026-12-10",
"slot_time": "09:00 AM - 09:30 AM",
"guest": {
"name": "Alex Rivera",
"email": "alex@example.com"
},
"source": "api"
}
}
API 与 Webhooks 常见解答
在哪里创建并管理 API 令牌和 Webhooks?
登录 MyCaly 控制台后,在左侧栏“集成”下的“API 与 Webhooks”页面即可创建/吊销令牌并配置 Webhook,也可通过 /api/v1 接口进行管理。
哪些接口无需携带 Bearer 令牌?
POST /api/v1/auth/login、GET /api/v1/events/{id}/available-slots 与 POST /api/v1/webinars/{id}/register 为公开接口,方便外部预约组件与报名表单安全调用而无需暴露私密密钥。
API 速率限制与套餐权限有哪些要求?
默认限流为每位用户/IP 每分钟 60 次请求(超出返回 HTTP 429)。受保护的 /api/v1 路由与传出 Webhooks 需要订阅已开启 API / Webhooks 功能的套餐。
服务端应当如何验证 MyCaly Webhooks?
请先读取未经 JSON 重新序列化的原始请求体,使用端点密钥计算 HMAC-SHA256 摘要,再通过 hash_equals(PHP)或 crypto.timingSafeEqual(Node.js)与 X-Signature 请求头比对。