{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/underwriting/assessments/{assessment_id}/completion","version":"1.0.0","description":"Complete an underwriting assessment"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/underwriting/assessments/{assessment_id}/completion":{"post":{"tags":["credit"],"summary":"Complete an underwriting assessment","description":"Scores measured figures against the program's criteria set and closes the assessment. Returns per-criterion value, threshold, pass or fail, and source, plus roll-up counts and a weighted score. A criterion we could not measure comes back `passed: null` rather than false — those call for opposite actions. No recommendation is returned at any point.","operationId":"complete_underwriting_assessment_api_v1_credit_underwriting_assessments__assessment_id__completion_post","parameters":[{"name":"assessment_id","in":"path","required":true,"schema":{"type":"string","title":"Assessment Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnderwritingCompletionRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_UnderwritingAssessmentResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AssessmentStatusEnum":{"type":"string","enum":["pending","completed","failed"],"title":"AssessmentStatusEnum","description":"Underwriting assessment lifecycle.\n\nPlaid backfill, categorisation, and trailing-ratio history can take up\nto three days (FRD §9.3), so an assessment is explicitly asynchronous."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"SuccessEnvelope_UnderwritingAssessmentResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/UnderwritingAssessmentResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[UnderwritingAssessmentResponse]"},"UnderwritingAssessmentResponse":{"properties":{"id":{"type":"string","title":"Id"},"credit_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Credit Line Id"},"external_application_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Application Id"},"status":{"$ref":"#/components/schemas/AssessmentStatusEnum"},"requested_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Requested At"},"completed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Completed At"},"criteria":{"items":{"$ref":"#/components/schemas/UnderwritingCriterionResult"},"type":"array","title":"Criteria"},"financials":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Financials"},"failure_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Failure Reason"},"decision":{"type":"null","title":"Decision","description":"Always null. The lending decision is the partner's (§9.3)."}},"type":"object","required":["id","status"],"title":"UnderwritingAssessmentResponse","description":"Assessment evidence — criteria, values, thresholds, and sources."},"UnderwritingCompletionRequest":{"properties":{"measured_values":{"additionalProperties":{"type":"number"},"type":"object","title":"Measured Values","description":"Criterion key to measured figure."},"financials":{"additionalProperties":true,"type":"object","title":"Financials","description":"Income statement, balance sheet, debt facilities, cash flow."},"evidence":{"anyOf":[{"additionalProperties":{"additionalProperties":true,"type":"object"},"type":"object"},{"type":"null"}],"title":"Evidence","description":"Per-criterion evidence trail."},"segment":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Segment","description":"Merchant segment for threshold overrides."}},"additionalProperties":false,"type":"object","required":["measured_values"],"title":"UnderwritingCompletionRequest","description":"Close out an assessment with measured figures.\n\nCalled by the pipeline once the ledger has enough history. `segment`\nselects per-segment threshold overrides so one criteria set can serve\nseveral merchant tiers."},"UnderwritingCriterionResult":{"properties":{"key":{"type":"string","title":"Key"},"label":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Label"},"value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value"},"threshold":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Threshold"},"comparator":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Comparator"},"passed":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Passed","description":"Null means the figure could not be measured yet — distinct from a failure, and calling for a different action."},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"unit":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unit"},"weight":{"type":"integer","title":"Weight","default":1},"required":{"type":"boolean","title":"Required","default":false},"evidence":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Evidence"}},"type":"object","required":["key"],"title":"UnderwritingCriterionResult","description":"One criterion, its value, its threshold, and where the figure came from.\n\nWe supply the assessment, not the verdict: thresholds and the lending\ndecision remain the partner's (§9.3)."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}