Skip to main content

Welcome to the MedMitra API

The MedMitra API is a RESTful service that powers the MedMitra medical case management platform. It provides endpoints for managing patient cases, uploading medical documents, and accessing AI-powered insights for diagnosis support.

Base URL

The API is built with FastAPI and runs on:
http://localhost:8000
For production deployments, replace with your production domain.

API Version

Current version: 1.0.0 The API version follows semantic versioning. Breaking changes will result in a major version bump.

API Architecture

Technology Stack

  • Framework: FastAPI (Python)
  • Database: Supabase (PostgreSQL)
  • Storage: Supabase Storage for file uploads
  • Authentication: Supabase Auth with JWT tokens
  • AI Processing: Background task processing with async workers

Core Capabilities

The MedMitra API enables you to:
  • Case Management: Create, retrieve, update, and delete patient cases
  • Document Processing: Upload and manage lab reports and radiology images
  • AI Insights: Access automated case summaries, SOAP notes, and diagnostic suggestions
  • File Management: Handle multi-file uploads with categorization
  • Background Processing: AI analysis runs asynchronously after case creation

Request Format

Content Types

The API accepts different content types depending on the endpoint:
  • JSON: application/json for most GET requests and data queries
  • Form Data: multipart/form-data for file uploads and case creation
  • URL Parameters: Query parameters for filtering and pagination

Headers

All authenticated requests require:
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
For file uploads:
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: multipart/form-data

Response Format

Success Responses

Successful responses return JSON with appropriate HTTP status codes:
{
  "message": "Case created successfully",
  "case": {
    "case_id": "123e4567-e89b-12d3-a456-426614174000",
    "patient_name": "John Doe",
    "patient_age": 45,
    "status": "processing",
    "created_at": "2026-03-04T10:30:00Z"
  }
}

Error Responses

Error responses include detailed error messages:
{
  "detail": "Case with ID abc123 not found"
}

Status Codes

The API uses standard HTTP status codes:
CodeDescription
200Success - Request completed successfully
201Created - Resource created successfully
400Bad Request - Invalid parameters or request body
401Unauthorized - Missing or invalid authentication
404Not Found - Resource does not exist
500Internal Server Error - Server-side error

API Features

Background Processing

When you create a case with files, the API:
  1. Immediately creates the case record (returns 201)
  2. Uploads files to storage
  3. Starts AI processing in the background
  4. Updates the case with insights when analysis completes
This allows fast API responses while computationally expensive AI analysis runs asynchronously.

File Categories

Uploaded files are categorized as:
  • lab: Laboratory reports, blood tests, pathology results
  • radiology: X-rays, CT scans, MRI images, ultrasounds
This categorization helps the AI agents process documents appropriately.

Case Status Flow

processing → completed (or failed)
  • processing: Case is created, AI analysis is running
  • completed: Analysis finished successfully
  • failed: Analysis encountered an error

Rate Limits

Currently, the API does not enforce rate limits. However, for production deployments, consider implementing:
  • Per-user rate limiting
  • File size restrictions
  • Concurrent request limits

API Playground

Test API endpoints using:
  • FastAPI Docs: Available at http://localhost:8000/docs (Swagger UI)
  • ReDoc: Available at http://localhost:8000/redoc (alternative documentation)
These interactive docs allow you to test endpoints directly from your browser.

Getting Started

To start using the MedMitra API:
  1. Set up authentication - See the Authentication guide
  2. Create your first case - Use the Create Case endpoint
  3. Retrieve AI insights - Query the Get Case by ID endpoint

Need Help?

For support and questions:
  • Check the endpoint documentation for detailed examples
  • Review error messages in responses
  • Consult the GitHub repository for code examples

Build docs developers (and LLMs) love