# Tareas

Source: https://won.dev/es/docs/tasks

Una tarea hace por ti muchas llamadas a un mismo endpoint en segundo plano, para que un agente no tenga que enviarlas una por una ni mantener una conexión abierta mientras se ejecutan.

- `enrich.people.email.find`, `enrich.email.verify` y `signals.find` reciben `inputs`: hasta 100 partes, cada una el cuerpo de una llamada. `trade.leads.find` recibe un solo `input` cuyo `limit` llega a 500, y la tarea recorre la lista por ti.
- Cada parte se ejecuta y se cobra exactamente como una llamada propia, así que una tarea cuesta lo que cuestan sus llamadas. Crear, consultar, listar y cancelar una tarea es gratis. `max_cost` rechaza una tarea que podría costar más, y `dry_run: true` dice lo máximo que puede costar.
- Crear una tarea responde `202 Accepted` de inmediato, con la URL de la tarea en el encabezado `Location`: síguela ahí con `GET /tasks/{id}` hasta que `status` deje de ser `running`.
- Una tarea que se queda sin saldo, o sin el presupuesto de su clave, se detiene como `failed` y conserva lo que hizo.
- Cuando una tarea termina, `task.completed` llega a tus [webhooks](/es/docs/email/webhooks-create) y a `GET /events`. Tu propia `metadata`, como el ID de un cliente, vuelve en la tarea y en ese evento.
- Los resultados se guardan 7 días después del final, o 1 día cuando una fuente no permite guardarlos. La tarea en sí aparece en la lista durante 30 días.
- Una clave de prueba ejecuta cada parte en el sandbox, nunca genera cargos y solo ve las tareas creadas con una clave de prueba.
- Lo mismo está disponible en las herramientas `task_create` y `task_get` del [servidor MCP](/es/docs/mcp).

## Crear una tarea [#create]

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

Ejecuta en segundo plano muchas llamadas a un mismo endpoint: hasta 100 búsquedas de correo de trabajo (`enrich.people.email.find`), verificaciones de direcciones (`enrich.email.verify`) o revisiones de señales de empresas (`signals.find`), una por cada elemento de `inputs`, o hasta 500 leads (`trade.leads.find`) a partir de un solo `input` cuyo `limit` llega a 500. Cada parte funciona exactamente como una llamada propia: se cobra al precio del endpoint por lo que devuelve, y las repeticiones y los resultados pagados en los últimos 30 días son gratis. Crear la tarea es gratis. `max_cost` rechaza una tarea que podría costar más, y `dry_run: true` dice lo máximo que puede costar. Una tarea que se queda sin saldo o sin presupuesto de su clave termina como `failed` y conserva lo que hizo. Síguela con `GET /tasks/{id}` o espera el evento `task.completed`. Los resultados se guardan 7 días después del final. Con un encabezado `Idempotency-Key`, un reintento nunca crea una segunda tarea. Endpoints: `trade.leads.find`, `enrich.people.email.find`, `enrich.email.verify`, `signals.find`.

### Parámetros [#create-parameters]

Los parámetros van en el cuerpo JSON.

| Parámetro | Tipo | Obligatorio | Descripción (texto original de la API) |
| --- | --- | --- | --- |
| `operation` | `trade.leads.find` \| `enrich.people.email.find` \| `enrich.email.verify` \| `signals.find` | sí | What to run: `trade.leads.find`, `enrich.people.email.find`, `enrich.email.verify`, `signals.find`. |
| `inputs` | object[] | no | For a batch: up to 100 parts, each the body of one call of the endpoint, such as `{"email": "jane@example.com"}`. |
| `input` | object | no | 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 | no | The most the whole task may cost, in US dollars. A task that could cost more is refused before anything runs. |
| `dry_run` | boolean | no | Only say the most the task can cost. Nothing is created or charged. Default: `false`. |
| `metadata` | object | no | 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. |

### Respuesta [#create-response]

| Campo | Tipo | Descripción (texto original de la API) |
| --- | --- | --- |
| `data` | object | The task, and the most it can cost. |
| `data.dry_run` | boolean | True when nothing was created: the answer to `dry_run: true`. |
| `data.max_cost` | number | The most the task can cost, in US dollars. |
| `data.task` | object \| null | The task. Null on a dry run. |
| `data.task.id` | string | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |
| `data.task.operation` | string | The endpoint it runs, such as `enrich.email.verify`. |
| `data.task.status` | `running` \| `completed` \| `failed` \| `canceled` | `running`, then `completed`, `failed` (it stopped early, and `error` says why) or `canceled`. |
| `data.task.progress` | object | How far it got. |
| `data.task.progress.done` | integer | Parts answered, or for leads the leads found. |
| `data.task.progress.total` | integer | Parts of the batch, or the leads asked for. |
| `data.task.progress.failed` | integer | Parts answered with an error. They cost nothing. |
| `data.task.cost` | number | What it cost so far, in US dollars. |
| `data.task.max_cost` | number | The most it can cost, in US dollars. |
| `data.task.error` | object \| null | Why it stopped early: the error of the call that stopped it, such as `insufficient_balance`. Null otherwise. |
| `data.task.error.code` | string |  |
| `data.task.error.message` | string |  |
| `data.task.metadata` | object | Your own keys and values, as you gave them. Empty when none were. |
| `data.task.created_at` | string | When it was created, ISO 8601. |
| `data.task.completed_at` | string \| null | When it ended. Null while it runs. |
| `data.task.results_expire_at` | string \| null | When the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

### Ejemplo [#create-example]

```bash
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"
  }
}'
```

```json
{
  "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
  }
}
```

## Consultar una tarea [#get]

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

Una tarea, cuánto avanzó y cuánto costó, con sus resultados en orden: cada uno es la respuesta que da una llamada al endpoint, con su estado HTTP. Recorre los resultados con `cursor`. Mientras `status` sea `running`, vuelve a consultar en un minuto o espera el evento `task.completed`. Los resultados se eliminan 7 días después del final (`results_expire_at`). Gratis.

### Parámetros [#get-parameters]

`id` va en la ruta. Los demás van en la cadena de consulta.

| Parámetro | Tipo | Obligatorio | Descripción (texto original de la API) |
| --- | --- | --- | --- |
| `id` | string | sí | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |
| `limit` | integer | no | How many to return, 1 to 100. Default: `20`. |
| `cursor` | string | no | To get the next page, pass `next_cursor` of the previous response back unchanged, with the same parameters. |

### Respuesta [#get-response]

| Campo | Tipo | Descripción (texto original de la API) |
| --- | --- | --- |
| `data` | object | The task, and a page of its results. |
| `data.task` | object |  |
| `data.task.id` | string | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |
| `data.task.operation` | string | The endpoint it runs, such as `enrich.email.verify`. |
| `data.task.status` | `running` \| `completed` \| `failed` \| `canceled` | `running`, then `completed`, `failed` (it stopped early, and `error` says why) or `canceled`. |
| `data.task.progress` | object | How far it got. |
| `data.task.progress.done` | integer | Parts answered, or for leads the leads found. |
| `data.task.progress.total` | integer | Parts of the batch, or the leads asked for. |
| `data.task.progress.failed` | integer | Parts answered with an error. They cost nothing. |
| `data.task.cost` | number | What it cost so far, in US dollars. |
| `data.task.max_cost` | number | The most it can cost, in US dollars. |
| `data.task.error` | object \| null | Why it stopped early: the error of the call that stopped it, such as `insufficient_balance`. Null otherwise. |
| `data.task.error.code` | string |  |
| `data.task.error.message` | string |  |
| `data.task.metadata` | object | Your own keys and values, as you gave them. Empty when none were. |
| `data.task.created_at` | string | When it was created, ISO 8601. |
| `data.task.completed_at` | string \| null | When it ended. Null while it runs. |
| `data.task.results_expire_at` | string \| null | When the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs. |
| `data.results` | object[] | The results of this page, in order. |
| `data.results[].index` | integer | The part of `inputs` it answers, or the page of leads, from 0. |
| `data.results[].status` | integer | The HTTP status of the call: 200, or the status of its error. |
| `data.results[].body` | object | The answer, exactly as a call of the endpoint returns it: its body or its error. |
| `has_more` | boolean | Whether more results follow this page. |
| `next_cursor` | string \| null | Pass it as `cursor` to get the next page of results. Null on the last page. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

### Ejemplo [#get-example]

```bash
curl "https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x?limit=1" \
  -H "Authorization: Bearer $WON_API_KEY"
```

```json
{
  "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 tareas [#list]

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

Tus tareas, de la más reciente a la más antigua, con su estado, su avance y su costo. Sus resultados se obtienen con `GET /tasks/{id}`. Gratis.

### Parámetros [#list-parameters]

Los parámetros van en la cadena de consulta.

| Parámetro | Tipo | Obligatorio | Descripción (texto original de la API) |
| --- | --- | --- | --- |
| `limit` | integer | no | How many to return, 1 to 100. Default: `25`. |
| `cursor` | string | no | To get the next page, pass `next_cursor` of the previous response back unchanged, with the same parameters. |

### Respuesta [#list-response]

| Campo | Tipo | Descripción (texto original de la API) |
| --- | --- | --- |
| `data` | object[] | The tasks, newest first. |
| `data[].id` | string | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |
| `data[].operation` | string | The endpoint it runs, such as `enrich.email.verify`. |
| `data[].status` | `running` \| `completed` \| `failed` \| `canceled` | `running`, then `completed`, `failed` (it stopped early, and `error` says why) or `canceled`. |
| `data[].progress` | object | How far it got. |
| `data[].progress.done` | integer | Parts answered, or for leads the leads found. |
| `data[].progress.total` | integer | Parts of the batch, or the leads asked for. |
| `data[].progress.failed` | integer | Parts answered with an error. They cost nothing. |
| `data[].cost` | number | What it cost so far, in US dollars. |
| `data[].max_cost` | number | The most it can cost, in US dollars. |
| `data[].error` | object \| null | Why it stopped early: the error of the call that stopped it, such as `insufficient_balance`. Null otherwise. |
| `data[].error.code` | string |  |
| `data[].error.message` | string |  |
| `data[].metadata` | object | Your own keys and values, as you gave them. Empty when none were. |
| `data[].created_at` | string | When it was created, ISO 8601. |
| `data[].completed_at` | string \| null | When it ended. Null while it runs. |
| `data[].results_expire_at` | string \| null | When the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs. |
| `has_more` | boolean | Whether more follow this page. |
| `next_cursor` | string \| null | Pass it as `cursor` to get the next page. Null on the last page. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

### Ejemplo [#list-example]

```bash
curl "https://api.won.dev/v1/tasks?limit=1" \
  -H "Authorization: Bearer $WON_API_KEY"
```

```json
{
  "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 una tarea [#cancel]

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

Detiene una tarea en curso: no empieza ninguna parte más. Las partes que ya estaban en curso terminan y se cobran como siempre, y todo lo que hizo se conserva. Envía `task.completed` con `status: canceled`. Gratis.

### Parámetros [#cancel-parameters]

`id` va en la ruta.

| Parámetro | Tipo | Obligatorio | Descripción (texto original de la API) |
| --- | --- | --- | --- |
| `id` | string | sí | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |

### Respuesta [#cancel-response]

| Campo | Tipo | Descripción (texto original de la API) |
| --- | --- | --- |
| `data` | object | The task, canceled. |
| `data.id` | string | Task ID, such as `task_7p1q8w3e5r4k2m9x`. |
| `data.operation` | string | The endpoint it runs, such as `enrich.email.verify`. |
| `data.status` | `running` \| `completed` \| `failed` \| `canceled` | `running`, then `completed`, `failed` (it stopped early, and `error` says why) or `canceled`. |
| `data.progress` | object | How far it got. |
| `data.progress.done` | integer | Parts answered, or for leads the leads found. |
| `data.progress.total` | integer | Parts of the batch, or the leads asked for. |
| `data.progress.failed` | integer | Parts answered with an error. They cost nothing. |
| `data.cost` | number | What it cost so far, in US dollars. |
| `data.max_cost` | number | The most it can cost, in US dollars. |
| `data.error` | object \| null | Why it stopped early: the error of the call that stopped it, such as `insufficient_balance`. Null otherwise. |
| `data.error.code` | string |  |
| `data.error.message` | string |  |
| `data.metadata` | object | Your own keys and values, as you gave them. Empty when none were. |
| `data.created_at` | string | When it was created, ISO 8601. |
| `data.completed_at` | string \| null | When it ended. Null while it runs. |
| `data.results_expire_at` | string \| null | When the results are deleted: 7 days after the end, 1 day when a source does not allow keeping them. Null while it runs. |
| `notice` | string \| null | A plain sentence when there is something to know about this answer. Null otherwise. |
| `usage` | object | Nothing is charged here. The balance, for reference. |
| `usage.cost` | number | What this call cost, in US dollars. |
| `usage.balance` | number | The balance left after this call, in US dollars. |
| `usage.replayed` | boolean | True when this is a repeat of a request from the last 24 hours. Repeats are free. |

### Ejemplo [#cancel-example]

```bash
curl https://api.won.dev/v1/tasks/task_7p1q8w3e5r4k2m9x/cancel \
  -H "Authorization: Bearer $WON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```json
{
  "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
  }
}
```