crontap-ai-built-apps
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRecurring work for AI-built apps
AI 构建应用的周期性任务
The deployed app must expose an HTTP endpoint. Crontap owns the clock and calls
that endpoint. The builder chat is used to create code, not as the production
runtime for recurring prompts.
部署后的应用必须暴露一个 HTTP 端点。Crontap 负责计时并调用该端点。构建器聊天用于创建代码,而不是作为执行周期性提示词的生产运行时。
Prerequisites
前置条件
Before using the required tools, check whether they are available. If any are
missing, stop and offer the user exactly two choices:
- Connect Crontap MCP at . MCP access works on every Crontap tier.
https://mcp.crontap.com/mcp - Configure and
$CRONTAP_CLIENT_IDfor the raw API. Raw API access requires Ultra.$CRONTAP_API_KEY
Do not silently choose a path or continue until the user selects one.
- Identify the builder's deployed server or function runtime.
- Define one narrow recurring operation and its durable side effect.
- Add a server-only cron secret and idempotency storage.
- Confirm the production URL and IANA timezone.
在使用所需工具之前,检查它们是否可用。如果缺少任何工具,请停止操作,并准确向用户提供以下两个选项:
- 在 连接 Crontap MCP。所有 Crontap 套餐层级均支持 MCP 访问。
https://mcp.crontap.com/mcp - 配置 和
$CRONTAP_CLIENT_ID以使用原始 API。原始 API 访问需要 Ultra 套餐。$CRONTAP_API_KEY
不要擅自选择其中一种方式,也不要在用户选择之前继续操作。
- 确定构建器所用的已部署服务器或函数运行时。
- 定义一项范围明确的周期性操作及其持久化副作用。
- 添加仅限服务器端使用的 cron secret 和幂等性存储。
- 确认生产 URL 和 IANA 时区。
Builder prompt
构建器提示词
Adapt this prompt to the app's framework:
text
Create a POST /api/jobs/daily-report endpoint. Before any work, compare the
Authorization bearer value with the server-only CRON_SECRET environment
variable and return 401 on mismatch. Persist an idempotency key for the current
logical reporting day before creating side effects. Queue long work durably.
Return JSON with a bounded status and no secrets. Add tests for unauthorized,
first-run, and duplicate-run behavior.Review the generated code. Verify that secret comparison and idempotency happen
server-side, not in browser code.
根据应用的框架调整此提示词:
text
Create a POST /api/jobs/daily-report endpoint. Before any work, compare the
Authorization bearer value with the server-only CRON_SECRET environment
variable and return 401 on mismatch. Persist an idempotency key for the current
logical reporting day before creating side effects. Queue long work durably.
Return JSON with a bounded status and no secrets. Add tests for unauthorized,
first-run, and duplicate-run behavior.审查生成的代码。验证 secret 比较和幂等性处理均发生在服务器端,而不是浏览器代码中。
Workflow
工作流
- Generate and review the protected endpoint in the builder.
- Deploy it and run authorized and unauthorized tests.
- Optionally create a heartbeat for independent run evidence.
- Create the schedule with the protected endpoint.
- Inspect the first run in both Crontap and application logs.
- 在构建器中生成并审查受保护的端点。
- 部署该端点,并运行授权和未授权测试。
- 可选创建一个 heartbeat,以获取独立的运行证据。
- 使用受保护的端点创建定时任务。
- 在 Crontap 和应用日志中检查首次运行情况。
MCP examples
MCP 示例
Create a heartbeat first when missed-run monitoring is useful:
json
{
"tool": "create_heartbeat",
"arguments": {
"name": "Daily report delivery",
"periodMinutes": 1440,
"graceMinutes": 30
}
}Store the returned ping URL securely. It can be connected to schedule outcome
webhooks or called by the deployed endpoint after durable completion.
Create the HTTP schedule:
json
{
"tool": "create_schedule",
"arguments": {
"url": "https://app.example.com/api/jobs/daily-report",
"text": "every day at 08:00",
"timezone": "America/New_York",
"method": "POST",
"headers": {
"Authorization": "Bearer <cron-secret-from-secure-store>",
"Content-Type": "application/json"
},
"body": {
"source": "crontap"
},
"label": "AI-built app daily report"
}
}当监控漏跑任务很有用时,请先创建 heartbeat:
json
{
"tool": "create_heartbeat",
"arguments": {
"name": "Daily report delivery",
"periodMinutes": 1440,
"graceMinutes": 30
}
}安全存储返回的 ping URL。它可以连接到任务结果 webhook,也可以在持久化任务完成后由已部署的端点调用。
创建 HTTP 定时任务:
json
{
"tool": "create_schedule",
"arguments": {
"url": "https://app.example.com/api/jobs/daily-report",
"text": "every day at 08:00",
"timezone": "America/New_York",
"method": "POST",
"headers": {
"Authorization": "Bearer <cron-secret-from-secure-store>",
"Content-Type": "application/json"
},
"body": {
"source": "crontap"
},
"label": "AI-built app daily report"
}
}REST fallback
REST 回退方案
REST requires Ultra API access:
bash
curl --fail-with-body https://api.crontap.com/v1/schedule \
-X POST \
-H "ClientId: $CRONTAP_CLIENT_ID" \
-H "ApiKey: $CRONTAP_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"url": "https://app.example.com/api/jobs/daily-report",
"interval": "0 8 * * *",
"timezone": "America/New_York",
"verb": "POST",
"headers": {
"Authorization": "Bearer <cron-secret-from-secure-store>",
"Content-Type": "application/json"
},
"data": {"source": "crontap"},
"label": "AI-built app daily report"
}'Use MCP for connected non-Ultra accounts.
REST 需要 Ultra API 访问权限:
bash
curl --fail-with-body https://api.crontap.com/v1/schedule \
-X POST \
-H "ClientId: $CRONTAP_CLIENT_ID" \
-H "ApiKey: $CRONTAP_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"url": "https://app.example.com/api/jobs/daily-report",
"interval": "0 8 * * *",
"timezone": "America/New_York",
"verb": "POST",
"headers": {
"Authorization": "Bearer <cron-secret-from-secure-store>",
"Content-Type": "application/json"
},
"data": {"source": "crontap"},
"label": "AI-built app daily report"
}'对于已连接的非 Ultra 账户,请使用 MCP。
Verification
验证
- Confirm the endpoint is server-side and unavailable before authentication.
- Confirm duplicate requests for one logical period create one side effect.
- Verify the first Crontap run and the corresponding application record.
- If using a heartbeat, verify success and explicit failure paths separately.
- 确认端点仅在服务器端运行,并且在通过认证前不可访问。
- 确认同一逻辑周期内的重复请求只产生一次副作用。
- 验证 Crontap 的首次运行及对应的应用记录。
- 如果使用 heartbeat,请分别验证成功和明确失败的路径。
Safety and plan limits
安全与套餐限制
- Never put a cron secret or heartbeat URL in client-side environment values.
- Avoid scheduling preview or development deployment URLs.
- Crontap does not keep the builder session open and does not initiate prompts.
- If creation hits a cap or cadence floor, present the returned four-option ladder and smallest viable option.
- 切勿将 cron secret 或 heartbeat URL 放入客户端环境变量。
- 避免为预览或开发部署 URL 安排任务。
- Crontap 不会保持构建器会话处于打开状态,也不会发起提示词。
- 如果创建任务时达到数量上限或触发执行频率下限,请呈现返回的四选项阶梯及最小可行选项。
Troubleshooting
故障排查
- A 404 often means the builder did not deploy the server route.
- A 401 means the deployed environment and Crontap use different secrets.
- Platform sleep or cold starts can cause timeouts. Queue long work durably.
- Duplicate effects mean the endpoint's idempotency boundary is incomplete.
- 404 通常意味着构建器未部署服务器路由。
- 401 意味着已部署环境与 Crontap 使用了不同的 secret。
- 平台休眠或冷启动可能导致超时。应将长时间任务持久化入队。
- 出现重复副作用意味着端点的幂等性边界不完整。