{
  "openapi": "3.0.3",
  "info": {
    "title": "HYBX OMNL API",
    "description": "HYBX OMNL endpoints on the token-aggregation service (Chain 138 / ALL Mainnet 651940, IPSAS, Fineract alignment). Optional auth: when `OMNL_API_KEY` is set, use `Authorization: Bearer <key>` or query `access_token`.",
    "version": "1.2.0"
  },
  "servers": [{ "url": "/api/v1", "description": "Token aggregation v1" }],
  "tags": [
    { "name": "omnl-discovery", "description": "Catalog and probes" },
    { "name": "omnl-chain", "description": "On-chain compliance and instruments" },
    { "name": "omnl-ipsas", "description": "IPSAS GL and Fineract" }
  ],
  "paths": {
    "/omnl/openapi.json": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "OpenAPI 3 document (this file)",
        "operationId": "getOmnlOpenApi",
        "responses": { "200": { "description": "OpenAPI 3 JSON" } }
      }
    },
    "/omnl/catalog": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "Human/agent catalog of OMNL routes",
        "operationId": "getOmnlCatalog",
        "responses": { "200": { "description": "Catalog object" } }
      }
    },
    "/omnl/integration-status": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "Which env-backed integrations are configured",
        "operationId": "getOmnlIntegrationStatus",
        "responses": { "200": { "description": "Status flags" } }
      }
    },
    "/omnl/reconcile-anchor": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "SHA-256 anchor for IPSAS registry + journal matrix files",
        "operationId": "getOmnlReconcileAnchor",
        "responses": { "200": { "description": "Anchor payload" }, "503": { "description": "Config files missing" } }
      }
    },
    "/omnl/cross-chain-lines": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "hybx-omnl-cross-chain-lines.json",
        "operationId": "getOmnlCrossChainLines",
        "responses": { "200": { "description": "lines + configPath" } }
      }
    },
    "/omnl/zk-verifier": {
      "get": {
        "tags": ["omnl-discovery"],
        "summary": "ZK verifier address from env",
        "operationId": "getOmnlZkVerifier",
        "responses": { "200": { "description": "address or null" } }
      }
    },
    "/omnl/mirror-coordinator": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Read OMNLMirrorCoordinator mirror destination",
        "operationId": "getOmnlMirrorCoordinator",
        "parameters": [
          {
            "name": "chainId",
            "in": "query",
            "schema": { "type": "integer", "default": 138 },
            "description": "Chain where coordinator is deployed"
          }
        ],
        "responses": { "200": { "description": "selector, receiver, feeToken" }, "503": { "description": "Not configured" } }
      }
    },
    "/omnl/compliance/{lineId}": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "ComplianceCore snapshot",
        "operationId": "getOmnlCompliance",
        "parameters": [
          { "name": "lineId", "in": "path", "required": true, "schema": { "type": "string" } },
          {
            "name": "chainId",
            "in": "query",
            "schema": { "type": "integer", "default": 138 }
          }
        ],
        "responses": { "200": { "description": "Compliance snapshot" } }
      }
    },
    "/omnl/compliance-aggregated/{lineId}": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Aggregated cross-chain compliance",
        "operationId": "getOmnlComplianceAggregated",
        "parameters": [{ "name": "lineId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Aggregated snapshot" } }
      }
    },
    "/omnl/instruments": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "InstrumentRegistry lines",
        "operationId": "getOmnlInstruments",
        "parameters": [
          { "name": "chainId", "in": "query", "schema": { "type": "integer", "default": 138 } }
        ],
        "responses": { "200": { "description": "lines" } }
      }
    },
    "/omnl/attestations/{lineId}": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Reserve commitment",
        "operationId": "getOmnlAttestations",
        "parameters": [
          { "name": "lineId", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "chainId", "in": "query", "schema": { "type": "integer", "default": 138 } }
        ],
        "responses": { "200": { "description": "Commitment tuple" } }
      }
    },
    "/omnl/breaker": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Circuit breaker status",
        "operationId": "getOmnlBreaker",
        "parameters": [
          { "name": "chainId", "in": "query", "schema": { "type": "integer", "default": 138 } },
          { "name": "lineId", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": { "200": { "description": "Breaker state" } }
      }
    },
    "/omnl/mirror-status/{lineId}": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Compare reserve attestation across chains",
        "operationId": "getOmnlMirrorStatus",
        "parameters": [{ "name": "lineId", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Comparison" } }
      }
    },
    "/omnl/health": {
      "get": {
        "tags": ["omnl-chain"],
        "summary": "Multi-chain compliance health (requires OMNL_HEALTH_LINE_ID)",
        "operationId": "getOmnlHealth",
        "responses": { "200": { "description": "Health payload" }, "400": { "description": "Missing line id env" } }
      }
    },
    "/omnl/ipsas/registry": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "IPSAS GL registry JSON",
        "operationId": "getOmnlIpsasRegistry",
        "responses": { "200": { "description": "Registry" } }
      }
    },
    "/omnl/ipsas/matrix": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Journal matrix JSON",
        "operationId": "getOmnlIpsasMatrix",
        "responses": { "200": { "description": "Matrix" } }
      }
    },
    "/omnl/ipsas/validate-pair": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Validate one GL pair",
        "operationId": "getOmnlIpsasValidatePair",
        "parameters": [
          { "name": "debitGlCode", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "creditGlCode", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": { "200": { "description": "Validation result" } }
      }
    },
    "/omnl/ipsas/validate-pairs": {
      "post": {
        "tags": ["omnl-ipsas"],
        "summary": "Batch validate GL pairs",
        "operationId": "postOmnlIpsasValidatePairs",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["pairs"],
                "properties": {
                  "pairs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": ["debitGlCode", "creditGlCode"],
                      "properties": {
                        "debitGlCode": { "type": "string" },
                        "creditGlCode": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": { "200": { "description": "Batch results" }, "400": { "description": "Invalid body" } }
      }
    },
    "/omnl/ipsas/fineract-health": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Fineract API reachability probe",
        "operationId": "getOmnlIpsasFineractHealth",
        "responses": { "200": { "description": "Health payload" } }
      }
    },
    "/omnl/ipsas/fineract-compare": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Registry vs live Fineract GL accounts",
        "operationId": "getOmnlIpsasFineractCompare",
        "security": [{ "OmnlApiKey": [] }, { "AccessTokenQuery": [] }],
        "responses": { "200": { "description": "Compare result" }, "401": { "description": "When OMNL_API_KEY set" } }
      }
    },
    "/omnl/ipsas/layer/{layer}": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Monetary layer hint",
        "operationId": "getOmnlIpsasLayer",
        "parameters": [{ "name": "layer", "in": "path", "required": true, "schema": { "type": "string" } }],
        "responses": { "200": { "description": "Layer hint" }, "404": { "description": "Unknown layer" } }
      }
    },
    "/omnl/ipsas/compliance-context/{lineId}": {
      "get": {
        "tags": ["omnl-ipsas"],
        "summary": "Compliance + IPSAS posting guidance",
        "operationId": "getOmnlIpsasComplianceContext",
        "parameters": [
          { "name": "lineId", "in": "path", "required": true, "schema": { "type": "string" } },
          {
            "name": "aggregated",
            "in": "query",
            "schema": { "type": "string", "enum": ["1", "true"] },
            "description": "Set to 1 for aggregated view"
          }
        ],
        "security": [{ "OmnlApiKey": [] }, { "AccessTokenQuery": [] }],
        "responses": { "200": { "description": "Context" }, "401": { "description": "When OMNL_API_KEY set" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OmnlApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "When OMNL_API_KEY is set: value equals that secret (Bearer)."
      },
      "AccessTokenQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "access_token",
        "description": "Alternate to Bearer when OMNL_API_KEY is set."
      }
    }
  }
}
