{
  "openapi": "3.1.0",
  "info": {
    "title": "MasteryHive Reconciliation \u2014 Loader (mostly platform)",
    "version": "0.1.0",
    "description": "Pipeline status may be useful; many routes are platform mesh. Local servers only."
  },
  "servers": [
    {
      "url": "http://localhost:8000/v1",
      "description": "Local mesh placeholder \u2014 replace host; keep /v1 prefix. Cloud bases require owner decision."
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Home",
        "operationId": "home__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health",
        "operationId": "health_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/loader/matches": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Store matched pairs to backend",
        "operationId": "store_matches_loader_matches_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MatchesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/software-records": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Publish GL + bank records to Pub/Sub",
        "operationId": "publish_software_records_loader_software_records_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SoftwareRecordsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/publish-matches": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Publish matched + unmatched records to Pub/Sub",
        "operationId": "publish_matches_loader_publish_matches_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublishMatchesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/update/{session_id}": {
      "patch": {
        "tags": [
          "Loader"
        ],
        "summary": "Update reconciliation session metadata on backend",
        "operationId": "update_reconciliation_loader_update__session_id__patch",
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Session Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/task": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Update task status on backend",
        "operationId": "create_task_loader_task_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/pipeline-status/{session_id}": {
      "get": {
        "tags": [
          "Loader"
        ],
        "summary": "Get full pipeline status for a session across all services",
        "operationId": "pipeline_status_loader_pipeline_status__session_id__get",
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Session Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/pipeline-status": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Record a pipeline status event (called by any service)",
        "operationId": "record_pipeline_status_loader_pipeline_status_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PipelineStatusRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/cancel/{session_id}/": {
      "post": {
        "tags": [
          "Loader"
        ],
        "summary": "Signal cancellation of a running reconciliation pipeline",
        "operationId": "cancel_reconciliation_loader_cancel__session_id___post",
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Session Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelReconciliationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/loader/health/redis": {
      "get": {
        "tags": [
          "Loader"
        ],
        "summary": "Test redis connectivity",
        "operationId": "test_redis_loader_health_redis_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CancelReconciliationRequest": {
        "properties": {
          "partner_id": {
            "type": "string",
            "title": "Partner Id"
          },
          "tenant_id": {
            "type": "string",
            "title": "Tenant Id"
          },
          "branch_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branch Id"
          },
          "ingress_task_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ingress Task Id"
          },
          "gl_reversal_task_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gl Reversal Task Id"
          },
          "reconciliation_task_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reconciliation Task Id"
          },
          "summary_task_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Summary Task Id"
          }
        },
        "type": "object",
        "required": [
          "partner_id",
          "tenant_id"
        ],
        "title": "CancelReconciliationRequest"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "MatchesRequest": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id"
          },
          "partner_id": {
            "type": "string",
            "title": "Partner Id"
          },
          "reconciliation_data": {
            "additionalProperties": true,
            "type": "object",
            "title": "Reconciliation Data"
          },
          "batch_size": {
            "type": "integer",
            "title": "Batch Size",
            "default": 100
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "partner_id",
          "reconciliation_data"
        ],
        "title": "MatchesRequest"
      },
      "PipelineStatusRequest": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id"
          },
          "service": {
            "type": "string",
            "title": "Service"
          },
          "stage": {
            "type": "string",
            "title": "Stage"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "partner_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Partner Id"
          },
          "tenant_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tenant Id"
          },
          "error_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error Message"
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata"
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "service",
          "stage",
          "status"
        ],
        "title": "PipelineStatusRequest"
      },
      "PublishMatchesRequest": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id"
          },
          "reconciliation_data": {
            "additionalProperties": true,
            "type": "object",
            "title": "Reconciliation Data"
          },
          "unmatched_gl": {
            "items": {},
            "type": "array",
            "title": "Unmatched Gl",
            "default": []
          },
          "unmatched_bank": {
            "items": {},
            "type": "array",
            "title": "Unmatched Bank",
            "default": []
          },
          "msc_rate": {
            "type": "number",
            "title": "Msc Rate",
            "default": 0.0
          },
          "commercial": {
            "type": "boolean",
            "title": "Commercial",
            "default": false
          },
          "bulk_chargebacks": {
            "anyOf": [
              {
                "items": {},
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Bulk Chargebacks"
          },
          "is_last_batch": {
            "type": "boolean",
            "title": "Is Last Batch",
            "default": true
          },
          "recon_type": {
            "type": "string",
            "title": "Recon Type",
            "default": "bank"
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "reconciliation_data"
        ],
        "title": "PublishMatchesRequest"
      },
      "SoftwareRecordsRequest": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id"
          },
          "bank_statements": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Bank Statements"
          },
          "gl_transactions": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Gl Transactions"
          },
          "recon_type": {
            "type": "string",
            "title": "Recon Type",
            "default": "bank"
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "bank_statements",
          "gl_transactions"
        ],
        "title": "SoftwareRecordsRequest"
      },
      "TaskError": {
        "properties": {
          "error": {
            "type": "string",
            "title": "Error"
          },
          "code": {
            "type": "integer",
            "title": "Code"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "details": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Details",
            "default": {}
          }
        },
        "type": "object",
        "required": [
          "error",
          "code",
          "message"
        ],
        "title": "TaskError"
      },
      "TaskRequest": {
        "properties": {
          "task_id": {
            "type": "string",
            "title": "Task Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TaskError"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "task_id",
          "status"
        ],
        "title": "TaskRequest"
      },
      "UpdateRequest": {
        "properties": {
          "ai_summary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Summary"
          },
          "msc_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Msc Rate"
          },
          "gl_opening_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gl Opening Balance"
          },
          "gl_closing_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gl Closing Balance"
          },
          "statement_opening_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Opening Balance"
          },
          "statement_closing_balance": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Closing Balance"
          },
          "gl_account_number": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gl Account Number"
          },
          "statement_account_number": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Statement Account Number"
          },
          "is_scheduled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Scheduled"
          },
          "partner_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Partner Id"
          },
          "period_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start Date"
          },
          "period_end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End Date"
          },
          "ai_statistics": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Statistics"
          }
        },
        "type": "object",
        "title": "UpdateRequest"
      },
      "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"
      }
    }
  }
}
