{"openapi":"3.1.0","info":{"title":"CapLens Sponsor Portfolio API","version":"2026-07-04","summary":"Load existing CRE debt portfolios and convert assets into monitored capital records.","description":"Use the Sponsor Portfolio API to validate, import, and update existing debt books from BI tools, spreadsheets, data warehouses, and sponsor systems of record."},"servers":[{"url":"https://app.caplens.io","description":"Production app"}],"tags":[{"name":"Sponsor Portfolio","description":"Validate and upsert existing sponsor assets, loans, maturities, lenders, and refinance context."},{"name":"API Keys","description":"Create and revoke organization-scoped sponsor API keys from an authenticated CapLens session."},{"name":"Capital Workflow","description":"Launch refinance and lender appetite workflows from imported portfolio records."}],"components":{"securitySchemes":{"SponsorApiKey":{"type":"http","scheme":"bearer","bearerFormat":"caplens_sk","description":"Organization-scoped sponsor API key created in CapLens."},"CapLensSession":{"type":"apiKey","in":"cookie","name":"sb-access-token","description":"Authenticated CapLens browser session."}},"schemas":{"SponsorPortfolioImportRequest":{"type":"object","required":["assets"],"properties":{"dryRun":{"type":"boolean","default":true,"description":"When true, validates rows without saving an import batch or creating records."},"createRecords":{"type":"boolean","default":false,"description":"When true and dryRun is false, creates or updates monitored capital records."},"sourceSystem":{"type":"string","examples":["11Capital BI","Yardi export","Snowflake debt_book"],"description":"External system name. CapLens uses organization + sourceSystem + externalId for delta updates."},"fileName":{"type":"string","examples":["debt-book-export.xlsx"]},"assets":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/SponsorPortfolioAsset"}}}},"SponsorPortfolioAsset":{"type":"object","required":["externalId","propertyName","market","units","sponsorName","currentLoan"],"properties":{"externalId":{"type":"string","description":"Stable external asset id. Reusing the same externalId with the same sourceSystem updates the existing CapLens record.","examples":["11C-SEA-014"]},"propertyName":{"type":"string","examples":["Harbor Ridge Apartments"]},"market":{"type":"string","examples":["Seattle, WA"]},"units":{"type":"integer","examples":[184]},"sponsorName":{"type":"string","examples":["11Capital"]},"rawData":{"type":"object","additionalProperties":true,"description":"Optional untouched source-system payload for auditability."},"currentLoan":{"$ref":"#/components/schemas/CurrentLoan"}}},"CurrentLoan":{"type":"object","required":["lenderName","loanAmount","maturityDate"],"properties":{"lenderName":{"type":"string","examples":["Pacific Crest Bank"]},"lenderType":{"type":"string","examples":["Bank","Life Co","Agency","Debt Fund"]},"lenderContactName":{"type":"string","examples":["Jordan Lee"]},"lenderContactEmail":{"type":"string","format":"email","examples":["jordan@pacificcrest.example"]},"brokerName":{"type":"string","examples":["Chris Capital"]},"brokerCompany":{"type":"string","examples":["Legacy Group Capital"]},"loanAmount":{"type":"number","examples":[21400000]},"interestRate":{"type":"number","examples":[6.18]},"rateType":{"type":"string","examples":["fixed-index-spread","floating-index-spread","all-in"]},"maturityDate":{"type":"string","format":"date","examples":["2027-11-15"]},"extensionNoticeDate":{"type":"string","format":"date","examples":["2027-05-15"]},"extensionOptions":{"type":"string","examples":["One 12-month extension at 1.25x DSCR"]},"prepaymentType":{"type":"string","enum":["none","yield-maintenance","defeasance","stepdown","open","other"]},"prepaymentSummary":{"type":"string","examples":["Yield maintenance through 2027; open final 90 days"]},"defeasanceSummary":{"type":"string"},"yieldMaintenanceSummary":{"type":"string"},"depositRequirements":{"type":"string","examples":["Tax, insurance, and replacement reserves"]},"reserveRequirements":{"type":"string"},"recentLenderConversation":{"type":"string"},"noi":{"type":"number","examples":[1825000]},"dscr":{"type":"number","examples":[1.31]},"occupancy":{"type":"number","examples":[94.2]},"debtYield":{"type":"number","examples":[8.5]}}},"SponsorPortfolioImportResponse":{"type":"object","properties":{"status":{"type":"string","examples":["ready_for_mapping","needs_attention","published"]},"mode":{"type":"string","examples":["dry_run","saved_batch","upserted_records"]},"sourceSystem":{"type":"string"},"summary":{"type":"object","properties":{"totalRows":{"type":"integer"},"readyRows":{"type":"integer"},"warningRows":{"type":"integer"},"blockedRows":{"type":"integer"},"createdRecords":{"type":"integer"},"updatedRecords":{"type":"integer"}}},"rows":{"type":"array","items":{"type":"object","properties":{"rowNumber":{"type":"integer"},"status":{"type":"string","enum":["ready","warning","blocked"]},"issues":{"type":"array","items":{"type":"string"}},"warnings":{"type":"array","items":{"type":"string"}},"createdDealId":{"type":"string","format":"uuid"},"importAction":{"type":"string","enum":["created","updated"]}}}}}},"ApiKeyCreateRequest":{"type":"object","properties":{"name":{"type":"string","examples":["11Capital BI nightly push"]},"expiresAt":{"type":"string","format":"date-time","nullable":true}}},"ApiKeyCreateResponse":{"type":"object","properties":{"apiKey":{"type":"object"},"token":{"type":"string","description":"Shown once. Store this token in your integration secret manager.","examples":["caplens_sk_example"]},"tokenPreview":{"type":"string"},"warning":{"type":"string"}}}}},"paths":{"/api/sponsor/portfolio/import":{"post":{"tags":["Sponsor Portfolio"],"summary":"Validate, save, or upsert an existing sponsor debt portfolio","description":"Validates portfolio rows and optionally creates or updates monitored capital records. Delta updates are keyed by organization, sourceSystem, and externalId.","security":[{"SponsorApiKey":[]},{"CapLensSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SponsorPortfolioImportRequest"}}}},"responses":{"200":{"description":"Validation or import result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SponsorPortfolioImportResponse"}}}},"400":{"description":"Invalid JSON or missing assets"},"401":{"description":"Missing or invalid sponsor API key/session"},"403":{"description":"API key missing required scope or organization access"}}}},"/api/sponsor/api-keys":{"get":{"tags":["API Keys"],"summary":"List sponsor API keys for the current organization","security":[{"CapLensSession":[]}],"responses":{"200":{"description":"API key list"},"401":{"description":"Unauthorized"}}},"post":{"tags":["API Keys"],"summary":"Create a sponsor API key","security":[{"CapLensSession":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateRequest"}}}},"responses":{"200":{"description":"One-time token response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreateResponse"}}}}}}},"/api/sponsor/api-keys/{id}":{"delete":{"tags":["API Keys"],"summary":"Revoke a sponsor API key","security":[{"CapLensSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Revoked API key"},"404":{"description":"Not found or already revoked"}}}},"/api/sponsor/portfolio/{id}/start-refinance":{"post":{"tags":["Capital Workflow"],"summary":"Start a refinance workflow from an imported portfolio record","security":[{"CapLensSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Draft refinance deal or existing refinance workflow"}}}},"/api/sponsor/portfolio/{id}/lender-appetite-link":{"post":{"tags":["Capital Workflow"],"summary":"Generate a lender appetite update link from an existing relationship","security":[{"CapLensSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Private lender package URL anchored to the criteria update form"}}}}}}