{
  "openapi": "3.1.0",
  "info": {
    "title": "Termbird Inquiry API",
    "version": "1.0.0",
    "summary": "Check indicative fit and submit a financing inquiry.",
    "description": "Termbird is an independent financing broker, not a lender, for SBA term loans and other small and medium business term loans. It works with more than five lenders. This API lets a business owner \u2014 or an AI agent acting with the owner's explicit permission \u2014 check indicative fit and start an inquiry.\n\nTermbird does not make credit decisions. Submitting an inquiry does not guarantee approval or any particular rate, amount, or terms. All financing is subject to lender review.\n\nAgents must have the business owner's explicit permission to share contact details and the owner's consent to be contacted. Agents must not fabricate information. See /llms.txt and /docs/agents.md.\n\nRate limiting: this API does not enforce a quota in the sample function. Configure rate limiting at the host (for example Netlify or a CDN) before launch.\nTODO(hubspot): the deployed function forwards accepted inquiries to the LEAD_WEBHOOK_URL environment variable (intended for a HubSpot webhook).\n\nThe inquiry also collects an approximate list of existing business debts (verified later), other owners with more than a 20% stake, and citizenship or residency status (asked because SBA eligibility rules depend on it; do not infer it; do not send it to analytics).",
    "license": {
      "name": "UNLICENSED"
    }
  },
  "servers": [
    {
      "url": "https://termbird.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "inquiry",
      "description": "Start a financing inquiry."
    },
    {
      "name": "fit",
      "description": "Indicative fit guidance."
    }
  ],
  "paths": {
    "/api/inquiry": {
      "post": {
        "operationId": "submitInquiry",
        "tags": [
          "inquiry"
        ],
        "summary": "Submit a financing inquiry",
        "description": "Accepts the same fields as the website form, plus submitted_via and consent.granted_by. Requests with a non-empty honeypot (`anti_spam.company_website`) or missing / invalid consent are rejected. A successful response includes a reference_id. Contact details may be submitted only with the business owner's explicit permission.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Pass the same value as submission_id so retries can be de-duplicated."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Inquiry"
              },
              "examples": {
                "agent": {
                  "summary": "Agent-submitted inquiry (sample)",
                  "value": {
                    "submission_id": "11111111-2222-4333-8444-555555555555",
                    "submitted_via": "agent",
                    "funding_amount": "250k_1m",
                    "time_in_business": "2_5y",
                    "purpose": "working_capital",
                    "full_name": "Jane Q Owner",
                    "business_name": "Owner Bakery LLC",
                    "email": "jane@example.com",
                    "phone": "+1 (312) 555-0142",
                    "consent": {
                      "contact": true,
                      "text": "I agree to be contacted about my financing inquiry by Termbird or its representatives.",
                      "version": "2026-10-draft-1",
                      "granted_by": "business_owner"
                    },
                    "anti_spam": {
                      "company_website": ""
                    },
                    "time_in_business_below_minimum": false,
                    "debts": {
                      "none": false,
                      "approximate": true,
                      "items": [
                        {
                          "lender_or_type": "Equipment loan",
                          "approx_balance": "25000",
                          "approx_monthly_payment": "600"
                        }
                      ],
                      "notes": ""
                    },
                    "other_owners": {
                      "none": true,
                      "items": []
                    },
                    "applicant_citizenship": "us_citizen"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inquiry accepted. reference_id is the id to keep for follow-up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InquiryAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Invalid payload, missing consent, or honeypot filled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The inquiry was valid but forwarding to the configured webhook failed. Safe to retry with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/fit-check": {
      "get": {
        "operationId": "getFitCheck",
        "tags": [
          "fit"
        ],
        "summary": "Indicative fit-check description",
        "description": "Machine-readable copy of the indicative fit guidance. Also published as the static file /fit-check.json. These are not underwriting requirements and are not an approval or a decline.",
        "responses": {
          "200": {
            "description": "Indicative fit guidance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FitCheck"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Inquiry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "funding_amount",
          "time_in_business",
          "purpose",
          "full_name",
          "business_name",
          "email",
          "phone",
          "consent",
          "submitted_via",
          "debts",
          "other_owners",
          "applicant_citizenship"
        ],
        "properties": {
          "submission_id": {
            "type": "string",
            "minLength": 8,
            "maxLength": 80,
            "description": "Stable id for this inquiry. Send the same value in the Idempotency-Key header so retries can be de-duplicated."
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "form_version": {
            "type": "string"
          },
          "submitted_via": {
            "type": "string",
            "enum": [
              "agent",
              "web"
            ],
            "description": "Use 'agent' when an AI agent submits on behalf of a business owner; use 'web' for the website form."
          },
          "funding_amount": {
            "type": "string",
            "enum": [
              "under_50k",
              "50k_250k",
              "250k_1m",
              "over_1m"
            ]
          },
          "funding_amount_label": {
            "type": "string"
          },
          "time_in_business": {
            "type": "string",
            "enum": [
              "under_1y",
              "1_2y",
              "2_5y",
              "over_5y"
            ]
          },
          "time_in_business_label": {
            "type": "string"
          },
          "time_in_business_below_minimum": {
            "type": "boolean",
            "description": "True when time_in_business is under_1y, which is below the 1-year minimum but still allowed."
          },
          "purpose": {
            "type": "string",
            "enum": [
              "working_capital",
              "equipment",
              "business_expansion",
              "refinancing",
              "other"
            ]
          },
          "purpose_label": {
            "type": "string"
          },
          "purpose_other": {
            "type": "string",
            "maxLength": 200,
            "description": "Optional free text when purpose is 'other'. Leave empty otherwise."
          },
          "full_name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "business_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "phone": {
            "type": "string",
            "maxLength": 30,
            "description": "Phone number including area or country code (7\u201315 digits)."
          },
          "debts": {
            "$ref": "#/components/schemas/Debts"
          },
          "other_owners": {
            "$ref": "#/components/schemas/OtherOwners"
          },
          "applicant_citizenship": {
            "type": "string",
            "enum": [
              "us_citizen",
              "permanent_resident",
              "other_or_not_sure"
            ],
            "description": "Citizenship or residency of the applicant. Asked because SBA eligibility rules depend on it. Do not infer this value. Treat as sensitive and do not send it to analytics."
          },
          "consent": {
            "$ref": "#/components/schemas/Consent"
          },
          "attribution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "utm_source": {
                "type": "string"
              },
              "utm_medium": {
                "type": "string"
              },
              "utm_campaign": {
                "type": "string"
              },
              "utm_content": {
                "type": "string"
              },
              "utm_term": {
                "type": "string"
              },
              "landing_page_url": {
                "type": "string"
              },
              "referrer": {
                "type": "string"
              }
            }
          },
          "user_agent": {
            "type": "string"
          },
          "anti_spam": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "company_website": {
                "type": "string",
                "description": "Honeypot. Must be omitted or an empty string. Non-empty values are rejected."
              },
              "elapsed_ms": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "Consent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "contact",
          "text",
          "version",
          "granted_by"
        ],
        "properties": {
          "contact": {
            "type": "boolean",
            "const": true,
            "description": "Must be true. The business owner consents to be contacted about this inquiry."
          },
          "text": {
            "type": "string",
            "description": "The exact consent wording presented to and accepted by the business owner. Current site wording: I agree to be contacted about my financing inquiry by Termbird or its representatives."
          },
          "version": {
            "type": "string",
            "description": "Consent text version. Current site version: 2026-10-draft-1"
          },
          "granted_by": {
            "type": "string",
            "enum": [
              "business_owner"
            ],
            "description": "Must be 'business_owner'. The agent must not grant consent itself."
          },
          "given_at": {
            "type": "string",
            "format": "date-time"
          },
          "privacy_policy_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "URL of the published privacy policy when one exists; null until it is set."
          }
        }
      },
      "InquiryAccepted": {
        "type": "object",
        "required": [
          "ok",
          "reference_id"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "reference_id": {
            "type": "string"
          },
          "forwarded": {
            "type": "boolean",
            "description": "True when the inquiry was forwarded to LEAD_WEBHOOK_URL. False when that environment variable is not set."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "details": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "FitCheck": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "disclaimer": {
            "type": "string"
          },
          "lender_network": {
            "type": "string"
          },
          "products": {
            "type": "object"
          },
          "criteria": {
            "type": "object"
          },
          "note": {
            "type": "string"
          },
          "inquiry": {
            "type": "object"
          }
        }
      },
      "Debts": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "none",
          "items",
          "approximate"
        ],
        "properties": {
          "none": {
            "type": "boolean",
            "description": "True if the business has no existing business debts."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DebtItem"
            },
            "description": "Approximate debts. Required when none is false. Leave empty when none is true."
          },
          "notes": {
            "type": "string",
            "maxLength": 500,
            "description": "Optional free text. Still treated as approximate."
          },
          "approximate": {
            "type": "boolean",
            "const": true,
            "description": "Figures are approximate; Termbird verifies them later."
          }
        }
      },
      "DebtItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "lender_or_type"
        ],
        "properties": {
          "lender_or_type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "approx_balance": {
            "type": "string",
            "maxLength": 40
          },
          "approx_monthly_payment": {
            "type": "string",
            "maxLength": 40
          }
        }
      },
      "OtherOwners": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "none",
          "items"
        ],
        "properties": {
          "none": {
            "type": "boolean",
            "description": "True if there are no other owners with more than a 20% stake."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OwnerItem"
            }
          }
        }
      },
      "OwnerItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "ownership_percent",
          "citizenship"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "ownership_percent": {
            "type": "number",
            "minimum": 20,
            "maximum": 100,
            "description": "Ownership stake greater than 20 percent."
          },
          "citizenship": {
            "type": "string",
            "enum": [
              "us_citizen",
              "permanent_resident",
              "other_or_not_sure"
            ],
            "description": "Citizenship or residency of this owner. Asked because of SBA eligibility rules. Do not infer it."
          }
        }
      }
    }
  }
}
