{"openapi":"3.1.0","info":{"title":"Greenfield AI · Realty API","version":"0.1.0","description":"Public REST API for the Realty product. Every admin-UI mutation has a matching API endpoint. Authenticate with a bearer API key minted in the platform admin."},"servers":[{"url":"/v1","description":"this server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"gfa_*"}},"schemas":{"Error":{"type":"object","required":["error","code"],"properties":{"error":{"type":"string"},"code":{"type":"integer"},"issues":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}}}}}},"LeadIn":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string","format":"email"},"country":{"type":"string","minLength":2,"maxLength":2},"source":{"type":"string","enum":["website","whatsapp","referral","agent","facebook","google","walk_in","import","api","other"],"default":"api"},"notes":{"type":"string"},"project_slug":{"type":"string"},"utm_json":{"type":"object"},"external_ref":{"type":"string"}}},"LeadOut":{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"email":{"type":"string","nullable":true},"source":{"type":"string"},"stage":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}},"PaymentIn":{"type":"object","required":["loan_id","amount","received_at"],"properties":{"loan_id":{"type":"string","format":"uuid"},"amount":{"type":"string","description":"Decimal amount as string, e.g. \"500.00\"."},"method":{"type":"string","enum":["cash","bank_transfer","card","check","crypto","fx_remittance"],"default":"bank_transfer"},"received_at":{"type":"string","format":"date"},"reference":{"type":"string"},"bank_statement_row_id":{"type":"string","format":"uuid"}}}}},"paths":{"/leads":{"post":{"summary":"Create a lead.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadIn"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadOut"}}}},"401":{"description":"Auth.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Validation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"summary":"List leads.","parameters":[{"in":"query","name":"limit","schema":{"type":"integer","maximum":500}},{"in":"query","name":"stage","schema":{"type":"string"}}],"responses":{"200":{"description":"OK."}}}},"/lots":{"get":{"summary":"List lots.","responses":{"200":{"description":"OK."}}},"post":{"summary":"Create a lot.","responses":{"201":{"description":"Created."}}}},"/loans":{"get":{"summary":"List loans.","responses":{"200":{"description":"OK."}}}},"/loans/{loanId}/schedule":{"get":{"summary":"Loan amortization schedule.","parameters":[{"in":"path","name":"loanId","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"OK."}}}},"/payments":{"post":{"summary":"Record and allocate a payment.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentIn"}}}},"responses":{"201":{"description":"Created and allocated."}}}}}}