> ## 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.

# Create an agent

> Create a Discovery Agent from a manual brief

Creates a Discovery Agent from a manual brief and requests its first search step. The agent then starts searching on its own. Requires the `write:discovery` permission and a plan that includes the Discovery Agent.

Supply the product website, `product_brand`, `audience`, and at least one keyword or competitor URL. Missing brief fields are not filled in for you.

> [!NOTE]
>
> Lookalike URLs do not count and are not accepted here. Add them after create with [Update lookalikes](https://docs.affonso.io/api/endpoint/discovery/update-lookalikes.md). `auto_approve` is not accepted on create. Set it with [Update an agent](https://docs.affonso.io/api/endpoint/discovery/update-agent.md).

The body is strict. Unknown fields are rejected. For the full flow from setup to review, see [How the Discovery Agent works](https://docs.affonso.io/api/endpoint/discovery/get-setup-defaults.md#how-the-discovery-agent-works).

## Body Parameters

**website** `string` *required*

Public product website, for example `https://example.com`. Must be a valid `http` or `https` URL that resolves to a public address.

**name** `string`

Display name, 1 to 160 characters. Defaults to `Discovery agent`.

**product\_brand** `string` *required*

Product or brand the agent finds partners for, 1 to 200 characters.

**audience** `string` *required*

One-sentence description of the customers the product serves, 1 to 500 characters.

**language** `string` (default: en)

Search language as a two-letter ISO 639-1 code. Stored in lowercase.

**channel** `string` (default: websites)

Where the agent searches. Only `websites` is accepted.

**exclude\_groups** `string[]` (default: \[])

Website categories to leave out of results. Up to 5 of `directories`, `marketplaces`, `social_networks`, `news`, `review_sites`.

**keywords** `string[]` (default: \[])

Topics to search for, up to 25. Each keyword is 1 to 200 characters. Duplicates are removed without regard to case. Send at least one keyword or one competitor.

**competitors** `string[]` (default: \[])

Competitor website URLs, up to 25. Each must be a public `http` or `https` URL. Duplicates are removed. Send at least one keyword or one competitor.

## Response

Returns `201 Created` with the new agent. `latest_run` is `null` in this response.

**success** `boolean`

`true` when the request succeeds.

**data** `object`

The new Discovery Agent.

**Agent fields**

**id** `string`

Agent ID.

**name** `string`

Display name. Defaults to `Discovery agent` when no name was given on create.

**website** `string | null`

Product website from the agent brief.

**product\_brand** `string | null`

Product or brand the agent finds partners for.

**audience** `string | null`

One-sentence description of the customers the product serves.

**language** `string | null`

Search language as a lowercase ISO 639-1 code, for example `en`.

**channel** `string | null`

Where the agent searches. Currently always `websites`.

**exclude\_groups** `string[]`

Website categories the agent leaves out of results: `directories`, `marketplaces`, `social_networks`, `news`, `review_sites`.

**keywords** `string[]`

Topic sources the agent searches for.

**competitors** `string[]`

Competitor website URLs the agent uses as search sources.

**lookalikes** `string[]`

Lookalike page URLs. Managed with [Update lookalikes](https://docs.affonso.io/api/endpoint/discovery/update-lookalikes.md).

**sources** `array`

Every saved source, oldest first.

**Source fields**

**id** `string`

Source ID.

**type** `string`

`topic`, `competitor`, or `lookalike`.

**value** `string`

The keyword for a topic. The hostname without `www.` for a competitor. The URL for a lookalike.

**website** `string | null`

Full URL for competitor and lookalike sources. `null` for topics.

**created\_at** `string`

ISO 8601 timestamp.

**updated\_at** `string`

ISO 8601 timestamp.

**can\_start** `boolean`

`true` when the agent has at least one keyword or competitor. Lookalikes do not count.

**auto\_approve** `boolean`

When `true`, newly delivered prospects are approved automatically and queued for contact enrichment.

**schedulable** `boolean`

`false` while the agent is paused or deleted.

**paused\_at** `string | null`

ISO 8601 timestamp of the last pause. `null` while the agent is live.

**archived\_at** `string | null`

ISO 8601 timestamp of deletion. `null` unless the agent was deleted.

**latest\_run** `object | null`

Most recent search run, or `null` when the agent has no run yet.

**Latest run fields**

**id** `string`

Run ID.

**status** `string`

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

**started\_at** `string`

ISO 8601 timestamp.

**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 each invalid field. A missing `product_brand` or `audience` returns `["Required"]` for that field. When both `keywords` and `competitors` are missing or empty, both fields return `["Provide at least one keyword or competitor"]`. Only the fields you left out or sent invalid appear in `details`, so a request that has keywords but no `audience` lists only `audience`.
* **400** `UNSAFE_URL`: a URL is not a public http or https address. This covers URLs with credentials, local or private hosts, hosts that do not resolve, and hosts that resolve to a non-public address.
* **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`.

A request with only `website` returns:

```json Website only theme={null}
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request",
    "details": {
      "product_brand": ["Required"],
      "audience": ["Required"],
      "keywords": ["Provide at least one keyword or competitor"],
      "competitors": ["Provide at least one keyword or competitor"]
    }
  }
}
```

```json No active plan theme={null}
{
  "success": false,
  "error": {
    "code": "FORBIDDEN",
    "message": "Discovery Agent needs an active plan"
  }
}
```

```bash cURL theme={null}
curl -X POST "https://api.affonso.io/v1/discovery/agents" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Newsletter partners",
    "website": "https://example.com",
    "product_brand": "Example Mail, email marketing for small shops",
    "audience": "Owners of small online shops who send a weekly newsletter.",
    "language": "en",
    "exclude_groups": ["directories", "marketplaces"],
    "keywords": ["email marketing for small business"],
    "competitors": ["https://example.org"]
  }'
```

```json 201 Created theme={null}
{
  "success": true,
  "data": {
    "id": "cmn4agt0001xk92hf6d0abcd",
    "name": "Newsletter partners",
    "website": "https://example.com",
    "product_brand": "Example Mail, email marketing for small shops",
    "audience": "Owners of small online shops who send a weekly newsletter.",
    "language": "en",
    "channel": "websites",
    "exclude_groups": ["directories", "marketplaces"],
    "keywords": ["email marketing for small business"],
    "competitors": ["https://example.org"],
    "lookalikes": [],
    "sources": [
      {
        "id": "cmn4src0001xk92hf6d0abcd",
        "type": "topic",
        "value": "email marketing for small business",
        "website": null,
        "created_at": "2026-11-02T09:00:00.000Z",
        "updated_at": "2026-11-02T09:00:00.000Z"
      },
      {
        "id": "cmn4src0002xk92hf6d0abcd",
        "type": "competitor",
        "value": "example.org",
        "website": "https://example.org",
        "created_at": "2026-11-02T09:00:00.000Z",
        "updated_at": "2026-11-02T09:00:00.000Z"
      }
    ],
    "can_start": true,
    "auto_approve": false,
    "schedulable": true,
    "paused_at": null,
    "archived_at": null,
    "latest_run": null,
    "created_at": "2026-11-02T09:00:00.000Z",
    "updated_at": "2026-11-02T09:00:00.000Z"
  }
}
```


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