{
  "openapi": "3.0.3",
  "info": {
    "title": "M441-SEAL",
    "version": "1.0.0",
    "description": "Timestamped sealing for agents: embed a DCT signature watermark into an image, verify a seal, and anchor a SHA-256 hash on Solana via a Memo transaction. Price: 0.03 SOL per seal and per anchor ($M441: -10%), enforced by an on-chain payment gate (HTTP 402). Verification is free of the paygate. Default anchor network: devnet (mainnet requires explicit owner approval). Source of truth: seal_server.py (port 4430)."
  },
  "servers": [{ "url": "https://seal.441engine.com" }],
  "paths": {
    "/health": {
      "get": {
        "summary": "Service health (public)",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "OK",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "status": { "type": "string", "example": "ok" },
                "service": { "type": "string", "example": "m441-seal" },
                "version": { "type": "string" },
                "network_default": { "type": "string", "example": "devnet" }
              } } } }
          }
        }
      }
    },
    "/api/v1/seal": {
      "post": {
        "summary": "Embed a signature watermark into an image (0.03 SOL)",
        "operationId": "sealImage",
        "security": [{ "ApiKeyAuth": [] }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "required": ["image_b64", "signature"],
            "properties": {
              "image_b64": { "type": "string", "format": "byte", "description": "JPEG image, base64, max 8 MB decoded" },
              "signature": { "type": "string", "description": "Signature string to embed (non-empty)" },
              "quality": { "type": "integer", "default": 95, "description": "JPEG quality of the sealed output" }
            } } } }
        },
        "responses": {
          "200": {
            "description": "Seal result, including the sealed image",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "sealed_image_b64": { "type": "string", "format": "byte" }
              },
              "additionalProperties": true
            } } } }
          },
          "400": { "description": "Invalid JSON, missing signature, or oversized image" },
          "401": { "description": "Missing or invalid x-api-key header" },
          "402": { "description": "Payment required (paygate)" }
        }
      }
    },
    "/api/v1/verify": {
      "post": {
        "summary": "Extract and validate the seal of an image",
        "operationId": "verifySeal",
        "security": [{ "ApiKeyAuth": [] }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "required": ["image_b64"],
            "properties": {
              "image_b64": { "type": "string", "format": "byte" }
            } } } }
        },
        "responses": {
          "200": {
            "description": "Verification result (HTTP 200 in both cases)",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "valid": { "type": "boolean" },
                "signature": { "type": "string" },
                "error": { "type": "string" }
              } } } }
          },
          "401": { "description": "Missing or invalid x-api-key header" }
        }
      }
    },
    "/api/v1/anchor": {
      "post": {
        "summary": "Anchor a SHA-256 hash on Solana (0.03 SOL)",
        "operationId": "anchorHash",
        "security": [{ "ApiKeyAuth": [] }],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": {
            "type": "object",
            "required": ["sha256", "issuer"],
            "properties": {
              "sha256": { "type": "string", "description": "Hex SHA-256 of the sealed content" },
              "issuer": { "type": "string" },
              "network": { "type": "string", "default": "devnet", "enum": ["devnet"] }
            } } } }
        },
        "responses": {
          "200": { "description": "Anchor result (includes the Solana transaction signature)", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } },
          "401": { "description": "Missing or invalid x-api-key header" },
          "402": { "description": "Payment required (paygate)" }
        }
      }
    },
    "/api/v1/anchor/{signature}": {
      "get": {
        "summary": "Verify an existing anchor by transaction signature",
        "operationId": "verifyAnchor",
        "security": [{ "ApiKeyAuth": [] }],
        "parameters": [
          { "name": "signature", "in": "path", "required": true, "schema": { "type": "string" } },
          { "name": "network", "in": "query", "required": false, "schema": { "type": "string", "default": "devnet" } }
        ],
        "responses": {
          "200": { "description": "Anchor verification result", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } },
          "401": { "description": "Missing or invalid x-api-key header" }
        }
      }
    }
  }