# Quickstart

Create an API key at https://leadsagent.io/dashboard/connectors/api-keys. Give it leads:write to start and change work, or leads:read to read saved tasks and leads. Keep the key in an environment variable.

```sh
export LEADSAGENT_API_BASE=https://leadsagent.io/api/v1
```

curl --fail-with-body --silent --show-error --request POST "$LEADSAGENT_API_BASE/tasks" -H "X-API-Key: $LEADSAGENT_API_KEY" -H "Content-Type: application/json" --data '{
  "prompt": "Find 20 dentists in Austin with emails",
  "max_leads": 20,
  "idempotency_key": "austin-dentists-001",
  "allow_questions": true
}'

Save data.id. Poll GET /tasks/{id} every 10–20 seconds. If status is needs_input, POST /tasks/{id}/messages with answers. When status is completed, GET /tasks/{id}/results and follow next_cursor until has_more is false. Use GET /tasks/{id}/export to download every row.

HTTP 202 means accepted. Read the task until it reaches completed, failed, cancelled or needs_input. Each row page is capped at 1,000 rows and 256 KiB. The full request body limit is 1 MiB.

[All documentation](https://leadsagent.io/documentation/quickstart)
[OpenAPI](https://leadsagent.io/documentation/openapi.json)
