{
  "openapi": "3.1.0",
  "info": {
    "title": "PositivePayMaker API",
    "version": "1.0.0",
    "description": "Generate and validate bank positive pay (check issue) files. Stateless: no storage or logging of check data. The browser tool at positivepaymaker.com is fully client-side; this API exists for agents and integrations. An MCP server exposing the same operations is described at /.well-known/mcp/server-card.json.",
    "contact": { "email": "support@positivepaymaker.com", "url": "https://positivepaymaker.com/" }
  },
  "servers": [{ "url": "https://api.positivepaymaker.com" }],
  "paths": {
    "/v1/formats": {
      "get": {
        "operationId": "listBankFormats",
        "summary": "List supported bank positive pay layouts",
        "responses": {
          "200": {
            "description": "Supported formats with confidence labels and source spec URLs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "formats": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/FormatSummary" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/convert": {
      "post": {
        "operationId": "generatePositivePayMaker",
        "summary": "Convert checks into a bank-formatted positive pay file",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": { "schema": { "$ref": "#/components/schemas/ConvertRequest" } }
          }
        },
        "responses": {
          "200": {
            "description": "Generated file plus validation report",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ConvertResponse" } }
            }
          },
          "400": { "description": "Unknown format_id or malformed checks" }
        }
      }
    },
    "/v1/validate": {
      "post": {
        "operationId": "validatePositivePayMaker",
        "summary": "Validate an existing positive pay file against a bank layout",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["format_id", "file_content"],
                "properties": {
                  "format_id": { "type": "string" },
                  "file_content": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structural issues found (level: err/warn/ok)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": { "issues": { "type": "array", "items": { "$ref": "#/components/schemas/Issue" } } }
                }
              }
            }
          },
          "400": { "description": "Unknown format_id" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "FormatSummary": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "bank": { "type": "string" },
          "type": { "type": "string", "enum": ["fixed", "delimited"] },
          "confidence": { "type": "string", "enum": ["verified", "reconstructed", "generic"] },
          "source_url": { "type": "string" },
          "notes": { "type": "string" }
        }
      },
      "Check": {
        "type": "object",
        "required": ["check_number", "issue_date", "amount"],
        "properties": {
          "check_number": { "type": "string", "description": "Real check number, digits only preferred" },
          "issue_date": { "type": "string", "description": "ISO (2026-06-11) or US (06/11/2026)" },
          "amount": { "type": "number", "exclusiveMinimum": 0, "description": "Positive dollars; mark voids with the void flag, never negative amounts" },
          "payee_name": { "type": "string" },
          "void": { "type": "boolean", "default": false }
        }
      },
      "ConvertRequest": {
        "type": "object",
        "required": ["format_id", "account_number", "checks"],
        "properties": {
          "format_id": { "type": "string", "description": "From GET /v1/formats, e.g. chase-business-csv" },
          "account_number": { "type": "string", "description": "Bank account the checks are drawn on" },
          "checks": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/Check" } }
        }
      },
      "ConvertResponse": {
        "type": "object",
        "properties": {
          "file_content": { "type": "string" },
          "filename": { "type": "string" },
          "check_count": { "type": "integer" },
          "total_amount": { "type": "number" },
          "format": { "$ref": "#/components/schemas/FormatSummary" },
          "issues": { "type": "array", "items": { "$ref": "#/components/schemas/Issue" } },
          "reminder": { "type": "string", "description": "Always present: verify the first file with the bank" }
        }
      },
      "Issue": {
        "type": "object",
        "properties": {
          "level": { "type": "string", "enum": ["err", "warn", "ok"] },
          "msg": { "type": "string" }
        }
      }
    }
  }
}
