跳到正文

定时任务 Cron

按 cron 表达式调度周期性 HTTP 任务——创建、暂停、手动触发并查看运行记录,支持重试与保留期。

1. 概览

基础路径: https://api.infrai.cc/v1/cron
鉴权头: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/cron capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/cron/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

2. 方法 (10)

2.1cron.create

POST /v1/cron/create

创建按计划向 URL 发起 POST 的定时任务。

参数

名称类型必填说明
namestring
必填
可读的任务名称。
schedulestring
必填
Cron 表达式,例如 0 9 * * *。
run_atstring可选一次性任务的绝对 ISO-8601 UTC 触发时间,仅触发一次(与周期 schedule 二选一)。
format: date-time
urlstring
必填
接收定时 POST 的 URL。
payloadunknown可选每次运行附带的可选 JSON 负载。
timezonestring可选调度使用的 IANA 时区。
default: "UTC"
retriesnumber可选失败时的重试次数。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

CronRecord { cron_id, name, schedule, url, enabled, next_run_at? }
名称类型说明
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
namestring | null资源的可读名称
account_idstring拥有此资源的账户标识
cron_exprstring标准 5/6 段 cron 表达式。
task_type"http_url" | "function_ref"任务类型(http、serverless)
task_urlstring | null定时任务触发时要调用的 URL
format: uri
task_function_namestring | null要调用的 Serverless 函数名
timezonestring定时任务的 IANA 时区
default: "UTC"
retryinteger失败执行的重试配置
0–10default: 3
timeout_secondsintegerStandard/Pro 硬上限 900 秒(15 分钟)。企业合同可按档位覆盖。
1–900default: 300
overlap_policy"allow" | "skip" | "queue"处理重叠运行的策略(skip、queue、cancel)
default: "skip"
max_runsinteger | null保留的最大运行次数
≥ 1
payloadobject | null消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
on_failure_webhookstring | null执行失败时回调的 Webhook URL
format: uri
enabledboolean该功能或配置是否启用
default: true
status"active" | "disabled" | "exhausted" | "deleted"当前资源状态
next_run_atstring | nullISO 8601 时间戳:the next scheduled run(ISO 8601)
format: date-time
last_run_atstring | nullISO 8601 时间戳:the last cron run(ISO 8601)
format: date-time
last_run_status"succeeded" | "failed" | "skipped" | null上次定时任务运行状态

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/cron/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"task": "https://example.com/callback"}'

2.2cron.list

GET /v1/cron/list

列出定时任务。

返回

{ items: CronRecord[] }
名称类型说明
itemsobject[]cron job records列表
next_cursorstring | null下一页游标;null 表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/cron/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.3cron.get

GET /v1/cron/get/{id}

获取单个定时任务的配置与下次运行时间

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID

返回

CronRecord { cron_id, name, cron_expr, task, timezone, enabled, next_run_at? }
名称类型说明
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
namestring | null资源的可读名称
account_idstring拥有此资源的账户标识
cron_exprstring标准 5/6 段 cron 表达式。
task_type"http_url" | "function_ref"任务类型(http、serverless)
task_urlstring | null定时任务触发时要调用的 URL
format: uri
task_function_namestring | null要调用的 Serverless 函数名
timezonestring定时任务的 IANA 时区
default: "UTC"
retryinteger失败执行的重试配置
0–10default: 3
timeout_secondsintegerStandard/Pro 硬上限 900 秒(15 分钟)。企业合同可按档位覆盖。
1–900default: 300
overlap_policy"allow" | "skip" | "queue"处理重叠运行的策略(skip、queue、cancel)
default: "skip"
max_runsinteger | null保留的最大运行次数
≥ 1
payloadobject | null消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
on_failure_webhookstring | null执行失败时回调的 Webhook URL
format: uri
enabledboolean该功能或配置是否启用
default: true
status"active" | "disabled" | "exhausted" | "deleted"当前资源状态
next_run_atstring | nullISO 8601 时间戳:the next scheduled run(ISO 8601)
format: date-time
last_run_atstring | nullISO 8601 时间戳:the last cron run(ISO 8601)
format: date-time
last_run_status"succeeded" | "failed" | "skipped" | null上次定时任务运行状态

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/cron/get/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.4cron.update

PATCH /v1/cron/update/{id}

更新定时任务的表达式、目标与策略

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
cron_exprstring可选标准 5/6 段 cron 表达式
taskstring可选触发时投递的目标 URL
format: uri
namestring可选任务名称
timezonestring可选IANA 时区名(如 Asia/Shanghai)
retrynumber可选失败重试次数(0-10)
0–10
timeout_secondsnumber可选单次触发超时秒数(1-900)
1–900
overlap_policy"allow" | "skip" | "queue" | null可选重叠策略:allow 允许 / skip 跳过 / queue 排队
max_runsnumber可选最大运行次数,达到后自动停止
≥ 1
payloadobject可选随触发发送的 JSON 负载
headersobject可选随触发发送的自定义请求头
on_failure_webhookstring可选失败时回调的 Webhook 地址
format: uri
idempotency_keystring可选幂等键,避免重复执行

返回

CronRecord { cron_id, name, cron_expr, task, timezone, enabled, next_run_at? }
名称类型说明
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
namestring | null资源的可读名称
account_idstring拥有此资源的账户标识
cron_exprstring标准 5/6 段 cron 表达式。
task_type"http_url" | "function_ref"任务类型(http、serverless)
task_urlstring | null定时任务触发时要调用的 URL
format: uri
task_function_namestring | null要调用的 Serverless 函数名
timezonestring定时任务的 IANA 时区
default: "UTC"
retryinteger失败执行的重试配置
0–10default: 3
timeout_secondsintegerStandard/Pro 硬上限 900 秒(15 分钟)。企业合同可按档位覆盖。
1–900default: 300
overlap_policy"allow" | "skip" | "queue"处理重叠运行的策略(skip、queue、cancel)
default: "skip"
max_runsinteger | null保留的最大运行次数
≥ 1
payloadobject | null消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
on_failure_webhookstring | null执行失败时回调的 Webhook URL
format: uri
enabledboolean该功能或配置是否启用
default: true
status"active" | "disabled" | "exhausted" | "deleted"当前资源状态
next_run_atstring | nullISO 8601 时间戳:the next scheduled run(ISO 8601)
format: date-time
last_run_atstring | nullISO 8601 时间戳:the last cron run(ISO 8601)
format: date-time
last_run_status"succeeded" | "failed" | "skipped" | null上次定时任务运行状态

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X PATCH https://api.infrai.cc/v1/cron/update/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

2.5cron.delete

DELETE /v1/cron/delete/{id}

删除一个定时任务

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
idempotency_keystring可选幂等键,避免重复执行

返回

{ cron_id, deleted }
名称类型说明
cron_idstring(尝试)删除的定时任务标识符
deletedboolean定时任务是否已删除
status"not_found" | null任务不存在时为 "not_found"(deleted=false)

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X DELETE https://api.infrai.cc/v1/cron/delete/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.6cron.pause

POST /v1/cron/pause/{id}

暂停定时任务

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
idempotency_keystring可选幂等键,避免重复执行

返回

CronRecord { cron_id, enabled }
名称类型说明
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
namestring | null资源的可读名称
account_idstring拥有此资源的账户标识
cron_exprstring标准 5/6 段 cron 表达式。
task_type"http_url" | "function_ref"任务类型(http、serverless)
task_urlstring | null定时任务触发时要调用的 URL
format: uri
task_function_namestring | null要调用的 Serverless 函数名
timezonestring定时任务的 IANA 时区
default: "UTC"
retryinteger失败执行的重试配置
0–10default: 3
timeout_secondsintegerStandard/Pro 硬上限 900 秒(15 分钟)。企业合同可按档位覆盖。
1–900default: 300
overlap_policy"allow" | "skip" | "queue"处理重叠运行的策略(skip、queue、cancel)
default: "skip"
max_runsinteger | null保留的最大运行次数
≥ 1
payloadobject | null消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
on_failure_webhookstring | null执行失败时回调的 Webhook URL
format: uri
enabledboolean该功能或配置是否启用
default: true
status"active" | "disabled" | "exhausted" | "deleted"当前资源状态
next_run_atstring | nullISO 8601 时间戳:the next scheduled run(ISO 8601)
format: date-time
last_run_atstring | nullISO 8601 时间戳:the last cron run(ISO 8601)
format: date-time
last_run_status"succeeded" | "failed" | "skipped" | null上次定时任务运行状态

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/cron/pause/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cron_id": "sample"}'

2.7cron.resume

POST /v1/cron/resume/{id}

恢复已暂停的定时任务

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
idempotency_keystring可选幂等键,避免重复执行

返回

CronRecord { cron_id, enabled, next_run_at? }
名称类型说明
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
namestring | null资源的可读名称
account_idstring拥有此资源的账户标识
cron_exprstring标准 5/6 段 cron 表达式。
task_type"http_url" | "function_ref"任务类型(http、serverless)
task_urlstring | null定时任务触发时要调用的 URL
format: uri
task_function_namestring | null要调用的 Serverless 函数名
timezonestring定时任务的 IANA 时区
default: "UTC"
retryinteger失败执行的重试配置
0–10default: 3
timeout_secondsintegerStandard/Pro 硬上限 900 秒(15 分钟)。企业合同可按档位覆盖。
1–900default: 300
overlap_policy"allow" | "skip" | "queue"处理重叠运行的策略(skip、queue、cancel)
default: "skip"
max_runsinteger | null保留的最大运行次数
≥ 1
payloadobject | null消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
on_failure_webhookstring | null执行失败时回调的 Webhook URL
format: uri
enabledboolean该功能或配置是否启用
default: true
status"active" | "disabled" | "exhausted" | "deleted"当前资源状态
next_run_atstring | nullISO 8601 时间戳:the next scheduled run(ISO 8601)
format: date-time
last_run_atstring | nullISO 8601 时间戳:the last cron run(ISO 8601)
format: date-time
last_run_status"succeeded" | "failed" | "skipped" | null上次定时任务运行状态

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/cron/resume/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cron_id": "sample"}'

2.8cron.trigger

POST /v1/cron/trigger/{id}

立即手动触发一次定时任务运行

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
idempotency_keystring可选幂等键,避免重复执行

返回

CronRun { run_id, cron_id, state, started_at }
名称类型说明
run_idstringcron run的唯一标识符
pattern: ^cronrun_[A-Za-z0-9]{20,}$
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
scheduled_atstring根据 cron 表达式计算的时间。
format: date-time
fired_atstring实际触发时间(可能有数毫秒偏差)。
format: date-time
started_atstring | null执行开始时间(ISO 8601)
format: date-time
completed_atstring | null执行完成时间(ISO 8601)
format: date-time
duration_msinteger | null操作耗时(毫秒)
≥ 0
status"queued" | "running" | "succeeded" | "failed" | "timeout" | "skipped"当前资源状态
skipped_reason"overlap_skip" | "max_runs_reached" | "disabled" | null运行被跳过的原因
retry_countintegerretries for this run数量
≥ 0
is_manual_triggerboolean本次运行是否为手动触发
http_statusinteger | nullWebhook 投递尝试的 HTTP 状态码
100–599
outputstring | null响应正文的前 4 KB。
errorstring | null操作失败时的错误消息
error_codestring | null失败执行的错误码
on_failure_webhook_delivery_idstring | null失败通知的 Webhook 投递 ID
pattern: ^dlv_[A-Za-z0-9]{20,}$

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/cron/trigger/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cron_id": "sample"}'

2.9cron.runs.get

GET /v1/cron/runs/get/{id}/{run_id}

获取定时任务某次运行的详情

参数

名称类型必填说明
cron_idstring
必填
定时任务 ID
run_idstring
必填
运行(CronRun)ID

返回

CronRun { run_id, cron_id, state, started_at, finished_at?, response_status?, error? }
名称类型说明
run_idstringcron run的唯一标识符
pattern: ^cronrun_[A-Za-z0-9]{20,}$
job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
scheduled_atstring根据 cron 表达式计算的时间。
format: date-time
fired_atstring实际触发时间(可能有数毫秒偏差)。
format: date-time
started_atstring | null执行开始时间(ISO 8601)
format: date-time
completed_atstring | null执行完成时间(ISO 8601)
format: date-time
duration_msinteger | null操作耗时(毫秒)
≥ 0
status"queued" | "running" | "succeeded" | "failed" | "timeout" | "skipped"当前资源状态
skipped_reason"overlap_skip" | "max_runs_reached" | "disabled" | null运行被跳过的原因
retry_countintegerretries for this run数量
≥ 0
is_manual_triggerboolean本次运行是否为手动触发
http_statusinteger | nullWebhook 投递尝试的 HTTP 状态码
100–599
outputstring | null响应正文的前 4 KB。
errorstring | null操作失败时的错误消息
error_codestring | null失败执行的错误码
on_failure_webhook_delivery_idstring | null失败通知的 Webhook 投递 ID
pattern: ^dlv_[A-Za-z0-9]{20,}$

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/cron/runs/get/ID/RUN_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.10cron.runs.list

GET /v1/cron/runs/list/{id}

列出某定时任务的运行历史(执行记录),支持分页。

参数

名称类型必填说明
cron_idstring
必填
要列出运行记录的定时任务 ID。
cursorstring可选分页游标。
limitnumber可选返回运行记录的最大条数。

返回

{ items: CronRun[], next_cursor? }
名称类型说明
itemsobject[]本页结果条目数组
items[].run_idstringcron run的唯一标识符
pattern: ^cronrun_[A-Za-z0-9]{20,}$
items[].job_idstringasync job的唯一标识符
pattern: ^cron_[A-Za-z0-9]{20,}$
items[].account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
items[].scheduled_atstring根据 cron 表达式计算的时间。
format: date-time
items[].fired_atstring实际触发时间(可能有数毫秒偏差)。
format: date-time
items[].started_atstring | null执行开始的 ISO 8601 时间戳
format: date-time
items[].completed_atstring | null执行完成的 ISO 8601 时间戳
format: date-time
items[].duration_msinteger | null操作耗时(毫秒)
≥ 0
items[].status"queued" | "running" | "succeeded" | "failed" | "timeout" | "skipped"此资源当前状态
items[].skipped_reason"overlap_skip" | "max_runs_reached" | "disabled" | null运行被跳过的原因
items[].retry_countintegerretries for this run数量
≥ 0
items[].is_manual_triggerboolean本次运行是否为手动触发
items[].http_statusinteger | nullWebhook 投递尝试的 HTTP 状态码
100–599
items[].outputstring | null响应正文的前 4 KB。
items[].errorstring | null操作失败时的错误消息
items[].error_codestring | null失败执行的错误码
items[].on_failure_webhook_delivery_idstring | null失败通知的 Webhook 投递 ID
pattern: ^dlv_[A-Za-z0-9]{20,}$
next_cursorstring | null获取下一页的不透明游标;null 或不存在表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/cron/runs/list/ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

3. 全部能力

本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。

cron.createPOST /v1/cron/create

Create a scheduled job: recurring via cron_expr, or a one-shot via run_at (fires once); idempotent write.

参数 (14)
名称类型必填说明
cron_exprstring可选Standard 5/6-field cron expression (recurring schedule). Mutually exclusive with run_at.
run_atstring可选Absolute UTC time for a ONE-SHOT job that fires exactly once (max_runs=1). Mutually exclusive with cron_expr.
format: date-time
taskstring必填Delivery target URL the cron fires against (http_url task type).
format: uri
namestring | null可选Human-readable name for this resource
timezonestring可选IANA tz name.
default: "UTC"
retryinteger可选Retry configuration for failed executions
0–10default: 3
timeout_secondsinteger可选Maximum execution time in seconds
1–900default: 300
overlap_policy"allow" | "skip" | "queue"可选Policy for handling overlapping runs (skip, queue, cancel)
default: "skip"
max_runsinteger | null可选Maximum number of runs to retain
≥ 1
payloadobject | null可选Payload data for the message or request body
headersobject | null可选Custom HTTP headers to include in requests or responses
on_failure_webhookstring | null可选Webhook URL to call on execution failure
format: uri
secretstring | null可选HMAC signing secret for the fired request; never returned (only secret_fingerprint).
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
cron.deleteDELETE /v1/cron/delete/{id}

Delete a cron job and stop all of its future scheduled runs; idempotent.

参数 (1)
名称类型必填说明
idstring必填Path parameter.
cron.getGET /v1/cron/get/{id}

Get a single cron job's configuration and next run time.

参数 (1)
名称类型必填说明
idstring必填Path parameter.
cron.listGET /v1/cron/list

List the account's cron jobs with pagination.

无请求参数。

cron.pausePOST /v1/cron/pause/{id}

Pause a cron job, halting subsequent triggers.

参数 (3)
名称类型必填说明
idstring必填Path parameter.
cron_idstring必填Id of the cron job to act on.
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
cron.resumePOST /v1/cron/resume/{id}

Resume a paused cron job.

参数 (3)
名称类型必填说明
idstring必填Path parameter.
cron_idstring必填Id of the cron job to act on.
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
cron.runs.getGET /v1/cron/runs/get/{id}/{run_id}

Retrieve details of a single cron job execution (CronRun).

参数 (2)
名称类型必填说明
run_idstring必填Path parameter.
idstring必填Path parameter.
cron.runs.listGET /v1/cron/runs/list/{id}

List a cron job's run history (executions) with pagination.

参数 (1)
名称类型必填说明
idstring必填Path parameter.
cron.triggerPOST /v1/cron/trigger/{id}

Manually trigger an immediate run of a scheduled cron job.

参数 (3)
名称类型必填说明
idstring必填Path parameter.
cron_idstring必填Id of the cron job to act on.
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
cron.updatePATCH /v1/cron/update/{id}

Update a cron job's schedule expression, target, overlap policy, and other fields.

参数 (13)
名称类型必填说明
idstring必填Path parameter.
cron_exprstring | null可选Cron expression for the schedule
taskstring | null可选Task URL or function to invoke on trigger
format: uri
namestring | null可选Human-readable name for this resource
timezonestring | null可选IANA tz name.
retryinteger | null可选Retry configuration for failed executions
0–10
timeout_secondsinteger | null可选Maximum execution time in seconds
1–900
overlap_policy"allow" | "skip" | "queue" | null可选Policy for handling overlapping runs (skip, queue, cancel)
max_runsinteger | null可选Maximum number of runs to retain
≥ 1
payloadobject | null可选Payload data for the message or request body
headersobject | null可选Custom HTTP headers to include in requests or responses
on_failure_webhookstring | null可选Webhook URL to call on execution failure
format: uri
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry

4. 完整示例

本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。

单文件可运行 Python 程序(仅标准库、无 SDK):拷贝后填入 INFRAI_API_KEY 运行,即可按真实业务流逐步体验本模块核心 API——每一步都真实调用并计费,后续步骤复用前一步返回的真实字段。12 行 helper 就是全部集成代码。

python
#!/usr/bin/env python3
"""Infrai · cron — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) cron.create — POST /v1/cron/create · Create a scheduled job: recurring via cron_expr, or a one-shot via run_at (fires once); idempotent write.
r1 = show("cron.create", infrai("POST", "/v1/cron/create", {"cron_expr":"0 9 * * 1","task":"https://api.acme.com/weekly"}))

# 2) cron.runs.list — GET /v1/cron/runs/list/{id} · List a cron job's run history (executions) with pagination.
id_2 = (r1.get("data") or {}).get("cron_id") or ""
r2 = show("cron.runs.list", infrai("GET", f"/v1/cron/runs/list/{id_2}"))

# 3) cron.list — GET /v1/cron/list · List the account's cron jobs with pagination.
r3 = show("cron.list", infrai("GET", "/v1/cron/list"))