{
  "openapi": "3.0.3",
  "info": {
    "title": "Health API (Beta)",
    "version": "3.0",
    "contact": {
      "email": "admin@vsee.com"
    },
    "description": "Health data and device management API"
  },
  "servers": [
    {
      "url": "https://api.vseepreview.com/api_v3",
      "description": "Staging"
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": false,
    "samples-languages": [
      "curl",
      "python",
      "javascript",
      "java"
    ]
  },
  "tags": [
    {
      "name": "Devices",
      "description": "Device management"
    },
    {
      "name": "Health Data",
      "description": "Health data submission and retrieval"
    }
  ],
  "paths": {
    "/users/{user_id}/devices": {
      "post": {
        "tags": [
          "Devices"
        ],
        "summary": "Register device",
        "description": "Register a health monitoring device for a user",
        "operationId": "registerDevice",
        "parameters": [
          {
            "name": "X-ApiToken",
            "in": "header",
            "description": "API token",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "your_api_token"
          },
          {
            "name": "X-ApiKey",
            "in": "header",
            "description": "API Key",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "your_api_key"
          },
          {
            "name": "X-AccountCode",
            "in": "header",
            "description": "Account code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "vclinic"
          },
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "User ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceRegistration"
              },
              "examples": {
                "thermometer": {
                  "value": {
                    "device_id": "004D320DCAA2",
                    "device_name": "Thermometer PT3SBT",
                    "type": "ihealth_thermometer_pt3sbt"
                  }
                },
                "pulseOximeter": {
                  "value": {
                    "device_id": "PO3-12345",
                    "device_name": "Pulse Oximeter PO3",
                    "type": "ihealth_po_po3"
                  }
                },
                "bloodPressure": {
                  "value": {
                    "device_id": "BP-100-001",
                    "device_name": "Blood Pressure RPM-BP100",
                    "type": "welchallync_bp_bp100"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Device registered successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Device"
                    }
                  }
                }
              }
            }
          }
        },
        "x-auth-type": "user-token"
      }
    },
    "/health": {
      "post": {
        "tags": [
          "Health Data"
        ],
        "summary": "Submit health data",
        "description": "Submit health measurement data from a registered device",
        "operationId": "submitHealthData",
        "parameters": [
          {
            "name": "X-ApiToken",
            "in": "header",
            "description": "API token",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "your_api_token"
          },
          {
            "name": "X-ApiKey",
            "in": "header",
            "description": "API Key",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "your_api_key"
          },
          {
            "name": "X-AccountCode",
            "in": "header",
            "description": "Account code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "vclinic"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HealthDataSubmission"
              },
              "examples": {
                "temperature": {
                  "value": {
                    "type": "ihealth_thermometer_pt3sbt",
                    "date": "2021-08-25",
                    "time": 1695626540,
                    "device_id": "004D320DCAA2",
                    "data_type": "temperature_body",
                    "data_class": "body",
                    "temperature_body": "36.76",
                    "temperature_unit": "cel"
                  }
                },
                "bloodGlucose": {
                  "value": {
                    "type": "ihealth_bg_bg5s",
                    "date": "2021-08-25",
                    "time": 1695626540,
                    "device_id": "BG5S-12345",
                    "data_type": "bg",
                    "data_class": "body",
                    "bg": 100,
                    "bg_unit": "mg/dL"
                  }
                },
                "bloodPressure": {
                  "value": {
                    "type": "welchallync_bp_bp100",
                    "date": "2021-08-25",
                    "time": 1695626540,
                    "device_id": "BP-100-001",
                    "data_type": "bp",
                    "data_class": "body",
                    "hp": 120,
                    "lp": 80,
                    "bp_unit": "mmHg"
                  }
                },
                "weight": {
                  "value": {
                    "type": "ihealth_scale_hs2",
                    "date": "2021-08-25",
                    "time": 1695626540,
                    "device_id": "SCALE-001",
                    "data_type": "weight",
                    "data_class": "body",
                    "weight": 170,
                    "weight_unit": "lbs"
                  }
                },
                "activity": {
                  "value": {
                    "type": "applehealth",
                    "date": "2021-08-25",
                    "time": 1695626540,
                    "device_id": "DEVICE-001",
                    "data_type": "active_minutes",
                    "data_class": "body",
                    "active_minutes": 30,
                    "steps": 5000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Health data submitted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "x-auth-type": "user-token"
      }
    }
  },
  "components": {
    "schemas": {
      "Device": {
        "type": "object",
        "properties": {
          "device_id": {
            "type": "string"
          },
          "device_name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          },
          "created_at": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "DeviceRegistration": {
        "type": "object",
        "required": [
          "device_id",
          "device_name",
          "type"
        ],
        "properties": {
          "device_id": {
            "type": "string",
            "description": "Device unique identifier"
          },
          "device_name": {
            "type": "string",
            "description": "Human-readable device name"
          },
          "type": {
            "type": "string",
            "description": "Device type code",
            "enum": [
              "ihealth_po_po3",
              "ihealth_scale_hs2",
              "applehealth",
              "samsunghealth",
              "welchallync_bp_bp100",
              "ihealth_bg_bg5s",
              "ihealth_thermometer_pt3sbt"
            ]
          }
        }
      },
      "HealthDataSubmission": {
        "type": "object",
        "required": [
          "type",
          "date",
          "time",
          "device_id",
          "data_type",
          "data_class"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "Device type"
          },
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date in YYYY-MM-DD format"
          },
          "time": {
            "type": "integer",
            "format": "int64",
            "description": "UNIX timestamp"
          },
          "device_id": {
            "type": "string",
            "description": "Device unique identifier"
          },
          "data_type": {
            "type": "string",
            "description": "Type of measurement",
            "enum": [
              "temperature_body",
              "bg",
              "bp",
              "weight",
              "active_minutes",
              "steps",
              "hr",
              "bo",
              "illuminance",
              "humidity",
              "gas",
              "movement",
              "noise",
              "range"
            ]
          },
          "data_class": {
            "type": "string",
            "description": "Data classification",
            "enum": [
              "body",
              "environment"
            ]
          },
          "temperature_body": {
            "type": "string",
            "description": "Body temperature value"
          },
          "temperature_unit": {
            "type": "string",
            "description": "Temperature unit",
            "enum": [
              "cel",
              "fah"
            ]
          },
          "bg": {
            "type": "number",
            "description": "Blood glucose value"
          },
          "bg_unit": {
            "type": "string",
            "description": "Blood glucose unit",
            "enum": [
              "mg/dL",
              "mmol/L"
            ]
          },
          "hp": {
            "type": "integer",
            "description": "Systolic blood pressure (high pressure)"
          },
          "lp": {
            "type": "integer",
            "description": "Diastolic blood pressure (low pressure)"
          },
          "bp_unit": {
            "type": "string",
            "description": "Blood pressure unit",
            "enum": [
              "mmHg",
              "kPa"
            ]
          },
          "weight": {
            "type": "number",
            "description": "Weight value"
          },
          "weight_unit": {
            "type": "string",
            "description": "Weight unit",
            "enum": [
              "lbs",
              "kg"
            ]
          },
          "active_minutes": {
            "type": "integer",
            "description": "Active minutes"
          },
          "steps": {
            "type": "integer",
            "description": "Step count"
          },
          "hr": {
            "type": "number",
            "description": "Heart rate"
          },
          "bo": {
            "type": "number",
            "description": "Blood oxygen"
          },
          "illuminance": {
            "type": "number",
            "description": "Illuminance value"
          },
          "illuminance_unit": {
            "type": "string",
            "description": "Illuminance unit",
            "enum": [
              "lux"
            ]
          },
          "humidity": {
            "type": "number",
            "description": "Humidity value"
          },
          "humidity_unit": {
            "type": "string",
            "description": "Humidity unit",
            "enum": [
              "percentage"
            ]
          },
          "gas": {
            "type": "string",
            "description": "Gas value"
          },
          "movement": {
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "type": "integer"
              }
            ],
            "description": "Movement value"
          },
          "noise": {
            "type": "number",
            "description": "Noise level"
          },
          "noise_unit": {
            "type": "string"
          },
          "range": {
            "type": "number",
            "description": "Range in cm"
          },
          "range_unit": {
            "type": "string",
            "description": "Range unit",
            "enum": [
              "cm"
            ]
          }
        }
      }
    }
  }
}