> ## Documentation Index
> Fetch the complete documentation index at: https://docs.affonso.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Start a run

> Ask a Discovery Agent to search now

Asks a Discovery Agent to search now. The agent decides what to search. New prospects appear as delivered matches in [List matches](https://docs.affonso.io/api/endpoint/discovery/list-matches.md). Requires the `write:discovery` permission and a plan that includes the Discovery Agent.

The agent must be live and have at least one keyword or one competitor. Lookalikes do not count.

> [!NOTE]
>
> The response status tells you whether a new step started:
>
> * `201 Created`: a new search step started. `data` describes it.
> * `202 Accepted`: nothing new started right now, for example because a step is already running. `data` describes the running step. When no step is running, `data` is a placeholder with status `pending`, zero counts, and `id` set to the agent ID.

`data.id` is the search run ID when the step already has one. Otherwise it is the ID of the step itself, which does not appear in [List runs](https://docs.affonso.io/api/endpoint/discovery/list-runs.md).

## Path Parameters

**id** `string` *required*

Agent ID.

## Body Parameters

The body is optional.

**depth** `integer` (default: 10)

Accepted for backwards compatibility and ignored. If sent, it must be an integer from 1 to 100. The agent picks its own search depth.

## Response

**success** `boolean`

`true` when the request succeeds.

**data** `object`

The search step.

**Run fields**

**id** `string`

Run ID.

**agent\_id** `string`

Agent that owns the run.

**kind** `string`

`serp` or `lookalike`.

**status** `string`

`pending`, `running`, `completed`, `empty`, or `failed`.

**depth** `integer`

Search depth recorded on the run.

**started\_at** `string`

ISO 8601 timestamp.

**finished\_at** `string | null`

ISO 8601 timestamp, or `null` while the run is not finished.

**error** `string | null`

Error message when the run failed, otherwise `null`.

**queries\_planned** `integer`

Search queries planned for the run.

**queries\_fetched** `integer`

Search queries fetched.

**queries\_empty** `integer`

Fetched queries that returned no results.

**results\_seen** `integer`

Search results the run looked at.

**candidates\_created** `integer`

New candidates the run created.

**created\_at** `string`

ISO 8601 timestamp.

**updated\_at** `string`

ISO 8601 timestamp.

## Errors

* **400** `VALIDATION_ERROR`: the body is not valid JSON or fails validation. The message is `Invalid request` and `details` lists the invalid fields.
* **400** `VALIDATION_ERROR`: the agent has no keyword or competitor. The message is `A Discovery agent needs at least one keyword or one competitor before a run can start. Lookalikes do not count.`
* **404** `NOT_FOUND`: no agent with this ID exists for your team, or the agent was deleted. An agent that belongs to another team also returns `404`. The message is `Discovery agent not found`.
* **409** `CONFLICT`: the agent is paused. The message is `Agent is paused`.
* **403** `INSUFFICIENT_PERMISSIONS`: the API key does not have the `write:discovery` permission.
* **403** `FORBIDDEN`: your team does not have a plan that includes the Discovery Agent. The message is `Discovery Agent needs an active plan`.

```json Agent paused theme={null}
{
  "success": false,
  "error": {
    "code": "CONFLICT",
    "message": "Agent is paused"
  }
}
```

```bash cURL theme={null}
curl -X POST "https://api.affonso.io/v1/discovery/agents/cmn4agt0001xk92hf6d0abcd/runs" \
  -H "Authorization: Bearer sk_live_your_api_key"
```

```json 201 Created theme={null}
{
  "success": true,
  "data": {
    "id": "cmn4run0002xk92hf6d0abcd",
    "agent_id": "cmn4agt0001xk92hf6d0abcd",
    "kind": "serp",
    "status": "running",
    "depth": 10,
    "started_at": "2026-11-08T09:30:00.000Z",
    "finished_at": null,
    "error": null,
    "queries_planned": 6,
    "queries_fetched": 0,
    "queries_empty": 0,
    "results_seen": 0,
    "candidates_created": 0,
    "created_at": "2026-11-08T09:30:00.000Z",
    "updated_at": "2026-11-08T09:30:00.000Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.