{
  "info": {
    "name": "EDITHLY API",
    "description": "Complete API collection for EDITHLY — document intelligence platform. Base URL: https://api.edithly.com/api/v1\n\nHow to use:\n1. Set the `api_key` variable in the collection Variables tab\n2. Run 'Create Chatbox' and copy the `session_id` from the response\n3. Set `chatbox_id` variable to that session_id\n4. Upload a file, then start chatting!",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_postman_id": "edithly-api-collection-v1"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.edithly.com/api/v1",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "... your API key here ...",
      "type": "string"
    },
    {
      "key": "chatbox_id",
      "value": "",
      "type": "string",
      "description": "Set this after running 'Create Chatbox' — copy the session_id from the response"
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{api_key}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "01 — Sessions",
      "item": [
        {
          "name": "Create Chatbox",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.session_id) {",
                  "  pm.collectionVariables.set('chatbox_id', json.session_id);",
                  "  console.log('chatbox_id set to:', json.session_id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"session_name\": \"My Research Session\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/external/chatbox/create",
              "host": ["{{base_url}}"],
              "path": ["external", "chatbox", "create"]
            },
            "description": "Creates a new chatbox (session). The `session_id` from the response is automatically saved to the `chatbox_id` collection variable via the test script."
          },
          "response": [
            {
              "name": "200 OK — Session Created",
              "originalRequest": {
                "method": "POST",
                "header": [{ "key": "Content-Type", "value": "application/json" }],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"session_name\": \"My Research Session\"\n}"
                },
                "url": {
                  "raw": "{{base_url}}/external/chatbox/create",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chatbox", "create"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"message\": \"Chatbox created successfully\",\n  \"session_id\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n  \"session_name\": \"My Research Session\",\n  \"created_at\": \"2026-03-07T10:30:00Z\"\n}"
            }
          ]
        },
        {
          "name": "List Chatboxes",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/external/chatbox/list",
              "host": ["{{base_url}}"],
              "path": ["external", "chatbox", "list"]
            },
            "description": "Returns all chatboxes belonging to the authenticated user."
          },
          "response": [
            {
              "name": "200 OK — Chatbox List",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/external/chatbox/list",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chatbox", "list"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"chatboxes\": [\n    {\n      \"id\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n      \"name\": \"My Research Session\",\n      \"description\": \"\",\n      \"created_at\": \"2026-03-07T08:00:00Z\",\n      \"updated_at\": \"2026-03-07T10:30:00Z\",\n      \"chunk_count\": 145\n    }\n  ]\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "02 — Documents",
      "item": [
        {
          "name": "Upload File to Chatbox",
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": [],
                  "description": "Select your PDF, DOCX, or TXT file here. Max 5MB."
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/external/chatbox/{{chatbox_id}}/upload",
              "host": ["{{base_url}}"],
              "path": ["external", "chatbox", "{{chatbox_id}}", "upload"]
            },
            "description": "Upload a document to the specified chatbox. Supported formats: PDF, DOCX, TXT, MD. Maximum file size: 5MB.\n\nNote: Do NOT set Content-Type manually — Postman sets the correct multipart/form-data boundary automatically when using formdata body."
          },
          "response": [
            {
              "name": "200 OK — File Uploaded",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "formdata",
                  "formdata": [{ "key": "file", "type": "file", "src": [] }]
                },
                "url": {
                  "raw": "{{base_url}}/external/chatbox/{{chatbox_id}}/upload",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chatbox", "{{chatbox_id}}", "upload"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"message\": \"File uploaded and processed successfully\",\n  \"file_name\": \"research_paper.pdf\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "03 — Chat",
      "item": [
        {
          "name": "Chat — Streaming (SSE)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Accept",
                "value": "text/event-stream"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatbox_id\": \"{{chatbox_id}}\",\n  \"message\": \"What are the main findings in this document?\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/external/chat/create",
              "host": ["{{base_url}}"],
              "path": ["external", "chat", "create"]
            },
            "description": "Sends a message and streams the AI response via Server-Sent Events (SSE). The response comes as a stream of `data:` lines.\n\nEvent types:\n- `start` — chat initiated\n- `content` — token chunk\n- `references` — source references used\n- `complete` — full response assembled\n\nNote: Postman will show the raw SSE stream in the response body."
          },
          "response": [
            {
              "name": "200 OK — SSE Stream",
              "originalRequest": {
                "method": "POST",
                "header": [
                  { "key": "Content-Type", "value": "application/json" },
                  { "key": "Accept", "value": "text/event-stream" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"chatbox_id\": \"{{chatbox_id}}\",\n  \"message\": \"Summarize this document\"\n}"
                },
                "url": {
                  "raw": "{{base_url}}/external/chat/create",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chat", "create"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "text",
              "header": [
                { "key": "Content-Type", "value": "text/event-stream" },
                { "key": "Cache-Control", "value": "no-cache" },
                { "key": "Connection", "value": "keep-alive" }
              ],
              "body": "data: {\"type\":\"start\",\"chat_id\":\"abc-123\",\"user_message\":\"Summarize this document\"}\n\ndata: {\"type\":\"content\",\"content\":\"This document \"}\n\ndata: {\"type\":\"content\",\"content\":\"covers the key findings...\"}\n\ndata: {\"type\":\"references\",\"references\":[{\"text\":\"Relevant excerpt...\",\"score\":0.89}]}\n\ndata: {\"type\":\"complete\",\"full_response\":\"This document covers the key findings...\"}\n"
            }
          ]
        },
        {
          "name": "Chat — Sync (Non-Streaming)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"chatbox_id\": \"{{chatbox_id}}\",\n  \"message\": \"What are the main findings in this document?\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/external/chat/create/sync",
              "host": ["{{base_url}}"],
              "path": ["external", "chat", "create", "sync"]
            },
            "description": "Same as the streaming endpoint but waits and returns the complete response as a single JSON object. Simpler for testing and server-side usage."
          },
          "response": [
            {
              "name": "200 OK — Full JSON Response",
              "originalRequest": {
                "method": "POST",
                "header": [{ "key": "Content-Type", "value": "application/json" }],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"chatbox_id\": \"{{chatbox_id}}\",\n  \"message\": \"What are the main findings?\"\n}"
                },
                "url": {
                  "raw": "{{base_url}}/external/chat/create/sync",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chat", "create", "sync"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"chat_id\": \"chat-uuid-here\",\n  \"user_message\": \"What are the main findings?\",\n  \"response\": \"The main findings include...\",\n  \"references\": []\n}"
            }
          ]
        },
        {
          "name": "Get Chat History",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/external/chat/{{chatbox_id}}/history?limit=50",
              "host": ["{{base_url}}"],
              "path": ["external", "chat", "{{chatbox_id}}", "history"],
              "query": [
                {
                  "key": "limit",
                  "value": "50",
                  "description": "Max number of messages to return"
                }
              ]
            },
            "description": "Retrieves all previous messages for a chatbox session."
          },
          "response": [
            {
              "name": "200 OK — Chat History",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/external/chat/{{chatbox_id}}/history?limit=50",
                  "host": ["{{base_url}}"],
                  "path": ["external", "chat", "{{chatbox_id}}", "history"],
                  "query": [{ "key": "limit", "value": "50" }]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"chatbox_id\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n  \"chatbox_name\": \"My Research Session\",\n  \"messages\": [\n    {\n      \"id\": \"msg_001\",\n      \"message\": \"What is this document about?\",\n      \"timestamp\": \"2026-03-07T10:00:00Z\",\n      \"response\": \"This document discusses...\"\n    }\n  ],\n  \"total_messages\": 1\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "04 — Analysis",
      "item": [
        {
          "name": "Analyze Document",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/external/analyze/{{chatbox_id}}",
              "host": ["{{base_url}}"],
              "path": ["external", "analyze", "{{chatbox_id}}"]
            },
            "description": "Runs a full AI analysis on the uploaded document. Returns:\n- Executive summary\n- Key topics and themes\n- Sentiment (positive / neutral / negative)\n- Named entities (people, orgs, technologies)\n- AI-generated insights\n- Token usage stats"
          },
          "response": [
            {
              "name": "200 OK — Analysis Result",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "{{base_url}}/external/analyze/{{chatbox_id}}",
                  "host": ["{{base_url}}"],
                  "path": ["external", "analyze", "{{chatbox_id}}"]
                }
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "body": "{\n  \"message\": \"Analysis completed successfully\",\n  \"session_id\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n  \"analysis_result\": {\n    \"summary\": \"This document outlines a robust API structure for chatbot interactions with modern async Python patterns.\",\n    \"key_topics\": [\"AI Development\", \"MCP Architecture\", \"API Design\"],\n    \"sentiment\": \"neutral\",\n    \"entities\": [\"FastAPI\", \"Python\", \"MongoDB\", \"S3\"],\n    \"insights\": [\n      \"The document outlines a robust API structure for chatbot interactions\",\n      \"Implementation uses modern async Python patterns\",\n      \"Integration with cloud storage and vector search capabilities\"\n    ]\n  },\n  \"token_usage\": {\n    \"prompt_tokens\": 2450,\n    \"completion_tokens\": 380,\n    \"total_tokens\": 2830\n  }\n}"
            }
          ]
        }
      ]
    }
  ]
}