Chronosfy API — Python 快速入门
安装请求。 Set CHRONOSFY_AUTH 到一个作用域键或 JWT 从 POST /auth/login.
import os, json, requests
BASE = "https://chronosfy.com/api"
def create(path, body, key):
response = requests.post(BASE + path, json=body, timeout=30, headers={
"Authorization": os.environ["CHRONOSFY_AUTH"], "Idempotency-Key": key})
response.raise_for_status()
return response.json()
person = create('/crm/persons', json.loads('{"name":"Alice","email":"[email protected]","external_id":"customer-42","metadata":{"source":"integration"}}'), 'person:customer-42:v1')
action = create('/actions', json.loads('{"name":"Monthly reminder","type":"email","template":{"subject":"Reminder","body_html":"<p>Hello</p>"}}'), 'action:reminder:v1')
schedule = json.loads('{"name":"Monthly reminder","subject_type":"person","frequency_config":{"type":"monthly","day":31,"time":"09:00","timezone":"Europe/London"},"client_reference":"subscription-42"}')
schedule.update(action_id=action['id'], subject_id=person['id'])
recurrence = create('/recurrences', schedule, '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 响应或结果未知,请重用原来的密钥。不要为同一笔付款创建新的支付标识。