API · Set up agents
Teach it your business
The Business Brain is what your agent knows and how it behaves. Build it from your website, write it yourself, or both. Render-mode sessions don't use it: there, your own agent does the thinking.
Build it from your website
- 1
Set the website
Create the agent with
website_url, or set it withPATCH /v1/agent/{agent_id}. - 2
See which pages it found
GET/v1/agent/{agent_id}/extract-linksThe pages linked from your homepage and sitemap, scored, each with a suggested category.
Response
{ "homepage_url": "https://bloomhair.example", "links": [ { "url": "https://bloomhair.example/services", "path": "/services", "anchor": "Services", "score": 92, "source": "homepage", "default_category": "primary" }, { "url": "https://bloomhair.example/prices", "path": "/prices", "anchor": "Prices", "score": 88, "source": "homepage", "default_category": "primary" } ], "total_found": 14 } - 3
Build
POST/v1/agent/{agent_id}/generate-brainSend the pages to learn from.
is_primary: truefor the pages that describe the business (home, services, prices, contact),falsefor background reading. Then pollGET /v1/agent/{agent_id}/brain-statusuntil it is no longerpendingorprocessing: it takes a few minutes.curl -X POST https://talk.selviaai.com/v1/agent/42/generate-brain \ -H "Authorization: Bearer $SELVIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"pages": [ {"url": "https://bloomhair.example", "is_primary": true}, {"url": "https://bloomhair.example/services", "is_primary": true}, {"url": "https://bloomhair.example/blog/summer-trends", "is_primary": false} ]}'
| brain_status | Meaning |
|---|---|
pending | Queued. |
processing | Being built. Conversation sessions for this agent answer 409 agent_building until it is done. |
complete | Ready. The status answer also carries the instructions it produced. |
failed | Something went wrong; build again, or write the instructions yourself. |
Write it yourself
Set system_prompt on the agent with PATCH /v1/agent/{agent_id}: who it is, what the business offers, how it should talk and what it must never do. You can do this instead of a build, or edit what a build produced.
Add knowledge
A section of facts
/v1/agent/{agent_id}/kb-sectionsA short titled piece of knowledge: opening hours, parking, a policy. List, change and delete them with the same path.
curl -X POST https://talk.selviaai.com/v1/agent/42/kb-sections \
-H "Authorization: Bearer $SELVIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title": "Parking", "content": "Free parking behind the salon; enter from Oak Street."}'Another page of your website
/v1/agent/{agent_id}/add-page{"url": "https://…", "is_primary": true} reads one more page into what it knows. List the pages it learned from with GET /v1/agent/{agent_id}/pages/list.
/v1/agent/{agent_id}/v2/…. Every route is listed in All endpoints.