{
  "openapi": "3.1.0",
  "info": {
    "title": "HeimerClean OEM Stock and Tracking Cloud API",
    "version": "1.1.0-pilot",
    "description": "Current-stock-device telemetry and platform/current-partner reads; no customer identity. Samples are pending review, never automatic training."
  },
  "paths": {
    "/license/oem-stock/telemetry": {
      "post": {
        "tags": [
          "oem-stock"
        ],
        "summary": "Ingest Telemetry",
        "operationId": "ingest_telemetry_license_oem_stock_telemetry_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Batch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/license/oem-stock/activate": {
      "post": {
        "tags": [
          "oem-stock"
        ],
        "summary": "Activate",
        "operationId": "activate_license_oem_stock_activate_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolActivate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/license/oem-stock/validate": {
      "post": {
        "tags": [
          "oem-stock"
        ],
        "summary": "Validate",
        "operationId": "validate_license_oem_stock_validate_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeaseValidate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/admin/oem-stock/tracking": {
      "get": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Admin Tracking",
        "operationId": "admin_tracking_web_admin_oem_stock_tracking_get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[a-f0-9]{16}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Pool Id"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 90,
              "minimum": 1,
              "default": 30,
              "title": "Days"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 5000,
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/channel/oem-stock/tracking": {
      "get": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Partner Tracking",
        "operationId": "partner_tracking_web_channel_oem_stock_tracking_get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[a-f0-9]{16}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Pool Id"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 90,
              "minimum": 1,
              "default": 30,
              "title": "Days"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 5000,
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/admin/oem-stock/pools/{pool_id}/telemetry-policy": {
      "patch": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Telemetry Policy",
        "operationId": "telemetry_policy_web_admin_oem_stock_pools__pool_id__telemetry_policy_patch",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{16}$",
              "title": "Pool Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TelemetryPolicy"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/admin/oem-stock/pools": {
      "get": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Inventory",
        "operationId": "inventory_web_admin_oem_stock_pools_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Create",
        "operationId": "create_web_admin_oem_stock_pools_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/web/channel/oem-stock/pools": {
      "get": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Partner Inventory",
        "operationId": "partner_inventory_web_channel_oem_stock_pools_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/web/admin/oem-stock/pools/{pool_id}/credits": {
      "post": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Credit",
        "operationId": "credit_web_admin_oem_stock_pools__pool_id__credits_post",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{16}$",
              "title": "Pool Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolCredit"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/admin/oem-stock/pools/{pool_id}": {
      "patch": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Status",
        "operationId": "status_web_admin_oem_stock_pools__pool_id__patch",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{16}$",
              "title": "Pool Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolStatus"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/web/admin/oem-stock/pools/{pool_id}/rotate-token": {
      "post": {
        "tags": [
          "oem-stock-operator"
        ],
        "summary": "Rotate",
        "operationId": "rotate_web_admin_oem_stock_pools__pool_id__rotate_token_post",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{16}$",
              "title": "Pool Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AiOutcome": {
        "properties": {
          "consent": {
            "type": "boolean",
            "title": "Consent"
          },
          "action": {
            "type": "string",
            "enum": [
              "temp_clear",
              "mem_clear",
              "noop",
              "daily_optimization"
            ],
            "title": "Action"
          },
          "model_version": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.-]{1,64}$",
            "title": "Model Version"
          },
          "before": {
            "$ref": "#/components/schemas/Observation"
          },
          "after": {
            "$ref": "#/components/schemas/Observation"
          },
          "elapsed_seconds": {
            "type": "number",
            "maximum": 3600.0,
            "exclusiveMinimum": 0.0,
            "title": "Elapsed Seconds"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "consent",
          "action",
          "model_version",
          "before",
          "after",
          "elapsed_seconds"
        ],
        "title": "AiOutcome"
      },
      "Batch": {
        "properties": {
          "partner_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{1,63}$",
            "title": "Partner Id"
          },
          "protocol_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Protocol Id"
          },
          "cpu_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Cpu Id"
          },
          "mac_address": {
            "type": "string",
            "pattern": "^(?:[A-Fa-f0-9]{2}[:-]?){5}[A-Fa-f0-9]{2}$",
            "title": "Mac Address"
          },
          "device_fingerprint": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "title": "Device Fingerprint"
          },
          "license_key": {
            "type": "string",
            "maxLength": 63,
            "minLength": 63,
            "format": "password",
            "title": "License Key",
            "writeOnly": true
          },
          "events": {
            "items": {
              "$ref": "#/components/schemas/Event"
            },
            "type": "array",
            "maxItems": 50,
            "minItems": 1,
            "title": "Events"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "partner_id",
          "protocol_id",
          "cpu_id",
          "mac_address",
          "device_fingerprint",
          "license_key",
          "events"
        ],
        "title": "Batch"
      },
      "Event": {
        "properties": {
          "event_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$",
            "title": "Event Id"
          },
          "kind": {
            "type": "string",
            "enum": [
              "heartbeat",
              "job.outcome",
              "ai.outcome"
            ],
            "title": "Kind"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "title": "Occurred At"
          },
          "engine_version": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.-]{1,32}$",
            "title": "Engine Version"
          },
          "job_id": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[a-f0-9]{32}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Job Id"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "temp.scan",
                  "optimize"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Operation"
          },
          "state": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "succeeded",
                  "failed",
                  "cancelled"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "State"
          },
          "error_code": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^HC_[A-Z0-9_]{1,64}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error Code"
          },
          "metrics": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Metrics"
              },
              {
                "type": "null"
              }
            ]
          },
          "ai_sample": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AiOutcome"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "event_id",
          "kind",
          "occurred_at",
          "engine_version"
        ],
        "title": "Event"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "LeaseValidate": {
        "properties": {
          "partner_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{1,63}$",
            "title": "Partner Id"
          },
          "protocol_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Protocol Id"
          },
          "cpu_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Cpu Id"
          },
          "mac_address": {
            "type": "string",
            "pattern": "^(?:[A-Fa-f0-9]{2}[:-]?){5}[A-Fa-f0-9]{2}$",
            "title": "Mac Address"
          },
          "device_fingerprint": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "title": "Device Fingerprint"
          },
          "license_key": {
            "type": "string",
            "maxLength": 63,
            "minLength": 63,
            "format": "password",
            "title": "License Key",
            "writeOnly": true
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "partner_id",
          "protocol_id",
          "cpu_id",
          "mac_address",
          "device_fingerprint",
          "license_key"
        ],
        "title": "LeaseValidate"
      },
      "Metrics": {
        "properties": {
          "cleaned_junk_gb": {
            "type": "number",
            "maximum": 100000.0,
            "minimum": 0.0,
            "title": "Cleaned Junk Gb",
            "default": 0
          },
          "memory_freed_gb": {
            "type": "number",
            "maximum": 10000.0,
            "minimum": 0.0,
            "title": "Memory Freed Gb",
            "default": 0
          },
          "deleted_files": {
            "type": "integer",
            "maximum": 100000000.0,
            "minimum": 0.0,
            "title": "Deleted Files",
            "default": 0
          },
          "daily_optimization_score": {
            "type": "number",
            "maximum": 100.0,
            "minimum": 0.0,
            "title": "Daily Optimization Score",
            "default": 0
          },
          "energy_saved_kwh": {
            "type": "number",
            "maximum": 1000.0,
            "minimum": 0.0,
            "title": "Energy Saved Kwh",
            "default": 0
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "Metrics"
      },
      "Observation": {
        "properties": {
          "cpu_percent": {
            "type": "number",
            "maximum": 100.0,
            "minimum": 0.0,
            "title": "Cpu Percent"
          },
          "memory_percent": {
            "type": "number",
            "maximum": 100.0,
            "minimum": 0.0,
            "title": "Memory Percent"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "cpu_percent",
          "memory_percent"
        ],
        "title": "Observation"
      },
      "PoolActivate": {
        "properties": {
          "partner_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{1,63}$",
            "title": "Partner Id"
          },
          "protocol_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Protocol Id"
          },
          "cpu_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Cpu Id"
          },
          "mac_address": {
            "type": "string",
            "pattern": "^(?:[A-Fa-f0-9]{2}[:-]?){5}[A-Fa-f0-9]{2}$",
            "title": "Mac Address"
          },
          "device_fingerprint": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "title": "Device Fingerprint"
          },
          "pool_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{16}$",
            "title": "Pool Id"
          },
          "activation_token": {
            "type": "string",
            "maxLength": 128,
            "minLength": 32,
            "format": "password",
            "title": "Activation Token",
            "writeOnly": true
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "partner_id",
          "protocol_id",
          "cpu_id",
          "mac_address",
          "device_fingerprint",
          "pool_id",
          "activation_token"
        ],
        "title": "PoolActivate"
      },
      "PoolCreate": {
        "properties": {
          "source_channel_node_id": {
            "type": "integer",
            "minimum": 1.0,
            "title": "Source Channel Node Id"
          },
          "request_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{8,64}$",
            "title": "Request Id"
          },
          "partner_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{1,63}$",
            "title": "Partner Id"
          },
          "protocol_id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "title": "Protocol Id"
          },
          "count": {
            "type": "integer",
            "maximum": 5000.0,
            "minimum": 1.0,
            "title": "Count"
          },
          "duration_days": {
            "type": "integer",
            "maximum": 3650.0,
            "minimum": 1.0,
            "title": "Duration Days",
            "default": 365
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "source_channel_node_id",
          "request_id",
          "partner_id",
          "protocol_id",
          "count"
        ],
        "title": "PoolCreate"
      },
      "PoolCredit": {
        "properties": {
          "request_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{8,64}$",
            "title": "Request Id"
          },
          "count": {
            "type": "integer",
            "maximum": 5000.0,
            "minimum": 1.0,
            "title": "Count"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "request_id",
          "count"
        ],
        "title": "PoolCredit"
      },
      "PoolStatus": {
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused",
              "revoked"
            ],
            "title": "Status"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "status"
        ],
        "title": "PoolStatus"
      },
      "TelemetryPolicy": {
        "properties": {
          "ai_training_enabled": {
            "type": "boolean",
            "title": "Ai Training Enabled"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "ai_training_enabled"
        ],
        "title": "TelemetryPolicy"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
