{"openapi":"3.1.0","info":{"title":"GET /api/v1/credit/scorecard-versions/{version_id}/backtests","version":"1.0.0","description":"List a version's backtests"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/scorecard-versions/{version_id}/backtests":{"get":{"tags":["credit"],"summary":"List a version's backtests","description":"Recent backtests, newest first, with summaries but not per-business rows.","operationId":"list_scorecard_backtests","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cursor"}},{"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"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_ScorecardBacktestPage_"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"list_scorecard_backtests_api_v1_credit_scorecard_versions__version_id__backtests_get"}}},"components":{"schemas":{"BacktestBusinessResult":{"properties":{"score_bps":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Score Bps"},"grade":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Grade"},"passed_count":{"type":"integer","title":"Passed Count","default":0},"failed_count":{"type":"integer","title":"Failed Count","default":0},"unmeasured_count":{"type":"integer","title":"Unmeasured Count","default":0},"not_applicable_count":{"type":"integer","title":"Not Applicable Count","default":0},"points_available":{"type":"integer","title":"Points Available","default":0},"required_failed":{"items":{"type":"string"},"type":"array","title":"Required Failed"},"criteria":{"items":{"$ref":"#/components/schemas/BacktestCriterionOutcome"},"type":"array","title":"Criteria"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"business_id":{"type":"string","title":"Business Id"},"business_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Business Name"},"requested_limit_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Requested Limit Cents"},"limit_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Limit Source","description":"fixed, line_limit, per_business, last_assessment or none."},"compare":{"anyOf":[{"$ref":"#/components/schemas/BacktestVersionResult"},{"type":"null"}],"description":"The same business under `compare_version_id`."},"outcome_changed":{"type":"boolean","title":"Outcome Changed","description":"The two versions disagree about this business.","default":false},"changes":{"items":{"type":"string"},"type":"array","title":"Changes","description":"What differs, in words."}},"type":"object","required":["business_id"],"title":"BacktestBusinessResult"},"BacktestCriterionOutcome":{"properties":{"id":{"type":"string","title":"Id"},"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"},{"items":{"type":"number"},"type":"array"},{"type":"null"}],"title":"Threshold"},"comparator":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Comparator"},"unit":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unit"},"weight":{"type":"integer","title":"Weight","default":1},"passed":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Passed"},"required":{"type":"boolean","title":"Required","default":false},"applicable":{"type":"boolean","title":"Applicable","default":true},"unmeasured_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unmeasured Reason"}},"type":"object","required":["id","key"],"title":"BacktestCriterionOutcome","description":"A criterion's result for one business, without the evidence trail."},"BacktestCriterionSummary":{"properties":{"id":{"type":"string","title":"Id"},"key":{"type":"string","title":"Key"},"label":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Label"},"passed":{"type":"integer","title":"Passed","default":0},"failed":{"type":"integer","title":"Failed","default":0},"required_failed":{"type":"integer","title":"Required Failed","default":0},"unmeasured":{"type":"integer","title":"Unmeasured","default":0},"not_applicable":{"type":"integer","title":"Not Applicable","default":0},"unmeasured_reasons":{"additionalProperties":{"type":"integer"},"type":"object","title":"Unmeasured Reasons"}},"type":"object","required":["id","key"],"title":"BacktestCriterionSummary"},"BacktestGradeCount":{"properties":{"label":{"type":"string","title":"Label"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["label","count"],"title":"BacktestGradeCount"},"BacktestScoreBucket":{"properties":{"from_bps":{"type":"integer","title":"From Bps"},"to_bps":{"type":"integer","title":"To Bps"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["from_bps","to_bps","count"],"title":"BacktestScoreBucket"},"BacktestSummary":{"properties":{"businesses":{"type":"integer","title":"Businesses","default":0},"evaluated":{"type":"integer","title":"Evaluated","default":0},"errored":{"type":"integer","title":"Errored","default":0},"unscored":{"type":"integer","title":"Unscored","description":"Evaluated, but nothing counted toward a score.","default":0},"with_required_failed":{"type":"integer","title":"With Required Failed","default":0},"criteria":{"items":{"$ref":"#/components/schemas/BacktestCriterionSummary"},"type":"array","title":"Criteria"},"score_distribution":{"items":{"$ref":"#/components/schemas/BacktestScoreBucket"},"type":"array","title":"Score Distribution"},"grade_mix":{"items":{"$ref":"#/components/schemas/BacktestGradeCount"},"type":"array","title":"Grade Mix"},"changed_outcomes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Changed Outcomes","description":"Businesses the two versions disagree on. Null without a comparison."},"compare":{"anyOf":[{"$ref":"#/components/schemas/BacktestSummary"},{"type":"null"}]}},"type":"object","title":"BacktestSummary"},"BacktestVersionResult":{"properties":{"score_bps":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Score Bps"},"grade":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Grade"},"passed_count":{"type":"integer","title":"Passed Count","default":0},"failed_count":{"type":"integer","title":"Failed Count","default":0},"unmeasured_count":{"type":"integer","title":"Unmeasured Count","default":0},"not_applicable_count":{"type":"integer","title":"Not Applicable Count","default":0},"points_available":{"type":"integer","title":"Points Available","default":0},"required_failed":{"items":{"type":"string"},"type":"array","title":"Required Failed"},"criteria":{"items":{"$ref":"#/components/schemas/BacktestCriterionOutcome"},"type":"array","title":"Criteria"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"}},"type":"object","title":"BacktestVersionResult","description":"One business under one version."},"ScorecardBacktestPage":{"properties":{"next_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Cursor","description":"Pass back as `cursor` for the next page. Null on the last."},"has_next":{"type":"boolean","title":"Has Next","description":"Another page follows. Looked up one row past the page, so a full last page is not reported as more.","default":false},"limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Limit","description":"The page size the list was read with."},"total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total","description":"Row count; present only with `include_total_count=true`."},"items":{"items":{"$ref":"#/components/schemas/ScorecardBacktestResponse"},"type":"array","title":"Items"}},"type":"object","title":"ScorecardBacktestPage"},"ScorecardBacktestResponse":{"properties":{"id":{"type":"string","title":"Id"},"version_id":{"type":"string","title":"Version Id"},"version_number":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Version Number"},"compare_version_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Compare Version Id"},"compare_version_number":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Compare Version Number"},"status":{"type":"string","enum":["queued","running","completed","failed"],"title":"Status"},"progress_done":{"type":"integer","title":"Progress Done","default":0},"progress_total":{"type":"integer","title":"Progress Total","default":0},"params":{"additionalProperties":true,"type":"object","title":"Params"},"summary":{"anyOf":[{"$ref":"#/components/schemas/BacktestSummary"},{"type":"null"}]},"results":{"items":{"$ref":"#/components/schemas/BacktestBusinessResult"},"type":"array","title":"Results","description":"Per business. Omitted from list responses."},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"requested_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Requested By"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"started_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Started At"},"completed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Completed At"}},"type":"object","required":["id","version_id","status"],"title":"ScorecardBacktestResponse","description":"A backtest job. Poll until `status` is completed or failed."},"SuccessEnvelope_ScorecardBacktestPage_":{"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/ScorecardBacktestPage"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[ScorecardBacktestPage]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}