{
  "openapi": "3.1.0",
  "info": {
    "title": "Shizen Capital x402 Contact Form API",
    "description": "Submit a contact request to Shizen Capital. Endpoints are protected by the x402 HTTP payment protocol. Agents must pay a small USDC micro-payment before the submission is processed.\n\nFlow:\n1. POST with body → receive 402 with payment terms.\n2. Sign ERC-3009 TransferWithAuthorization EIP-712 typed-data.\n3. Re-POST with X-PAYMENT header (base64-encoded x402 object) → receive 200.",
    "version": "1.0.0",
    "contact": {
      "email": "whitelist@shizen.vc"
    },
    "x-agent-compatible": true,
    "x-payment-protocol": "x402"
  },
  "servers": [
    {
      "url": "https://x402-contact-form-juco235vwa-uc.a.run.app",
      "description": "Production server (Google Cloud Run)"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "healthCheck",
        "description": "Returns server status and available routes. No payment required.",
        "responses": {
          "200": {
            "description": "Server is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" },
                    "routes": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/submit-contact-testnet": {
      "post": {
        "summary": "Submit contact form (Base Sepolia testnet)",
        "operationId": "submitContactTestnet",
        "description": "Submit a contact form. Requires x402 payment of $1.00 test-USDC on Base Sepolia (chainId 84532). Probe without X-PAYMENT header first to obtain 402 payment terms.",
        "x-payment": {
          "network": "base-sepolia",
          "chainId": 84532,
          "price_usd": "1.00",
          "asset": "USDC",
          "asset_address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
          "facilitator": "https://x402.org/facilitator"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ContactRequest" }
            }
          }
        },
        "parameters": [
          { "$ref": "#/components/parameters/XPaymentHeader" }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/ContactSuccess" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "402": { "$ref": "#/components/responses/PaymentRequired" }
        }
      }
    },
    "/submit-contact-mainnet": {
      "post": {
        "summary": "Submit contact form (Base mainnet)",
        "operationId": "submitContactMainnet",
        "description": "Submit a contact form. Requires x402 payment of $0.10 USDC on Base mainnet (chainId 8453).",
        "x-payment": {
          "network": "base",
          "chainId": 8453,
          "price_usd": "0.10",
          "asset": "USDC",
          "asset_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "facilitator": "https://facilitator.xpay.sh"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ContactRequest" }
            }
          }
        },
        "parameters": [
          { "$ref": "#/components/parameters/XPaymentHeader" }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/ContactSuccess" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "402": { "$ref": "#/components/responses/PaymentRequired" }
        }
      }
    },
    "/submit-contact-ethereum": {
      "post": {
        "summary": "Submit contact form (Ethereum mainnet)",
        "operationId": "submitContactEthereum",
        "description": "Submit a contact form. Requires x402 payment of $0.10 USDC on Ethereum mainnet (chainId 1).",
        "x-payment": {
          "network": "ethereum-mainnet",
          "chainId": 1,
          "price_usd": "0.10",
          "asset": "USDC",
          "asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "facilitator": "https://facilitator.primev.xyz"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ContactRequest" }
            }
          }
        },
        "parameters": [
          { "$ref": "#/components/parameters/XPaymentHeader" }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/ContactSuccess" },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "402": { "$ref": "#/components/responses/PaymentRequired" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ContactRequest": {
        "type": "object",
        "required": ["name", "email", "message"],
        "properties": {
          "name":    { "type": "string", "example": "Noriko Tanaka" },
          "email":   { "type": "string", "format": "email", "example": "noriko@tanaka.com" },
          "message": { "type": "string", "example": "I would like to discuss a potential investment." }
        }
      },
      "X402PaymentObject": {
        "type": "object",
        "description": "x402 payment payload, base64-encoded and passed in the X-PAYMENT header.",
        "required": ["x402Version", "scheme", "network", "resource", "payload"],
        "properties": {
          "x402Version": { "type": "integer", "example": 1 },
          "scheme":      { "type": "string",  "example": "exact" },
          "network":     { "type": "string",  "example": "base-sepolia" },
          "resource": {
            "type": "object",
            "properties": {
              "url":         { "type": "string" },
              "description": { "type": "string" },
              "mimeType":    { "type": "string" }
            }
          },
          "payload": {
            "type": "object",
            "properties": {
              "signature": { "type": "string", "description": "ERC-3009 EIP-712 typed-data signature" },
              "authorization": {
                "type": "object",
                "properties": {
                  "from":        { "type": "string", "description": "Payer wallet address" },
                  "to":          { "type": "string", "description": "Payee address (from 402 payTo)" },
                  "value":       { "type": "string", "description": "Amount in USDC base units (from 402 maxAmountRequired)" },
                  "validAfter":  { "type": "string", "example": "0" },
                  "validBefore": { "type": "string", "description": "Unix timestamp ~5 min in future" },
                  "nonce":       { "type": "string", "description": "Random 32-byte hex string" }
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "XPaymentHeader": {
        "name": "X-PAYMENT",
        "in": "header",
        "required": false,
        "description": "Base64-encoded x402 payment object. Required for the actual paid submission (after probing for 402 terms).",
        "schema": { "type": "string" }
      }
    },
    "responses": {
      "ContactSuccess": {
        "description": "Contact form accepted and payment verified.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": { "type": "boolean", "example": true },
                "message": { "type": "string" },
                "txHash":  { "type": "string", "nullable": true }
              }
            }
          }
        }
      },
      "BadRequest": {
        "description": "Missing required fields.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": { "error": { "type": "string" } }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "HTTP 402 — payment required. Response body contains the payment terms needed to build the X-PAYMENT header.",
        "headers": {
          "X-Payment-Protocol": {
            "schema": { "type": "string", "example": "x402" },
            "description": "Indicates the x402 protocol is in use."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "accepts": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "network":            { "type": "string" },
                      "asset":              { "type": "string", "description": "USDC contract address" },
                      "maxAmountRequired":  { "type": "string" },
                      "payTo":              { "type": "string", "description": "Destination wallet address" },
                      "resource":           { "type": "string" },
                      "description":        { "type": "string" },
                      "mimeType":           { "type": "string" },
                      "extra": {
                        "type": "object",
                        "properties": {
                          "name":    { "type": "string", "description": "EIP-712 domain name (USDC token name)" },
                          "version": { "type": "string", "description": "EIP-712 domain version" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
