创建 Worker 任务
方法: POST
端点: /api/v2/worker-tasks
认证: 支持 Authorization: Bearer <YOUR_API_KEY>、api-key: <YOUR_API_KEY> 和 ?token=<YOUR_API_KEY>。推荐优先使用 Bearer token。
POST
/api/v2/worker-tasksCreate worker taskAuthenticationRequired
Stored only in this browser tab. Sent only to https://openapi.coreclaw.com.
Request BodyRequiredapplication/json
FieldTypeRequiredDescription
descriptionstringOptionalTask description.inputanyRequiredWorker input payload. Put Worker form fields under `input.parameters.custom`. If left empty in the playground, it will try to load schema defaults before sending.schedule_dayintegerOptionalDay of month for monthly schedule (1-31). Constraints: range 1-31.schedule_enabledenum: 0, 1OptionalSchedule switch. 0=disabled, 1=enabled. Constraints: allowed values: `0`, `1`.schedule_once_datestringOptionalOnce schedule date in YYYY-MM-DD.schedule_timestringOptionalSchedule time in HH:mm.schedule_typeenum: 1, 2, 3, 4OptionalSchedule type. 1=daily, 2=weekly, 3=monthly, 4=once. Constraints: allowed values: `1`, `2`, `3`, `4`.schedule_weekdayenum: 1, 2, 3, 4, 5, 6, 7OptionalWeekday for weekly schedule. 1=Monday ... 7=Sunday. Constraints: range 1-7; allowed values: `1`, `2`, `3`, `4`, `5`, `6`, `7`.titlestringRequiredTask title.versionstringOptionalOptional Worker version. Omit it unless you have confirmed a concrete available version for this Worker; not every Worker accepts `latest`.worker_idstringRequiredWorker slug or path. Use owner~name for path values.Request body (JSON)
什么时候使用这个接口
Section titled “什么时候使用这个接口”用于查询已保存的 Worker 任务模板。
使用 Content-Type: application/json 发送请求体。表格中的必填/选填描述字段本身是否必须提供;整个请求体是否必填以在线试用区的 Request Body 标记为准。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
description | 否 | string | 任务模板描述,可选。 |
input | 是 | any | Worker 输入参数。Worker 表单字段通常放在 input.parameters.custom 下;应先读取该 Worker 的 input schema,再按 schema 构造。 |
schedule_day | 否 | integer | 每月调度时的日期(1-31)。 |
schedule_enabled | 否 | enum: 0, 1 | 调度开关:1 启用,0 关闭。 |
schedule_once_date | 否 | string | 单次调度的日期,格式 YYYY-MM-DD。 |
schedule_time | 否 | string | 调度执行时间,格式 HH:mm。 |
schedule_type | 否 | enum: 1, 2, 3, 4 | 调度类型:1=每天,2=每周,3=每月,4=单次。 |
schedule_weekday | 否 | enum: 1, 2, 3, 4, 5, 6, 7 | 每周调度时的星期几(1=周一 … 7=周日)。 |
title | 是 | string | 任务模板标题,用于展示和搜索。 |
version | 否 | string | 可选 Worker 版本。除非已经确认该 Worker 存在某个具体可用版本,否则建议省略;并非所有 Worker 都接受 latest 作为显式版本值。 |
worker_id | 是 | string | Worker 标识。接受 Worker slug,也支持把 owner/name 写成 owner~name。 |
JSON 示例
Section titled “JSON 示例”{ "description": "Scrape Google Maps business records on a schedule.", "input": { "parameters": { "custom": { "keywords": [ "coffee" ], "base_location": "New York,USA", "max_results": 1 } } }, "schedule_day": 1, "schedule_enabled": 0, "schedule_once_date": "2026-08-01", "schedule_time": "09:00", "schedule_type": 1, "schedule_weekday": 1, "title": "Google Maps Scraper (Task)", "worker_id": "coreclaw~google-maps-scraper"}curl -X POST "https://openapi.coreclaw.com/api/v2/worker-tasks" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ --data '{"description":"Scrape Google Maps business records on a schedule.","input":{"parameters":{"custom":{"keywords":["coffee"],"base_location":"New York,USA","max_results":1}}},"schedule_day":1,"schedule_enabled":0,"schedule_once_date":"2026-08-01","schedule_time":"09:00","schedule_type":1,"schedule_weekday":1,"title":"Google Maps Scraper (Task)","worker_id":"coreclaw~google-maps-scraper"}'{ "code": 0, "data": { "slug": "demo-task" }, "message": "success", "request_id": "req-123"}- API v2 同时支持 Bearer token、旧版
api-key请求头和 query token;新集成建议优先使用 Bearer token。 worker_id接受 Worker slug,也支持把owner/name写成owner~name。- 应先读取 Worker 输入 schema 再构造
input,表单字段放在input.parameters.custom下;可用GET /api/v2/workers/{workerId}/input-schema读取 schema。 - 调度字段:
schedule_enabled1 启用 0 关闭;schedule_type1=每天、2=每周、3=每月、4=单次;schedule_time为HH:mm;schedule_once_date为YYYY-MM-DD。不启用调度时可省略全部 schedule 字段。
HTTP 响应
Section titled “HTTP 响应”| HTTP 状态 | 应用代码 | 含义 |
|---|---|---|
200 | 0 | 请求成功。 |
400 | 11000 | 请求参数不合法。 |
401 | 12001 | 认证缺失或无效。 |
404 | 11004 | 目标资源不存在。 |
422 | 11000 | 请求语义或字段校验未通过。 |
429 | 13000 | 请求过于频繁。 |
500 | 10000 | 服务端内部错误。 |