API reference

All endpoints under /api/v1.

Leads

GET /api/v1/leads

List leads. Returns up to limit rows (max 100, default 50).

bash
curl -H "Authorization: Bearer $SONAR_KEY" \
  https://sonar-cyan-seven.vercel.app/api/v1/leads?limit=20
json
{
  "data": [
    {
      "id": "8c5a...",
      "name": "Jane Doe",
      "email": "jane@acme.com",
      "companyName": "Acme Inc",
      "companyWebsite": "https://acme.com",
      "status": "DISCOVERY",
      "assignedToUserId": "...",
      "createdAt": "2026-05-15T14:23:00.000Z",
      "updatedAt": "2026-05-15T14:23:00.000Z"
    }
  ]
}

Required scope: leads:read.

POST /api/v1/leads

Create a lead.

bash
curl -H "Authorization: Bearer $SONAR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane Doe","companyName":"Acme","status":"DISCOVERY"}' \
  https://sonar-cyan-seven.vercel.app/api/v1/leads

Required scope: leads:write. Returns the created lead with status 201.

Agent runs

POST /api/v1/runs

Start an agent run. Returns 202 with the run id; poll GET /api/v1/runs/{id} for progress.

bash
curl -H "Authorization: Bearer $SONAR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"leadId":"<uuid>","callId":"<uuid>"}' \
  https://sonar-cyan-seven.vercel.app/api/v1/runs

Required scope: runs:write. Returns 402 when the workspace has hit its Free-plan monthly run limit.

GET /api/v1/runs/{id}

Fetch a run with its step outputs.

json
{
  "data": {
    "id": "ab12...",
    "status": "AWAITING_APPROVAL",
    "leadId": "8c5a...",
    "callId": "df3a...",
    "startedAt": "...",
    "completedAt": "...",
    "traceUrl": "https://smith.langchain.com/...",
    "steps": [
      { "node": "RESEARCH", "status": "COMPLETED", "output": { ... } },
      { "node": "ANALYSIS", "status": "COMPLETED", "output": { ... } },
      { "node": "STRATEGY", "status": "COMPLETED", "output": { ... } },
      { "node": "WRITER",   "status": "COMPLETED", "output": { ... } }
    ],
    "emailDraft": { "id": "...", "status": "DRAFT", "subject": "..." }
  }
}

Required scope: runs:read.