Pular para o conteúdo
Won.dev
DocumentaçãoReferência da API

Tarefas

Execute em segundo plano até 100 buscas ou 500 leads, com cobrança por parte, e leia os resultados quando terminarem.

Uma tarefa faz por você, em segundo plano, muitas chamadas a um mesmo endpoint, para que um agente não precise enviá-las uma a uma nem manter uma conexão aberta enquanto elas rodam.

  • enrich.people.email.find, enrich.email.verify e signals.find recebem inputs: até 100 partes, cada uma o corpo de uma chamada. trade.leads.find recebe um único input cujo limit vai até 500, e a tarefa percorre a lista por você.
  • Cada parte roda e é cobrada exatamente como uma chamada avulsa, então uma tarefa custa o que as chamadas dela custam. Criar, consultar, listar e cancelar uma tarefa é grátis. max_cost recusa uma tarefa que possa custar mais, e dry_run: true informa o máximo que ela pode custar.
  • Criar uma tarefa responde 202 Accepted na hora, com a URL da tarefa no cabeçalho Location: acompanhe-a ali com GET /tasks/{id} até que status deixe de ser running.
  • Uma tarefa que fica sem saldo, ou sem o orçamento da chave, para como failed e mantém o que fez.
  • Quando uma tarefa termina, task.completed vai para os seus webhooks e para GET /events. A sua própria metadata, como o ID de um cliente, volta na tarefa e nesse evento.
  • Os resultados ficam guardados por 7 dias depois do fim, ou 1 dia quando uma fonte não permite guardá-los. A tarefa em si aparece na lista por 30 dias.
  • Uma chave de teste roda cada parte no sandbox, nunca gera cobrança e só vê as tarefas criadas com chave de teste.
  • O mesmo está nas ferramentas task_create e task_get do servidor MCP.

Criar uma tarefa

Executa em segundo plano muitas chamadas a um mesmo endpoint: até 100 buscas de e-mail corporativo (enrich.people.email.find), verificações de endereço (enrich.email.verify) ou checagens de sinais de empresas (signals.find), uma por item de inputs, ou até 500 leads (trade.leads.find) a partir de um único input cujo limit vai até 500. Cada parte funciona exatamente como uma chamada avulsa: é cobrada pelo preço do endpoint pelo que retorna, e repetições e resultados pagos nos últimos 30 dias são grátis. Criar a tarefa é grátis. max_cost recusa uma tarefa que possa custar mais, e dry_run: true informa o máximo que ela pode custar. Uma tarefa que fica sem saldo ou sem orçamento da chave termina como failed e mantém o que fez. Acompanhe com GET /tasks/{id} ou espere o evento task.completed. Os resultados ficam guardados por 7 dias depois do fim. Com um cabeçalho Idempotency-Key, uma nova tentativa nunca cria uma segunda tarefa. Endpoints: trade.leads.find, enrich.people.email.find, enrich.email.verify, signals.find.

POST
/tasks

Autenticação

apiKey
headerAuthorizationBearer <chave de API>

Authorization: Bearer won_live_..., a key from the console.

Parâmetros de cabeçalho

Idempotency-Key?string

Any unique string. A retry with the same key and the same body returns the first response and is not charged again.

Tamanholength <= 255

Corpo da requisição

application/json
  1. body
operation*string

What to run: trade.leads.find, enrich.people.email.find, enrich.email.verify, signals.find.

Valores"trade.leads.find""enrich.people.email.find""enrich.email.verify""signals.find"
inputs?array<>

For a batch: up to 100 parts, each the body of one call of the endpoint, such as {"email": "jane@example.com"}.

Itens1 <= items <= 100
input?

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_cost?number

The most the whole task may cost, in US dollars. A task that could cost more is refused before anything runs.

Intervalo0 < value
dry_run?boolean

Only say the most the task can cost. Nothing is created or charged.

Padrãofalse
metadata?

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.

Corpo da resposta

Nothing was started: the answer to dry_run: true.

application/json
  1. response
data*

The task, and the most it can cost.

notice*|

A plain sentence when there is something to know about this answer. Null otherwise.

usage*

Nothing is charged here. The balance, for reference.

Requisição de exemplo
curl -X POST 'https://api.won.dev/v1/tasks' \  -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"  }}'
Resposta de exemplo
{  "data": {    "dry_run": true,    "max_cost": 0,    "task": {      "id": "string",      "operation": "string",      "status": "running",      "progress": {        "done": 0,        "total": 0,        "failed": 0      },      "cost": 0,      "max_cost": 0,      "error": {        "code": "string",        "message": "string"      },      "metadata": {        "property1": "string",        "property2": "string"      },      "created_at": "string",      "completed_at": "string",      "results_expire_at": "string"    }  },  "notice": "string",  "usage": {    "cost": 0,    "balance": 0,    "replayed": true  }}

Consultar uma tarefa

Uma tarefa, até onde ela chegou e quanto custou, com os resultados em ordem: cada um é a resposta que uma chamada ao endpoint dá, com o status HTTP. Navegue pelos resultados com cursor. Enquanto status for running, consulte de novo em um minuto ou espere o evento task.completed. Os resultados são apagados 7 dias depois do fim (results_expire_at). Grátis.

GET
/tasks/{id}

Autenticação

apiKey
headerAuthorizationBearer <chave de API>

Authorization: Bearer won_live_..., a key from the console.

Parâmetros de caminho

id*string

Task ID, such as task_7p1q8w3e5r4k2m9x.

Tamanholength <= 40

Parâmetros de consulta

limit?integer

How many to return, 1 to 100.

Intervalo1 <= value <= 100
Padrão20
cursor?string

To get the next page, pass next_cursor of the previous response back unchanged, with the same parameters.

Tamanholength <= 200

Corpo da resposta

The result.

application/json
  1. response
data*

The task, and a page of its results.

has_more*boolean

Whether more results follow this page.

next_cursor*|

Pass it as cursor to get the next page of results. Null on the last page.

notice*|

A plain sentence when there is something to know about this answer. Null otherwise.

usage*

Nothing is charged here. The balance, for reference.

Requisição de exemplo
curl -X GET 'https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x?limit=1'
Resposta de exemplo
{  "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  }}

Listar tarefas

As suas tarefas, da mais recente para a mais antiga, com status, progresso e custo. Os resultados vêm com GET /tasks/{id}. Grátis.

GET
/tasks

Autenticação

apiKey
headerAuthorizationBearer <chave de API>

Authorization: Bearer won_live_..., a key from the console.

Parâmetros de consulta

limit?integer

How many to return, 1 to 100.

Intervalo1 <= value <= 100
Padrão25
cursor?string

To get the next page, pass next_cursor of the previous response back unchanged, with the same parameters.

Tamanholength <= 200

Corpo da resposta

The result.

application/json
  1. response
data*array<>

The tasks, newest first.

has_more*boolean

Whether more follow this page.

next_cursor*|

Pass it as cursor to get the next page. Null on the last page.

notice*|

A plain sentence when there is something to know about this answer. Null otherwise.

usage*

Nothing is charged here. The balance, for reference.

Requisição de exemplo
curl -X GET 'https://api.won.dev/v1/tasks?limit=1'
Resposta de exemplo
{  "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  }}

Cancelar uma tarefa

Interrompe uma tarefa em andamento: nenhuma parte nova começa. As partes que já estavam em andamento terminam e são cobradas normalmente, e tudo o que ela fez fica guardado. Envia task.completed com status: canceled. Grátis.

POST
/tasks/{id}/cancel

Autenticação

apiKey
headerAuthorizationBearer <chave de API>

Authorization: Bearer won_live_..., a key from the console.

Parâmetros de caminho

id*string

Task ID, such as task_7p1q8w3e5r4k2m9x.

Tamanholength <= 40

Parâmetros de cabeçalho

Idempotency-Key?string

Any unique string. A retry with the same key and the same body returns the first response and is not charged again.

Tamanholength <= 255

Corpo da resposta

The result.

application/json
  1. response
data*

The task, canceled.

notice*|

A plain sentence when there is something to know about this answer. Null otherwise.

usage*

Nothing is charged here. The balance, for reference.

Requisição de exemplo
curl -X POST 'https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x/cancel'
Resposta de exemplo
{  "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  }}

Última atualização em