{"openapi":"3.1.0","info":{"title":"MonGPT API","version":"1.0.0","description":"Public REST API for MonGPT — AI support agents with chat + voice in the languages Asia speaks. Authenticate with a scoped API token (create one in Dashboard → API): `Authorization: Bearer mgpt_…`. API access requires the Growth plan or higher."},"servers":[{"url":"https://mongpt-api.mongpt.workers.dev/v1"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API token from Dashboard → API (mgpt_…)"}},"schemas":{"Bot":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"language":{"type":"string","example":"en-IN"},"created_at":{"type":"string","format":"date-time"}}},"KBDocument":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"source_url":{"type":"string","nullable":true},"source_type":{"type":"string","enum":["url","file","qa","snippet"]},"status":{"type":"string","enum":["queued","processing","ready","failed"]},"chunk_count":{"type":"integer"},"chatbot_id":{"type":"string","format":"uuid","nullable":true},"created_at":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"}}}}},"paths":{"/bots":{"get":{"summary":"List bots","description":"Requires scope `bots:read`.","security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Bot list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Bot"}}}}}}}}},"post":{"summary":"Create a bot","description":"Requires scope `bots:write`. Subject to your plan’s bot limit.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","maxLength":100},"language":{"type":"string","example":"en-IN"}}}}}},"responses":{"201":{"description":"Created bot"},"402":{"description":"Plan bot limit reached"}}}},"/kb":{"get":{"summary":"List knowledge-base documents","description":"Requires scope `kb:read`. Filter with `?chatbotId=`.","security":[{"bearerAuth":[]}],"parameters":[{"name":"chatbotId","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Document list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/KBDocument"}}}}}}}}}},"/kb/ingest":{"post":{"summary":"Add knowledge (URL or raw text)","description":"Requires scope `kb:write`. Queued for crawling/embedding; poll GET /kb for status.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["title"],"properties":{"title":{"type":"string"},"url":{"type":"string","format":"uri"},"text":{"type":"string"},"chatbotId":{"type":"string","format":"uuid"}}}}}},"responses":{"202":{"description":"Queued","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"}}}}}}}}}}},"/chat":{"post":{"summary":"Chat with a bot (streaming)","description":"Requires scope `chat:invoke`. Returns a Server-Sent Events stream of OpenAI-style chunks (`data: {\"choices\":[{\"delta\":{\"content\":\"…\"}}]}`). Counts toward your monthly message quota.","security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string","maxLength":2000},"chatbotId":{"type":"string","format":"uuid"},"sessionId":{"type":"string","description":"Stable id groups turns into one conversation"},"language":{"type":"string","example":"hi-IN"}}}}}},"responses":{"200":{"description":"SSE stream","content":{"text/event-stream":{}}}}}},"/conversations":{"get":{"summary":"List conversations","description":"Requires scope `conversations:read`. Supports `?q=` search, `?limit=`, `?chatbotId=`.","security":[{"bearerAuth":[]}],"parameters":[{"name":"q","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","maximum":200}},{"name":"chatbotId","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Session list"}}}},"/conversations/{sessionId}":{"get":{"summary":"Get a conversation transcript","security":[{"bearerAuth":[]}],"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Messages in the session"}}}},"/analytics":{"get":{"summary":"Analytics summary (30 days)","description":"Requires scope `analytics:read`. Daily volumes, top questions, unanswered rate, feedback, sessions.","security":[{"bearerAuth":[]}],"parameters":[{"name":"chatbotId","in":"query","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Analytics summary"}}}}}}