Skip to content
MedTrack AI
MedTrack AI

Personal Health Record

Back to App
Developers & API

Developer Documentation

API Reference and Integration Guide

Overview

MedTrack AI provides a REST API for managing medical reports, extracting biomarkers, and tracking health metrics. All API endpoints require authentication via Supabase session cookies (set during Google OAuth sign-in).

Authentication

  1. Initiate Google OAuth: GET /api/auth/google → returns { url } to redirect the user
  2. Callback: GET /api/auth/callback?code=... → exchanges code for session, sets cookies
  3. Check session: GET /api/auth/session → returns current user, subscription status, free tier remaining
  4. Sign out: POST /api/auth/signout → clears session cookies

API Endpoints Reference

MethodEndpointDescriptionAuth
GET/api/auth/googleStart Google OAuth flowNo
GET/api/auth/callbackOAuth callback (exchanges code for session)No
GET/api/auth/sessionGet current user & subscription statusNo
POST/api/auth/signoutSign out and clear cookiesNo
GET/api/reportsList all user reportsYes
POST/api/reportsUpload medical report (multipart/form-data)Yes
GET/api/reports/:idGet report detail with metricsYes
DELETE/api/reports/:idDelete a report and its metricsYes
POST/api/reports/:id/process-pageProcess a single page (base64 data)Yes
POST/api/reports/:id/finalizeFinalize multi-page report analysisYes
POST/api/reports/:id/retryRetry failed analysisYes
GET/api/metricsGet all biomarker groups with trendsYes
GET/api/metrics?name=XGet single metric historyYes
GET/api/files/:filenameDownload uploaded fileYes
POST/api/checkout/create-orderCreate Razorpay payment orderYes
POST/api/checkout/verifyVerify payment signatureYes

Rate Limits

  • Upload: 10 requests per 5 minutes per user
  • AI Analysis: 20 requests per 24 hours per user
  • Auth: 5 signup attempts per hour per IP

All rate-limited responses return HTTP 429 with a Retry-After header and RFC RateLimit-* headers.

Response Format

All API responses return JSON. Successful responses include the requested data. Error responses follow this structure:

{
  "error": "Human-readable message",
  "code": "MACHINE_READABLE_CODE"
}

HTTP status codes used: 200 (success), 400 (bad request), 401 (not authenticated), 402 (subscription required), 404 (not found), 413 (payload too large), 415 (unsupported media type), 429 (rate limited), 500 (server error)

Machine-Readable API Specification

A complete OpenAPI 3.1 specification is available at /openapi.json. This spec includes typed schemas for all request/response bodies and is compatible with LLM function-calling formats.

Agent Instructions

See /llms.txt for guidance on when and how AI agents should interact with MedTrack AI.