开发者文档

Chronosfy API — Node.js 快速启动

节点 22 已 built-in 设置 CHRONOSFY_AUTH 到一个作用域键或 JWT 从 POST /auth/login.
const BASE = 'https://chronosfy.com/api';
const authorization = process.env.CHRONOSFY_AUTH;
async function create(path, body, key) {
  const response = await fetch(BASE + path, { method: 'POST',
    headers: { Authorization: authorization, 'Content-Type': 'application/json', 'Idempotency-Key': key },
    body: JSON.stringify(body) });
  const result = await response.json();
  if (!response.ok) throw new Error(JSON.stringify(result));
  return result;
}
const person = await create('/crm/persons', {"name":"Alice","email":"[email protected]","external_id":"customer-42","metadata":{"source":"integration"}}, 'person:customer-42:v1');
const action = await create('/actions', {"name":"Monthly reminder","type":"email","template":{"subject":"Reminder","body_html":"<p>Hello</p>"}}, 'action:reminder:v1');
const recurrence = await create('/recurrences', { ...{"name":"Monthly reminder","subject_type":"person","frequency_config":{"type":"monthly","day":31,"time":"09:00","timezone":"Europe/London"},"client_reference":"subscription-42"},
  action_id: action.id, subject_id: person.id }, 'recurrence:subscription-42:v1');
使用一个范围 API 键或一个 JWT 从 POST /auth/login. 每个逻辑请求保留一个稳定密钥,包括在超时或进程重新启动后。使用相同的密钥更改有效载荷返回 409. 创建密钥对于人员/操作/重复是可选的,对于付款链接是必需的。 MCP 使用 request_key。 external_id 在租户的活动人员中是独一无二的; client_reference 是 non-unique 业务参考。 为 one-off 购买、循环注册或独立卡片存储,请参阅 /docs/quickstart/checkout 对于托管 URL 和嵌入式 SDK. 对于 Stripe Elements 的直接设置,请配置经过验证的 PSP,并使用 Stripe.js 中的 /payment/setup-intent 。 Checkout 可以使用 save_payment_method 保存卡片;first_run_at 设置最早的自动重复。 有关完整的 HTTP/MCP 流程、权限和恢复,请参阅 /docs/quickstart/renewals 。 如果收到 502 响应或结果未知,请重用原来的密钥。不要为同一笔付款创建新的支付标识。