{
  "openapi": "3.1.0",
  "info": {
    "title": "Pay Guard (pre-payment check + Seller Wallet Reputation)",
    "version": "0.1.0",
    "summary": "allow/warn/block before an agent signs an x402 402; plus seller wallet reputation from Agentropolis.",
    "description": "Deterministic checks, no LLM. Default to warn when Agentropolis coverage is missing (false blocks hurt trust). Pay Guard $0.01/call; Seller Wallet Reputation $0.02/call.",
    "contact": {
      "name": "Seenly / Agentropolis",
      "email": "hello@agentropolis.io"
    },
    "x-guidance": "POST /api/guard with plan + challenge; branch on verdict. POST /api/reputation with payTo for seller stats."
  },
  "servers": [
    {
      "url": "https://seenly-pay-guard.vercel.app"
    }
  ],
  "paths": {
    "/api/guard": {
      "post": {
        "operationId": "payGuard",
        "summary": "Pre-payment allow/warn/block check for an x402 challenge",
        "description": "$0.01 USDC per call on Base mainnet. Invalid → 422 before payment. Settles only on success.",
        "tags": [
          "Pay Guard"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.01"
          },
          "protocols": [
            {
              "x402": {}
            }
          ],
          "rails": [
            {
              "protocol": "x402",
              "version": 2,
              "scheme": "exact",
              "network": "eip155:8453",
              "networkName": "Base mainnet",
              "asset": "USDC",
              "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "amount": "10000",
              "priceUsd": "0.01",
              "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
              "facilitator": "Coinbase CDP (gas sponsored; payer needs no ETH)",
              "header": "PAYMENT-SIGNATURE"
            }
          ]
        },
        "x-free-allowance": {
          "available": true,
          "per_caller_per_day": 5,
          "global_per_day": 150,
          "window": "UTC day (resets 00:00 UTC)",
          "how": "Add header \"X-Free-Allowance: use\" (or ?free=1) to a valid request. If you have free calls left it runs with no payment; otherwise you get this same x402 402.",
          "caller": "per client network: IPv4 /24 or IPv6 /64 (hashed, never stored raw)",
          "applies_to": [
            "POST /api/guard",
            "POST /api/reputation"
          ],
          "note": "Free calls are not sales and never count toward settlements or trust. Calls through the Agentropolis relay always use x402."
        },
        "parameters": [
          {
            "name": "X-Free-Allowance",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "use"
              ]
            },
            "description": "Opt in to the free daily allowance (5/caller network/day, global cap; see x-free-allowance)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GuardRequest"
              },
              "example": {
                "domain": "seenly-payload-check.vercel.app",
                "max_price_usd": 0.05,
                "challenge": {
                  "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
                  "amount": "30000",
                  "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
                  "network": "eip155:8453",
                  "resource": "https://seenly-payload-check.vercel.app/api/check"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Guard verdict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GuardResult"
                }
              }
            }
          },
          "402": {
            "description": "Payment required (x402 v2)"
          },
          "422": {
            "description": "invalid_request (not charged)"
          },
          "429": {
            "description": "rate_limited"
          }
        }
      }
    },
    "/api/reputation": {
      "post": {
        "operationId": "sellerWalletReputation",
        "summary": "Seller wallet reputation from Agentropolis public data",
        "description": "$0.02 USDC per call on Base mainnet. Coverage-limited when the payTo is not indexed.",
        "tags": [
          "Seller Wallet Reputation"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          },
          "protocols": [
            {
              "x402": {}
            }
          ],
          "rails": [
            {
              "protocol": "x402",
              "version": 2,
              "scheme": "exact",
              "network": "eip155:8453",
              "networkName": "Base mainnet",
              "asset": "USDC",
              "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "amount": "20000",
              "priceUsd": "0.02",
              "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
              "facilitator": "Coinbase CDP (gas sponsored; payer needs no ETH)",
              "header": "PAYMENT-SIGNATURE"
            }
          ]
        },
        "x-free-allowance": {
          "available": true,
          "per_caller_per_day": 5,
          "global_per_day": 150,
          "window": "UTC day (resets 00:00 UTC)",
          "how": "Add header \"X-Free-Allowance: use\" (or ?free=1) to a valid request. If you have free calls left it runs with no payment; otherwise you get this same x402 402.",
          "caller": "per client network: IPv4 /24 or IPv6 /64 (hashed, never stored raw)",
          "applies_to": [
            "POST /api/guard",
            "POST /api/reputation"
          ],
          "note": "Free calls are not sales and never count toward settlements or trust. Calls through the Agentropolis relay always use x402."
        },
        "parameters": [
          {
            "name": "X-Free-Allowance",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "use"
              ]
            },
            "description": "Opt in to the free daily allowance (5/caller network/day, global cap; see x-free-allowance)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReputationRequest"
              },
              "example": {
                "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reputation report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReputationResult"
                }
              }
            }
          },
          "402": {
            "description": "Payment required (x402 v2)"
          },
          "422": {
            "description": "invalid_request (not charged)"
          }
        }
      },
      "get": {
        "operationId": "sellerWalletReputationGet",
        "summary": "Seller wallet reputation (GET)",
        "tags": [
          "Seller Wallet Reputation"
        ],
        "x-payment-info": {
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "0.02"
          },
          "protocols": [
            {
              "x402": {}
            }
          ],
          "rails": [
            {
              "protocol": "x402",
              "version": 2,
              "scheme": "exact",
              "network": "eip155:8453",
              "networkName": "Base mainnet",
              "asset": "USDC",
              "assetAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "amount": "20000",
              "priceUsd": "0.02",
              "payTo": "0xeE6239F3E17bEBe5e89F21F29D74D68CAa0d78CE",
              "facilitator": "Coinbase CDP (gas sponsored; payer needs no ETH)",
              "header": "PAYMENT-SIGNATURE"
            }
          ]
        },
        "parameters": [
          {
            "name": "payTo",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "domain",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "listing_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Free-Allowance",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "use"
              ]
            },
            "description": "Opt in to the free daily allowance (5/caller network/day, global cap; see x-free-allowance)."
          }
        ],
        "responses": {
          "200": {
            "description": "Reputation report"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "GuardRequest": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "description": "Planned seller domain / host the agent intends to pay."
          },
          "max_price_usd": {
            "type": "number",
            "minimum": 0,
            "description": "Hard cap the agent will not exceed (USD)."
          },
          "asset": {
            "type": "string",
            "default": "USDC"
          },
          "network": {
            "type": "string",
            "default": "eip155:8453"
          },
          "listed_price_usd": {
            "type": "number",
            "minimum": 0,
            "description": "Optional expected listed price from the agent’s plan."
          },
          "challenge": {
            "type": "object",
            "description": "The x402 402 challenge / accept entry the agent received.",
            "properties": {
              "payTo": {
                "type": "string"
              },
              "amount": {
                "type": "string",
                "description": "Atomic USDC units (6 decimals), e.g. \"10000\" = $0.01."
              },
              "asset": {
                "type": "string"
              },
              "network": {
                "type": "string"
              },
              "resource": {
                "type": "string",
                "description": "HTTPS resource URL from the 402."
              }
            },
            "required": [
              "payTo",
              "amount"
            ]
          },
          "payTo": {
            "type": "string",
            "description": "Shortcut: challenge.payTo at top level."
          },
          "amount": {
            "type": "string"
          },
          "requestKey": {
            "type": "string",
            "maxLength": 128
          }
        },
        "required": [
          "max_price_usd"
        ],
        "additionalProperties": true
      },
      "GuardResult": {
        "type": "object",
        "properties": {
          "kit": {
            "type": "string"
          },
          "verdict": {
            "type": "string",
            "enum": [
              "allow",
              "warn",
              "block"
            ]
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checks": {
            "type": "object"
          },
          "advice": {
            "type": "string"
          },
          "coverage": {
            "type": "object"
          },
          "check_version": {
            "type": "string"
          },
          "pricing": {
            "type": "object"
          }
        }
      },
      "ReputationRequest": {
        "type": "object",
        "properties": {
          "payTo": {
            "type": "string",
            "description": "Seller receive address to score."
          },
          "domain": {
            "type": "string",
            "description": "Optional domain hint to find listings."
          },
          "listing_id": {
            "type": "string",
            "description": "Optional Agentropolis listing id hint."
          },
          "requestKey": {
            "type": "string",
            "maxLength": 128
          }
        },
        "required": [
          "payTo"
        ],
        "additionalProperties": false
      },
      "ReputationResult": {
        "type": "object",
        "properties": {
          "kit": {
            "type": "string"
          },
          "payTo": {
            "type": "string"
          },
          "coverage": {
            "type": "string",
            "enum": [
              "full",
              "partial",
              "none"
            ]
          },
          "coverage_note": {
            "type": "string"
          },
          "listings": {
            "type": "array"
          },
          "aggregate": {
            "type": "object"
          },
          "check_version": {
            "type": "string"
          },
          "pricing": {
            "type": "object"
          }
        }
      }
    }
  },
  "x-rate-limit": "60/min"
}