{
  "openapi": "3.1.0",
  "info": {
    "title": "FideRail Control Plane & Trust Oracle API",
    "version": "2.3.5",
    "description": "Non-custodial cross-chain (Base, Solana, Arbitrum, Polygon) AI Agent payment control plane, anti-sybil reputation oracle, pre-flight firewall, Open Bazaar endpoint grader, and x402#2299 Trust-Provider hook.",
    "contact": {
      "name": "FideRail Maintainers",
      "email": "founder@fiderail.com",
      "url": "https://fiderail.com"
    }
  },
  "servers": [
    {
      "url": "https://api.fiderail.com"
    },
    {
      "url": "https://fiderail.com"
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "summary": "Live indexer telemetry, dataset freshness, and L1/L2 health summary",
        "responses": {
          "200": {
            "description": "Health and dataset telemetry JSON"
          }
        }
      }
    },
    "/v1/trust/{chain}/{address}": {
      "get": {
        "summary": "Get trust-v2 anti-sybil credit score, confidence, dual HHI metrics, dataCoverage, isolated associatedCredit, Bazaar services, and liveness",
        "parameters": [
          {
            "name": "chain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "base",
                "solana",
                "arbitrum",
                "polygon"
              ]
            }
          },
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Agent trust profile (includes X-FideRail-Cache and X-FideRail-Model-Hash headers)"
          },
          "400": {
            "description": "Invalid chain or wallet address format"
          },
          "402": {
            "description": "Payment Required when x402Enforce is enabled or free-tier quota is exceeded"
          }
        }
      }
    },
    "/v1/history/{chain}/{address}": {
      "get": {
        "summary": "Get delta trust score history, risk flag transitions, current trust profile, and latest signed Merkle stateRoot commitment",
        "parameters": [
          {
            "name": "chain",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "base",
                "solana",
                "arbitrum",
                "polygon"
              ]
            }
          },
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delta trust score history and latest Merkle stateRoot"
          },
          "400": {
            "description": "Invalid chain or wallet address format"
          }
        }
      }
    },
    "/v1/agents": {
      "get": {
        "summary": "List audited AI agent payee wallets with SQL-pushed pagination, tier, channel, and sort filters",
        "parameters": [
          {
            "name": "chain",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "base",
                "solana",
                "arbitrum",
                "polygon"
              ]
            }
          },
          {
            "name": "tier",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "FLAGGED",
                "HIGH_TRUST",
                "MODERATE_TRUST",
                "LOW_HISTORY",
                "FLAGGED_LOOP",
                "FLAGGED_CONCENTRATED",
                "FLAGGED_FARM"
              ]
            }
          },
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "x402"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "score",
                "volume",
                "txs",
                "risk"
              ]
            }
          },
          {
            "name": "minScore",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "excludeFlagged",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated leaderboard payload"
          },
          "400": {
            "description": "Invalid enum or numeric query parameter"
          }
        }
      }
    },
    "/v1/services": {
      "get": {
        "summary": "Search CDP Bazaar, PayAI, and Open Bazaar services enriched with trust and liveness",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "chain",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "base",
                "solana",
                "arbitrum",
                "polygon"
              ]
            }
          },
          {
            "name": "maxPriceUsdc",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "minTrustScore",
            "in": "query",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "excludeFlagged",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated trusted x402 service capabilities"
          },
          "400": {
            "description": "Invalid enum or numeric query parameter"
          }
        }
      }
    },
    "/v1/preflight": {
      "post": {
        "summary": "Simulate pre-flight payment firewall check (ALLOW / WARN / BLOCK)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "chain",
                  "counterparty",
                  "amountUsdc"
                ],
                "properties": {
                  "chain": {
                    "type": "string",
                    "enum": [
                      "base",
                      "solana",
                      "arbitrum",
                      "polygon"
                    ]
                  },
                  "counterparty": {
                    "type": "string"
                  },
                  "amountUsdc": {
                    "type": "number"
                  },
                  "spentTodayUsdc": {
                    "type": "number"
                  },
                  "policy": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Firewall verdict and reasons"
          }
        }
      }
    },
    "/v1/diagnose": {
      "post": {
        "summary": "Zero-payment x402 endpoint diagnostic grader & Open Bazaar self-submission",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "GET",
                      "POST"
                    ]
                  },
                  "autoRegister": {
                    "type": "boolean"
                  },
                  "serviceName": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Grade (A/B/C/F), header safety, and registration status"
          }
        }
      }
    },
    "/v1/trust-provider/before-settle": {
      "post": {
        "summary": "x402#2299 Trust-Provider onBeforeSettle behavioral risk hook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payer"
                ],
                "properties": {
                  "chain": {
                    "type": "string"
                  },
                  "network": {
                    "type": "string"
                  },
                  "payer": {
                    "type": "string"
                  },
                  "amountUsdc": {
                    "type": "number"
                  },
                  "minTrustScore": {
                    "type": "number"
                  },
                  "blockLoops": {
                    "type": "boolean"
                  },
                  "allowUnknown": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settlement screening decision (ALLOW / WARN / REJECT)"
          }
        }
      }
    },
    "/v1/telemetry/delivery": {
      "post": {
        "summary": "Report L2 post-payment delivery telemetry (fiderail-sar-v2 required, deduplicated, unverified negative claims quarantined)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "chain",
                  "address",
                  "resourceUrl",
                  "delivered",
                  "receipt"
                ],
                "properties": {
                  "chain": {
                    "type": "string",
                    "enum": [
                      "base",
                      "solana",
                      "arbitrum",
                      "polygon"
                    ]
                  },
                  "address": {
                    "type": "string"
                  },
                  "resourceUrl": {
                    "type": "string"
                  },
                  "httpStatus": {
                    "type": "integer"
                  },
                  "delivered": {
                    "type": "boolean"
                  },
                  "latencyMs": {
                    "type": "number"
                  },
                  "receipt": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Telemetry acknowledgement"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "Remote Streamable HTTP MCP (JSON-RPC 2.0) endpoint exposing the 5 stateless FideRail trust, pre-flight firewall, service discovery, and diagnostic tools (guarded_x402_fetch stays local-only)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {
                    "type": [
                      "string",
                      "integer",
                      "null"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "initialize",
                      "notifications/initialized",
                      "ping",
                      "tools/list",
                      "tools/call"
                    ]
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC 2.0 response payload"
          },
          "202": {
            "description": "Notification accepted"
          }
        }
      }
    },
    "/.well-known/fiderail-keys.json": {
      "get": {
        "summary": "Public Ed25519 verification keys and canonical signing format for Merkle stateRoot commitments",
        "responses": {
          "200": {
            "description": "Public Ed25519 verification key set (SPKI PEM + keyId)"
          }
        }
      }
    },
    "/.well-known/fiderail-manifest.json": {
      "get": {
        "summary": "Machine-readable Single Source of Truth (SSOT) manifest for FideRail v2.3.5",
        "responses": {
          "200": {
            "description": "FideRail SSOT manifest JSON"
          }
        }
      }
    },
    "/reports/1m-audit": {
      "get": {
        "summary": "Self-hosted stratified 1M+ On-Chain Agent Payments Audit Report (HTML for browsers, raw Markdown via /reports/1m-audit.md)",
        "responses": {
          "200": {
            "description": "Stratified 1M+ Agent Payments Audit Report"
          }
        }
      }
    }
  }
}