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

# Agent endpoint

> Run scraping tasks with a single prompt

The `/api/agent` endpoint takes a natural-language `prompt` and chooses a strategy (`extract`, `crawl`, or `scrape`) for you.

## Key parameter

* `prompt`: what you want to collect

## Example

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.fetchfox.ai/api/agent \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "Find product URLs on pokemondb.net and extract name and number for each pokemon."
  }'
  ```
</CodeGroup>

Typical response shape:

```json theme={null}
{
  "jobId": "abc123",
  "results": {
    "hits": [
      "https://pokemondb.net/pokedex/all",
      "https://pokemondb.net/pokedex/bulbasaur"
    ],
    "items": [
      {
        "name": "Bulbasaur",
        "number": "0001",
        "_url": "https://pokemondb.net/pokedex/bulbasaur",
        "_htmlUrl": "https://ffxyz.s3.amazonaws.com/visit/html/example.html"
      }
    ]
  },
  "metrics": { ... }
}
```

## Pattern vs query crawl behavior

The agent can route crawl-like work in two ways:

* **Pattern-based crawl**: URL wildcard matching (`pattern`).
* **Query-based crawl**: semantic page scanning (`query`) from seed URLs.

This distinction matters for behavior, but you usually only provide `prompt` and let the agent choose.
