{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/sandbox/advance","version":"1.0.0","description":"Move the sandbox clock"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/sandbox/advance":{"post":{"tags":["credit"],"summary":"Move the sandbox clock","description":"Sandbox only. Runs the daily sweep as of `to`, which catches up every accrual day and closes every period that ended. Statements are not emailed.","operationId":"advance_sandbox","parameters":[{"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/SandboxAdvanceRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_SandboxAdvanceResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"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"}}}},"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":"advance_sandbox_api_v1_credit_sandbox_advance_post"}}},"components":{"schemas":{"AccrualRunLineResult":{"properties":{"credit_line_id":{"type":"string","title":"Credit Line Id"},"through":{"type":"string","format":"date","title":"Through"},"loans_considered":{"type":"integer","title":"Loans Considered","default":0},"loans_accrued":{"type":"integer","title":"Loans Accrued","default":0},"days_accrued":{"type":"integer","title":"Days Accrued","default":0},"interest_cents":{"type":"integer","title":"Interest Cents","default":0},"marked_past_due":{"type":"integer","title":"Marked Past Due","default":0},"due_soon_notified":{"type":"integer","title":"Due Soon Notified","default":0},"items":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Items"}},"type":"object","required":["credit_line_id","through"],"title":"AccrualRunLineResult"},"AccrualRunResponse":{"properties":{"through":{"type":"string","format":"date","title":"Through"},"lines":{"type":"integer","title":"Lines","default":0},"loans_accrued":{"type":"integer","title":"Loans Accrued","default":0},"days_accrued":{"type":"integer","title":"Days Accrued","default":0},"interest_cents":{"type":"integer","title":"Interest Cents","default":0},"marked_past_due":{"type":"integer","title":"Marked Past Due","default":0},"due_soon_notified":{"type":"integer","title":"Due Soon Notified","default":0},"results":{"items":{"$ref":"#/components/schemas/AccrualRunLineResult"},"type":"array","title":"Results"}},"type":"object","required":["through"],"title":"AccrualRunResponse"},"AdverseActionSweepResult":{"properties":{"pending":{"type":"integer","title":"Pending","description":"Notices pending.","default":0},"due_soon":{"type":"integer","title":"Due Soon","description":"Due within five days.","default":0},"overdue":{"type":"integer","title":"Overdue","description":"Past their due date.","default":0},"alerted":{"type":"integer","title":"Alerted","description":"Notices alerted on (due soon or overdue); a rerun is deduplicated.","default":0}},"type":"object","title":"AdverseActionSweepResult","description":"What the sweep's adverse-action step found."},"BankMatchRunSummary":{"properties":{"enabled":{"type":"boolean","title":"Enabled","description":"False when no program on this business has bank_settlement_matching on.","default":true},"transactions_considered":{"type":"integer","title":"Transactions Considered","default":0},"settled":{"type":"integer","title":"Settled","default":0},"returned":{"type":"integer","title":"Returned","default":0},"ambiguous":{"type":"integer","title":"Ambiguous","default":0},"unmatched_candidates":{"type":"integer","title":"Unmatched Candidates","default":0},"errors":{"items":{"type":"string"},"type":"array","title":"Errors"}},"type":"object","title":"BankMatchRunSummary","description":"What one pass of the bank-settlement matcher did."},"CycleCloseResponse":{"properties":{"closed":{"type":"integer","title":"Closed"},"skipped":{"type":"integer","title":"Skipped"},"dry_run":{"type":"boolean","title":"Dry Run"},"results":{"items":{"$ref":"#/components/schemas/CycleCloseResult"},"type":"array","title":"Results"}},"type":"object","required":["closed","skipped","dry_run"],"title":"CycleCloseResponse","description":"Result of a close sweep."},"CycleCloseResult":{"properties":{"cycle_id":{"type":"string","title":"Cycle Id"},"credit_line_id":{"type":"string","title":"Credit Line Id"},"period_start":{"type":"string","format":"date","title":"Period Start"},"period_end":{"type":"string","format":"date","title":"Period End"},"closed_on":{"type":"string","format":"date","title":"Closed On"},"due_date":{"type":"string","format":"date","title":"Due Date"},"principal_cents":{"type":"integer","title":"Principal Cents"},"disbursement_fee_cents":{"type":"integer","title":"Disbursement Fee Cents"},"interest_cents":{"type":"integer","title":"Interest Cents"},"amount_due_cents":{"type":"integer","title":"Amount Due Cents"},"settlement_count":{"type":"integer","title":"Settlement Count"},"previous_balance_cents":{"type":"integer","title":"Previous Balance Cents","default":0},"payments_cents":{"type":"integer","title":"Payments Cents","default":0},"statement_balance_cents":{"type":"integer","title":"Statement Balance Cents","default":0},"loan_count":{"type":"integer","title":"Loan Count","default":0},"loan_ids":{"items":{"type":"string"},"type":"array","title":"Loan Ids"}},"type":"object","required":["cycle_id","credit_line_id","period_start","period_end","closed_on","due_date","principal_cents","disbursement_fee_cents","interest_cents","amount_due_cents","settlement_count"],"title":"CycleCloseResult","description":"What one cycle close produced."},"DailySweepResponse":{"properties":{"run_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Run Id","description":"The run's row in `GET /credit/sweeps/runs/{id}`."},"status":{"type":"string","enum":["running","succeeded","partial","failed"],"title":"Status","description":"partial: at least one step failed and the others still ran.","default":"succeeded"},"steps":{"items":{"$ref":"#/components/schemas/SweepStepResult"},"type":"array","title":"Steps"},"bank_settlement":{"anyOf":[{"$ref":"#/components/schemas/BankMatchRunSummary"},{"type":"null"}]},"as_of":{"type":"string","format":"date","title":"As Of"},"fees_recognized":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Fees Recognized"},"interchange":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Interchange"},"bank_balance_snapshots":{"type":"integer","title":"Bank Balance Snapshots","default":0},"settlement_reconciliation":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Settlement Reconciliation"},"statements_emailed":{"type":"integer","title":"Statements Emailed","default":0},"notices_sent":{"type":"integer","title":"Notices Sent","description":"Borrower notices emailed from the event feed.","default":0},"adverse_actions":{"anyOf":[{"$ref":"#/components/schemas/AdverseActionSweepResult"},{"type":"null"}],"description":"Counts from the adverse-action step; null when it did not run."},"accrual":{"anyOf":[{"$ref":"#/components/schemas/AccrualRunResponse"},{"type":"null"}]},"autopay_due":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Autopay Due","description":"Loans due today on AutoPay lines, with the amount the partner should debit."},"close":{"anyOf":[{"$ref":"#/components/schemas/CycleCloseResponse"},{"type":"null"}]},"spend_limits":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Spend Limits"},"cards_sync":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Cards Sync"},"assessments":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Assessments"},"limit_reviews":{"anyOf":[{"$ref":"#/components/schemas/LimitReviewSweepResult"},{"type":"null"}],"description":"Counts from the limit-review step; null when it did not run."},"ledger_checks":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Ledger Checks"},"readiness":{"items":{"$ref":"#/components/schemas/ReadinessSweepItem"},"type":"array","title":"Readiness","description":"One entry per active program the readiness step evaluated."},"collections":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Collections","description":"Lines whose delinquency stage moved, and what was applied."},"errors":{"items":{"type":"string"},"type":"array","title":"Errors"}},"type":"object","required":["as_of"],"title":"DailySweepResponse"},"LimitReviewSweepResult":{"properties":{"reviewed":{"type":"integer","title":"Reviewed","description":"Lines reviewed this run.","default":0},"proposed":{"type":"integer","title":"Proposed","default":0},"applied":{"type":"integer","title":"Applied","default":0},"no_change":{"type":"integer","title":"No Change","default":0},"not_due":{"type":"integer","title":"Not Due","description":"Lines with a policy already reviewed in this cadence window.","default":0},"expired":{"type":"integer","title":"Expired","description":"Pending limit-change requests that lapsed and were expired.","default":0}},"type":"object","title":"LimitReviewSweepResult","description":"What the nightly sweep's limit-review step did."},"ReadinessSweepItem":{"properties":{"program_id":{"type":"string","title":"Program Id","description":"The program evaluated."},"ready":{"type":"boolean","title":"Ready","description":"No blocking check fails."},"blocking_failures":{"type":"integer","title":"Blocking Failures","description":"Failing checks that stop activation."},"regressions":{"items":{"type":"string"},"type":"array","title":"Regressions","description":"Checks that passed in the previous stored result and fail now."},"result_id":{"type":"string","title":"Result Id","description":"The stored result."}},"type":"object","required":["program_id","ready","blocking_failures","result_id"],"title":"ReadinessSweepItem","description":"What the nightly readiness step found for one active program."},"SandboxAdvanceRequest":{"properties":{"to":{"type":"string","format":"date","title":"To"}},"additionalProperties":false,"type":"object","required":["to"],"title":"SandboxAdvanceRequest"},"SandboxAdvanceResponse":{"properties":{"to":{"type":"string","format":"date","title":"To"},"sweep":{"$ref":"#/components/schemas/DailySweepResponse"}},"type":"object","required":["to","sweep"],"title":"SandboxAdvanceResponse"},"SuccessEnvelope_SandboxAdvanceResponse_":{"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/SandboxAdvanceResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[SandboxAdvanceResponse]"},"SweepStepAttempt":{"properties":{"at":{"type":"string","format":"date-time","title":"At"},"actor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Actor"},"status":{"type":"string","enum":["succeeded","failed","skipped"],"title":"Status"},"counts":{"additionalProperties":true,"type":"object","title":"Counts"},"duration_ms":{"type":"integer","title":"Duration Ms","default":0},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"}},"type":"object","required":["at","status"],"title":"SweepStepAttempt","description":"One operator re-run of a step."},"SweepStepResult":{"properties":{"name":{"type":"string","title":"Name"},"status":{"type":"string","enum":["succeeded","failed","skipped"],"title":"Status"},"counts":{"additionalProperties":true,"type":"object","title":"Counts"},"duration_ms":{"type":"integer","title":"Duration Ms","default":0},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"Why a step was skipped, or what a failed check found."},"reruns":{"items":{"$ref":"#/components/schemas/SweepStepAttempt"},"type":"array","title":"Reruns"}},"type":"object","required":["name","status"],"title":"SweepStepResult","description":"How one step of the sweep went."},"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":[]}]}