{
  "openapi": "3.1.0",
  "info": { "title": "BMG Internal Chat API", "version": "1.0.0", "description": "Text-only internal chat API protected by Entra sessions or revocable bearer tokens." },
  "servers": [{ "url": "https://chat.bmgfvn.net" }],
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "bmgc token" },
      "sessionCookie": { "type": "apiKey", "in": "cookie", "name": "bmg_chat_session" }
    },
    "schemas": {
      "MessageInput": { "type": "object", "required": ["text"], "properties": { "text": { "type": "string", "minLength": 1, "maxLength": 4000 } } }
    }
  },
  "paths": {
    "/api/v1/status": { "get": { "summary": "Service and integration status", "responses": { "200": { "description": "OK" } } } },
    "/api/auth/entra/login": { "get": { "summary": "Start Entra authorization-code + PKCE flow", "responses": { "302": { "description": "Redirect to Microsoft" } } } },
    "/api/auth/me": { "get": { "summary": "Current session", "responses": { "200": { "description": "Authentication state" } } } },
    "/api/v1/channels": { "get": { "summary": "List authorized channels", "security": [{ "bearerAuth": [] }, { "sessionCookie": [] }], "responses": { "200": { "description": "Channel list" }, "401": { "description": "Authentication required" } } } },
    "/api/v1/channels/{channelId}/messages": {
      "parameters": [{ "name": "channelId", "in": "path", "required": true, "schema": { "type": "string" } }],
      "get": { "summary": "Read messages", "security": [{ "bearerAuth": [] }, { "sessionCookie": [] }], "responses": { "200": { "description": "Messages" } } },
      "post": { "summary": "Send a text message", "security": [{ "bearerAuth": [] }, { "sessionCookie": [] }], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MessageInput" } } } }, "responses": { "201": { "description": "Created" }, "429": { "description": "Rate limited" } } }
    },
    "/api/v1/tokens": { "get": { "summary": "List API tokens", "security": [{ "sessionCookie": [] }], "responses": { "200": { "description": "Token metadata" } } }, "post": { "summary": "Create an API token", "security": [{ "sessionCookie": [] }], "responses": { "201": { "description": "Raw token shown once" } } } },
    "/api/verified-id/presentation": { "post": { "summary": "Create a Verified ID presentation request", "security": [{ "sessionCookie": [] }], "responses": { "201": { "description": "QR and deep link" } } } }
  }
}
