{
  "openapi": "3.1.0",
  "info": {
    "title": "Flex V Capital Ltd — Public API",
    "version": "1.0.0",
    "description": "Public-facing API for Flex V Capital Ltd, a direct commercial lender based in Northport, New York. Endpoints support loan applications, contact inquiries, newsletter subscriptions, and blog content retrieval.",
    "contact": {
      "name": "Flex V Capital Ltd",
      "url": "https://flexvcapital.com/contact",
      "email": "loans@flexvcapital.com"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://flexvcapital.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/apply": {
      "post": {
        "operationId": "submitLoanApplication",
        "summary": "Submit a loan application",
        "description": "Accepts a multi-step commercial loan application. Rate-limited to 5 submissions per 15 minutes per IP. On success, sends a confirmation email to the applicant and a notification to the lending team.",
        "tags": ["Applications"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoanApplicationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Application submitted successfully",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessResponse" }
              }
            }
          },
          "400": {
            "description": "Validation error — missing or invalid fields",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/api/contact": {
      "post": {
        "operationId": "submitContactForm",
        "summary": "Submit a contact inquiry",
        "description": "Sends a contact inquiry to the Flex V Capital lending team. Rate-limited to 5 submissions per 15 minutes per IP.",
        "tags": ["Contact"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inquiry submitted successfully",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessResponse" }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/api/subscribe": {
      "post": {
        "operationId": "subscribeNewsletter",
        "summary": "Subscribe to the Flex V Capital newsletter",
        "description": "Adds an email address to the Flex V Capital newsletter list. Rate-limited to 10 subscriptions per hour per IP.",
        "tags": ["Newsletter"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email"],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Subscriber email address"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscribed successfully",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid email address",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/api/grandranker/posts": {
      "get": {
        "operationId": "listBlogPosts",
        "summary": "List published blog posts",
        "description": "Returns all published blog posts persisted from the GrandRanker content pipeline. Posts are sorted by publication date descending.",
        "tags": ["Blog"],
        "responses": {
          "200": {
            "description": "Array of blog post summaries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/BlogPostSummary" }
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "healthCheck",
        "summary": "Server health check",
        "description": "Returns the server status and current timestamp. Cached for 30 seconds.",
        "tags": ["System"],
        "responses": {
          "200": {
            "description": "Server is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" },
                    "timestamp": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LoanApplicationRequest": {
        "type": "object",
        "description": "Commercial loan application payload",
        "required": ["firstName", "lastName", "email", "phone", "loanType", "loanAmount"],
        "properties": {
          "firstName": { "type": "string", "description": "Applicant first name" },
          "lastName": { "type": "string", "description": "Applicant last name" },
          "email": { "type": "string", "format": "email", "description": "Applicant email address" },
          "phone": { "type": "string", "description": "Applicant phone number" },
          "loanType": {
            "type": "string",
            "description": "Type of loan requested",
            "enum": ["commercial-mortgage", "bridge-loan", "sba-7a", "sba-504", "dscr", "hard-money", "construction", "mezzanine", "business-term", "working-capital"]
          },
          "loanAmount": { "type": "number", "description": "Requested loan amount in USD", "minimum": 50000 },
          "propertyType": { "type": "string", "description": "Type of collateral property (if applicable)" },
          "propertyAddress": { "type": "string", "description": "Address of the collateral property (if applicable)" },
          "message": { "type": "string", "description": "Additional notes or context from the applicant" }
        }
      },
      "ContactRequest": {
        "type": "object",
        "required": ["name", "email", "message"],
        "properties": {
          "name": { "type": "string", "description": "Sender full name" },
          "email": { "type": "string", "format": "email", "description": "Sender email address" },
          "phone": { "type": "string", "description": "Sender phone number (optional)" },
          "message": { "type": "string", "description": "Inquiry message body" }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "example": true },
          "message": { "type": "string", "description": "Human-readable success message" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "description": "Machine-readable error code or message" },
          "message": { "type": "string", "description": "Human-readable error description" }
        }
      },
      "BlogPostSummary": {
        "type": "object",
        "properties": {
          "slug": { "type": "string", "description": "URL slug for the post (used in /blog/:slug)" },
          "title": { "type": "string", "description": "Post title" },
          "excerpt": { "type": "string", "description": "Short excerpt or summary" },
          "date": { "type": "string", "format": "date", "description": "Publication date (YYYY-MM-DD)" },
          "author": { "type": "string", "description": "Author name" },
          "tags": { "type": "array", "items": { "type": "string" }, "description": "Topic tags" }
        }
      }
    }
  },
  "tags": [
    { "name": "Applications", "description": "Loan application submission" },
    { "name": "Contact", "description": "Contact and inquiry forms" },
    { "name": "Newsletter", "description": "Email newsletter subscription" },
    { "name": "Blog", "description": "Blog post content" },
    { "name": "System", "description": "Server health and diagnostics" }
  ]
}
