Agent API

The AI agent reads conversations, retrieves KB context, calls an LLM, and posts a response (autopilot) or drafts one for review (copilot).

Endpoints

MethodPathScope
GET/v1/projects/{projectId}/agent/statusread
GET/v1/projects/{projectId}/agent/configread
PATCH/v1/projects/{projectId}/agent/configagent:write
POST/v1/projects/{projectId}/agent/respondagent:write
POST/v1/projects/{projectId}/agent/classifyagent:write
POST/v1/projects/{projectId}/agent/suggestagent:write

Status

bash
curl https://api.rogeriq.com/api/v1/projects/prj_xxx/agent/status \ -H "X-API-Key: riq_xxx"
json
{ "data": { "enabled": true, "mode": "copilot", "model": "anthropic/claude-sonnet-4", "domain": "support.acme.com", "has_byom_key": false, "usage_this_month": { "calls": 1284, "input_tokens": 845022, "output_tokens": 184211, "cost_usd": 12.40 } }}

Update config

bash
curl -X PATCH https://api.rogeriq.com/api/v1/projects/prj_xxx/agent/config \ -H "X-API-Key: riq_xxx" \ -H "Content-Type: application/json" \ -d '{"agent_mode": "autopilot", "ai_model": "openai/gpt-4o"}'
agent_modestringbody

autopilot (send replies directly), copilot (draft as internal notes for human review), or assist (suggestions only, no posting).

ai_modelstringbody

Any model id supported by OpenRouter, e.g. anthropic/claude-sonnet-4, openai/gpt-4o, google/gemini-2.5-pro.

0-1. Replies below this confidence are flagged / held for review.

settingsobjectbody

Merged into the project's settings JSON. Includes guardrails, tone, persona, and other agent tuning.

Respond on a conversation

bash
curl -X POST https://api.rogeriq.com/api/v1/projects/prj_xxx/agent/respond \ -H "X-API-Key: riq_xxx" \ -H "Content-Type: application/json" \ -d '{"conversation_id": "con_xxx"}'

Runs the full agent pipeline:

  1. Loads conversation history + contact metadata.
  2. Hybrid-searches the KB for relevant context.
  3. Builds the system prompt + calls the LLM.
  4. Posts the response according to the project's agent_mode.
json
{ "data": { "content": "Hi Jane! ...", "content_html": "<p>Hi Jane! ...</p>", "confidence": 0.82, "mode": "copilot", "effective_mode": "copilot", "message_created": true, "message_id": "msg_xxx", "sources": [{ "id": "kba_xxx", "title": "How refunds work" }], "usage": { "input_tokens": 4500, "output_tokens": 230, "cost_usd": 0.04 } }}

mode_override in the body forces a specific mode for this call only.

Classify

bash
curl -X POST https://api.rogeriq.com/api/v1/projects/prj_xxx/agent/classify \ -H "X-API-Key: riq_xxx" \ -H "Content-Type: application/json" \ -d '{"conversation_id": "con_xxx"}'

Returns intent, sentiment, suggested priority, and tags. Useful for triage automation:

ts
for await (const conv of roger.conversations.listAll({ status: "open" })) { const c = await roger.agent.classify(conv.id); if (c.priority === "urgent") { await roger.conversations.update(conv.id, { priority: "urgent" }); }}

Suggest (without posting)

bash
curl -X POST https://api.rogeriq.com/api/v1/projects/prj_xxx/agent/suggest \ -H "X-API-Key: riq_xxx" \ -H "Content-Type: application/json" \ -d '{"conversation_id": "con_xxx"}'

Same retrieval + generation pipeline as respond, but never posts. Returns the suggested text + sources for human review.

Audit

Every agent.config.updated and agent.responded event is captured in the audit log with the acting API key id.

Ask a question... ⌘I