API Reference

Thotis RAG API endpoints for programmatic access to agents, sessions, and messages.

Authentication

All internal API endpoints require authentication via session cookies (for Makerkit console) or API keys (for embed and external integrations).

The embed endpoint (/api/embed/{agentKey}) is public but protected by domain allowlisting and rate limiting.

Embed API

Send a message

POST /api/embed/{agentKey}
Content-Type: application/json

{
  "question": "What is Parcoursup?",
  "session_id": "optional-uuid",
  "stream": true
}

Response (streaming): text/event-stream with data: {"answer": "...", "done": false} events.

Response (non-streaming): application/json with { "answer": "...", "session_id": "..." }.

Parameters

FieldTypeRequiredDescription
questionstringYesUser message (1-4000 chars)
session_idUUIDNoExisting session ID. Auto-created if omitted
user_idstringNoUser identifier for tracking
user_hashstringNoHMAC hash for identity verification
streambooleanNoEnable SSE streaming (default: false)

Internal API (Makerkit console)

These endpoints are used by the Makerkit control plane and require authenticated sessions.

Publish an agent version

POST /api/internal/rag/publish
{
  "agent_id": "uuid",
  "version_id": "uuid"
}

Rollback an agent

POST /api/internal/rag/rollback
{
  "agent_id": "uuid"
}

Get runtime manifest

GET /api/internal/rag/runtime-manifest?agent_id={uuid}

Returns the published manifest for a given agent, used by the mobile backend to sync configuration.

Sync to mobile backend

POST /api/internal/rag/sync/mobile
{
  "agent_id": "uuid"
}

Triggers a webhook delivery to the mobile NestJS backend with the latest runtime manifest.

Mobile backend API

The NestJS backend exposes these endpoints for the Flutter mobile app:

EndpointMethodDescription
/chat/agentsGETList available agents
/chat/sessionsPOSTCreate a new chat session
/chat/messagePOSTSend a user message
/chat/sessions/{id}/messagesGETGet conversation history
/chat/agents/{id}/sessionsGETList sessions for an agent

WebSocket events (Socket.IO)

EventDirectionDescription
join-conversationClient -> ServerJoin a session room
message-streamingServer -> ClientStreaming text chunk
message-completeServer -> ClientEnd of response
bot-typingServer -> ClientAgent is generating

Webhooks

Configure webhooks in the agent's settings to receive real-time notifications:

  • conversation.created — New conversation started
  • message.received — User message received
  • message.sent — Agent response sent