跳到正文
Won.dev

任务

在后台批量执行最多 100 次查找或获取 500 条线索,按子调用计费,完成后读取结果。

任务会在后台替你批量调用同一个接口,agent 无需逐个发请求,也不用在运行期间一直保持连接。

  • enrich.people.email.find、enrich.email.verify 和 signals.find 使用 inputs:最多 100 个子调用,每项是一次调用的请求体。trade.leads.find 使用单个 input,其 limit 最大为 500,任务会自动替你逐页获取。
  • 每个子调用的执行和计费都与单独调用完全相同,所以任务的花费就是这些调用花费之和。创建、查看、列出和取消任务都免费。max_cost 会拒绝可能超出该金额的任务,dry_run: true 只返回最高花费。
  • 余额或 key 的预算用完时,任务以 failed 结束,已完成的部分全部保留。
  • 任务结束时,task.completed 事件会推送到你的 webhook,也会出现在 GET /events 中。你自定义的 metadata(比如客户 ID)会随任务和该事件一并返回。
  • 结果在任务结束后保留 7 天;如果数据来源不允许长期保存,则只保留 1 天。任务本身在列表中保留 30 天。
  • 使用测试 key 时,每个子调用都在沙箱中运行,不扣费,并且只能看到测试 key 创建的任务。
  • MCP 服务 通过 task_create 和 task_get 工具提供相同的功能。

创建任务

POST https://api.won.dev/v1/tasks

在后台对同一个接口批量发起调用:最多 100 次工作邮箱查找(enrich.people.email.find)、邮箱验证(enrich.email.verify)或公司信号检查(signals.find),inputs 中每一项对应一次调用;或者用一个 input 获取最多 500 条线索(trade.leads.find),其 limit 最大为 500。每个子调用都与单独调用完全一致:按接口价格对返回的结果计费,重复调用和 30 天内已付费的结果免费。创建任务本身免费。max_cost 会拒绝可能超出该金额的任务,dry_run: true 只返回最高花费。余额或 key 的预算用完时,任务以 failed 结束,已完成的部分全部保留。可以用 GET /tasks/{id} 查看进度,或者等待 task.completed 事件。结果在任务结束后保留 7 天。带上 Idempotency-Key 请求头,重试时不会重复创建任务。支持的接口:trade.leads.find、enrich.people.email.find、enrich.email.verify、signals.find。

参数

参数放在JSON 请求体里。

参数类型必填说明(API 原文)
operationtrade.leads.find | enrich.people.email.find | enrich.email.verify | signals.find是What to run: trade.leads.find, enrich.people.email.find, enrich.email.verify, signals.find.
inputsobject[]否For a batch: up to 100 parts, each the body of one call of the endpoint, such as {"email": "jane@example.com"}.
inputobject否For trade.leads.find: the body of one call, with limit up to 500 (default 100). The task goes down the ranked list until it has limit leads or the list ends.
max_costnumber否The most the whole task may cost, in US dollars. A task that could cost more is refused before anything runs.
dry_runboolean否Only say the most the task can cost. Nothing is created or charged. Default: false.
metadataobject否Your own keys and values, such as {"customer_id": "c_812"}: up to 20 keys of at most 40 characters, each value a string of at most 500. Returned as given, and in the events about it.

响应

字段类型说明(API 原文)
dataobjectThe task, and the most it can cost.
data.dry_runbooleanTrue when nothing was created: the answer to dry_run: true.
data.max_costnumberThe most the task can cost, in US dollars.
data.taskobject | nullThe task. Null on a dry run.
data.task.idstringTask ID, such as task_7p1q8w3e5r4k2m9x.
data.task.operationstringThe endpoint it runs, such as enrich.email.verify.
data.task.statusrunning | completed | failed | canceledrunning, then completed, failed (it stopped early, and error says why) or canceled.
data.task.progressobjectHow far it got.
data.task.progress.doneintegerParts answered, or for leads the leads found.
data.task.progress.totalintegerParts of the batch, or the leads asked for.
data.task.progress.failedintegerParts answered with an error. They cost nothing.
data.task.costnumberWhat it cost so far, in US dollars.
data.task.max_costnumberThe most it can cost, in US dollars.
data.task.errorobject | nullWhy it stopped early: the error of the call that stopped it, such as insufficient_balance. Null otherwise.
data.task.error.codestring
data.task.error.messagestring
data.task.metadataobjectYour own keys and values, as you gave them. Empty when none were.
data.task.created_atstringWhen it was created, ISO 8601.
data.task.completed_atstring | nullWhen it ended. Null while it runs.
data.task.results_expire_atstring | nullWhen the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs.
noticestring | nullA plain sentence when there is something to know about this answer. Null otherwise.
usageobjectNothing is charged here. The balance, for reference.
usage.costnumberWhat this call cost, in US dollars.
usage.balancenumberThe balance left after this call, in US dollars.
usage.replayedbooleanTrue when this is a repeat of a request from the last 24 hours. Repeats are free.

示例

curl https://api.won.dev/v1/tasks \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "operation": "enrich.people.email.find",
  "inputs": [
    {
      "first_name": "Dana",
      "last_name": "Reyes",
      "domain": "harbor-chairs.com"
    },
    {
      "linkedin_url": "https://www.linkedin.com/in/lee-okafor"
    }
  ],
  "max_cost": 3,
  "metadata": {
    "customer_id": "c_812"
  }
}'
{
  "data": {
    "dry_run": false,
    "max_cost": 0.06,
    "task": {
      "id": "task_7p1q8w3e5r4k2m9x",
      "operation": "enrich.people.email.find",
      "status": "running",
      "progress": {
        "done": 0,
        "total": 2,
        "failed": 0
      },
      "cost": 0,
      "max_cost": 0.06,
      "error": null,
      "metadata": {
        "customer_id": "c_812"
      },
      "created_at": "2026-11-20T13:40:00.000Z",
      "completed_at": null,
      "results_expire_at": null
    }
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.14,
    "replayed": false
  }
}

查看任务

GET https://api.won.dev/v1/tasks/{id}

查看任务的进度、花费,以及按顺序排列的结果:每条结果都与单独调用该接口时的响应相同,并附带 HTTP 状态码。结果可以用 cursor 翻页。status 仍为 running 时,可以过一分钟再查,或者等待 task.completed 事件。结果在任务结束 7 天后删除(results_expire_at)。免费。

参数

id 放在路径中,其余参数放在查询字符串里。

参数类型必填说明(API 原文)
idstring是Task ID, such as task_7p1q8w3e5r4k2m9x.
limitinteger否How many to return, 1 to 100. Default: 20.
cursorstring否To get the next page, pass next_cursor of the previous response back unchanged, with the same parameters.

响应

字段类型说明(API 原文)
dataobjectThe task, and a page of its results.
data.taskobject
data.task.idstringTask ID, such as task_7p1q8w3e5r4k2m9x.
data.task.operationstringThe endpoint it runs, such as enrich.email.verify.
data.task.statusrunning | completed | failed | canceledrunning, then completed, failed (it stopped early, and error says why) or canceled.
data.task.progressobjectHow far it got.
data.task.progress.doneintegerParts answered, or for leads the leads found.
data.task.progress.totalintegerParts of the batch, or the leads asked for.
data.task.progress.failedintegerParts answered with an error. They cost nothing.
data.task.costnumberWhat it cost so far, in US dollars.
data.task.max_costnumberThe most it can cost, in US dollars.
data.task.errorobject | nullWhy it stopped early: the error of the call that stopped it, such as insufficient_balance. Null otherwise.
data.task.error.codestring
data.task.error.messagestring
data.task.metadataobjectYour own keys and values, as you gave them. Empty when none were.
data.task.created_atstringWhen it was created, ISO 8601.
data.task.completed_atstring | nullWhen it ended. Null while it runs.
data.task.results_expire_atstring | nullWhen the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs.
data.resultsobject[]The results of this page, in order.
data.results[].indexintegerThe part of inputs it answers, or the page of leads, from 0.
data.results[].statusintegerThe HTTP status of the call: 200, or the status of its error.
data.results[].bodyobjectThe answer, exactly as a call of the endpoint returns it: its body or its error.
has_morebooleanWhether more results follow this page.
next_cursorstring | nullPass it as cursor to get the next page of results. Null on the last page.
noticestring | nullA plain sentence when there is something to know about this answer. Null otherwise.
usageobjectNothing is charged here. The balance, for reference.
usage.costnumberWhat this call cost, in US dollars.
usage.balancenumberThe balance left after this call, in US dollars.
usage.replayedbooleanTrue when this is a repeat of a request from the last 24 hours. Repeats are free.

示例

curl "https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x?limit=1" \
  -H "Authorization: Bearer $WON_API_KEY"
{
  "data": {
    "task": {
      "id": "task_7p1q8w3e5r4k2m9x",
      "operation": "enrich.people.email.find",
      "status": "completed",
      "progress": {
        "done": 100,
        "total": 100,
        "failed": 2
      },
      "cost": 1.86,
      "max_cost": 3,
      "error": null,
      "metadata": {
        "customer_id": "c_812"
      },
      "created_at": "2026-11-20T13:40:00.000Z",
      "completed_at": "2026-11-20T13:46:12.000Z",
      "results_expire_at": "2026-11-27T13:46:12.000Z"
    },
    "results": [
      {
        "index": 0,
        "status": 200,
        "body": {
          "data": {
            "email": {
              "address": "dana.reyes@harbor-chairs.com",
              "status": "verified"
            },
            "person": null
          },
          "query": {
            "first_name": "Dana",
            "last_name": "Reyes",
            "domain": "harbor-chairs.com"
          },
          "notice": null,
          "usage": {
            "unit": "person_email",
            "records": 1,
            "already_paid": 0,
            "cost": 0.03,
            "balance": 49.97,
            "replayed": false
          }
        }
      }
    ]
  },
  "has_more": true,
  "next_cursor": "cur_Zx81kQp4b2JtMW0uMXJ6ZzQ",
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.14,
    "replayed": false
  }
}

列出任务

GET https://api.won.dev/v1/tasks

列出你的任务,按时间倒序,包含状态、进度和花费。具体结果用 GET /tasks/{id} 查看。免费。

参数

参数放在查询字符串里。

参数类型必填说明(API 原文)
limitinteger否How many to return, 1 to 100. Default: 25.
cursorstring否To get the next page, pass next_cursor of the previous response back unchanged, with the same parameters.

响应

字段类型说明(API 原文)
dataobject[]The tasks, newest first.
data[].idstringTask ID, such as task_7p1q8w3e5r4k2m9x.
data[].operationstringThe endpoint it runs, such as enrich.email.verify.
data[].statusrunning | completed | failed | canceledrunning, then completed, failed (it stopped early, and error says why) or canceled.
data[].progressobjectHow far it got.
data[].progress.doneintegerParts answered, or for leads the leads found.
data[].progress.totalintegerParts of the batch, or the leads asked for.
data[].progress.failedintegerParts answered with an error. They cost nothing.
data[].costnumberWhat it cost so far, in US dollars.
data[].max_costnumberThe most it can cost, in US dollars.
data[].errorobject | nullWhy it stopped early: the error of the call that stopped it, such as insufficient_balance. Null otherwise.
data[].error.codestring
data[].error.messagestring
data[].metadataobjectYour own keys and values, as you gave them. Empty when none were.
data[].created_atstringWhen it was created, ISO 8601.
data[].completed_atstring | nullWhen it ended. Null while it runs.
data[].results_expire_atstring | nullWhen the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs.
has_morebooleanWhether more follow this page.
next_cursorstring | nullPass it as cursor to get the next page. Null on the last page.
noticestring | nullA plain sentence when there is something to know about this answer. Null otherwise.
usageobjectNothing is charged here. The balance, for reference.
usage.costnumberWhat this call cost, in US dollars.
usage.balancenumberThe balance left after this call, in US dollars.
usage.replayedbooleanTrue when this is a repeat of a request from the last 24 hours. Repeats are free.

示例

curl "https://api.won.dev/v1/tasks?limit=1" \
  -H "Authorization: Bearer $WON_API_KEY"
{
  "data": [
    {
      "id": "task_7p1q8w3e5r4k2m9x",
      "operation": "enrich.people.email.find",
      "status": "completed",
      "progress": {
        "done": 100,
        "total": 100,
        "failed": 2
      },
      "cost": 1.86,
      "max_cost": 3,
      "error": null,
      "metadata": {
        "customer_id": "c_812"
      },
      "created_at": "2026-11-20T13:40:00.000Z",
      "completed_at": "2026-11-20T13:46:12.000Z",
      "results_expire_at": "2026-11-27T13:46:12.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null,
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.14,
    "replayed": false
  }
}

取消任务

POST https://api.won.dev/v1/tasks/{id}/cancel

停止一个正在运行的任务,不再启动新的子调用。已经开始的子调用会照常完成并计费,任务已产生的结果全部保留。取消后会发出 status: canceled 的 task.completed 事件。免费。

参数

id 放在路径中。

参数类型必填说明(API 原文)
idstring是Task ID, such as task_7p1q8w3e5r4k2m9x.

响应

字段类型说明(API 原文)
dataobjectThe task, canceled.
data.idstringTask ID, such as task_7p1q8w3e5r4k2m9x.
data.operationstringThe endpoint it runs, such as enrich.email.verify.
data.statusrunning | completed | failed | canceledrunning, then completed, failed (it stopped early, and error says why) or canceled.
data.progressobjectHow far it got.
data.progress.doneintegerParts answered, or for leads the leads found.
data.progress.totalintegerParts of the batch, or the leads asked for.
data.progress.failedintegerParts answered with an error. They cost nothing.
data.costnumberWhat it cost so far, in US dollars.
data.max_costnumberThe most it can cost, in US dollars.
data.errorobject | nullWhy it stopped early: the error of the call that stopped it, such as insufficient_balance. Null otherwise.
data.error.codestring
data.error.messagestring
data.metadataobjectYour own keys and values, as you gave them. Empty when none were.
data.created_atstringWhen it was created, ISO 8601.
data.completed_atstring | nullWhen it ended. Null while it runs.
data.results_expire_atstring | nullWhen the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs.
noticestring | nullA plain sentence when there is something to know about this answer. Null otherwise.
usageobjectNothing is charged here. The balance, for reference.
usage.costnumberWhat this call cost, in US dollars.
usage.balancenumberThe balance left after this call, in US dollars.
usage.replayedbooleanTrue when this is a repeat of a request from the last 24 hours. Repeats are free.

示例

curl https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x/cancel \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
{
  "data": {
    "id": "task_7p1q8w3e5r4k2m9x",
    "operation": "enrich.people.email.find",
    "status": "canceled",
    "progress": {
      "done": 35,
      "total": 100,
      "failed": 0
    },
    "cost": 0.84,
    "max_cost": 3,
    "error": null,
    "metadata": {
      "customer_id": "c_812"
    },
    "created_at": "2026-11-20T13:40:00.000Z",
    "completed_at": "2026-11-20T13:46:12.000Z",
    "results_expire_at": "2026-11-27T13:46:12.000Z"
  },
  "notice": null,
  "usage": {
    "cost": 0,
    "balance": 48.14,
    "replayed": false
  }
}

本页内容