API reference

Chat API

A stateless RAG (Retrieval-Augmented Generation) chat endpoint. Ask questions about your codebase and get answers grounded in your synced documentation, code, and database context.

Note: The chat endpoint is stateless — each request is independent. There is no session or conversation history. For multi-turn conversations, include prior context in your message.
POST/api/v1/chatchat

Send a single-turn message and get an answer grounded in your workspace context. The response includes source references and, for database queries, structured row data.

Request body

NameTypeRequiredDescription
messagestringrequiredThe user message or question. 1–4000 characters.
type"documentation" | "database" | "both"requiredContext type to search. Use "documentation" for code/docs questions, "database" for SQL-based answers, or "both".
repostringoptionalOptional repository filter. Scopes retrieval to a single repo.

Request

curl -X POST https://scopedocs-ai-production.up.railway.app/api/v1/chat \
  -H "X-API-Key: sk-sd_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "How does the authentication service work?",
    "type": "documentation",
    "repo": "acme/backend"
  }'

Response

JSON
{
  "answer": "The authentication service uses JWT tokens issued by Supabase Auth. It supports OAuth 2.0 for GitHub, Slack, and Linear integrations. API requests are authenticated via the `X-API-Key` header or `Authorization: Bearer` header...",
  "sources": [
    {
      "id": "d1a2b3c4-e5f6-7890-abcd-ef1234567890",
      "title": "Authentication Service Overview",
      "similarity": 0.92,
      "excerpt": "JWT issuance and validation is handled by..."
    }
  ],
  "db_result": null
}