{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/sweeps/daily","version":"1.0.0","description":"Run the daily credit sweep"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/sweeps/daily":{"post":{"tags":["credit"],"summary":"Run the daily credit sweep","description":"DayZero internal; the nightly schedule runs this per business. Runs every step of the nightly sweep in order (the steps are listed under What runs on DayZero's schedule in the guide, and each run's `steps` names them). Each step that fails is recorded and the rest still run (`status: partial`); the run is logged under `GET /credit/sweeps/runs/{run_id}`. Open to any token on a sandbox business; on a live business an operator action (an API token receives `403`).","operationId":"run_daily_sweep","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/DailySweepRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_DailySweepResponse_"}}}},"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":"run_daily_sweep_api_v1_credit_sweeps_daily_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."},"DailySweepRequest":{"properties":{"as_of":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"As Of"},"accrue":{"type":"boolean","title":"Accrue","default":true},"close_periods":{"type":"boolean","title":"Close Periods","default":true},"push_spend_limits":{"type":"boolean","title":"Push Spend Limits","default":true},"sync_cards":{"type":"boolean","title":"Sync Cards","default":false},"reconcile_settlements":{"type":"boolean","title":"Reconcile Settlements","default":true},"recognize_fees":{"type":"boolean","title":"Recognize Fees","default":true},"recognize_interchange":{"type":"boolean","title":"Recognize Interchange","default":true},"snapshot_bank_balances":{"type":"boolean","title":"Snapshot Bank Balances","default":true},"email_statements":{"type":"boolean","title":"Email Statements","default":true},"send_notices":{"type":"boolean","title":"Send Notices","description":"Email the borrower notices each program has switched on, for the credit events since the last run.","default":true},"run_assessments":{"type":"boolean","title":"Run Assessments","default":true},"alert_adverse_actions":{"type":"boolean","title":"Alert Adverse Actions","description":"List pending adverse-action notices and alert on those due within five days or overdue. Nothing is sent.","default":true},"review_limits":{"type":"boolean","title":"Review Limits","description":"Review the limit of every line whose program has an enabled limit_review_policy and that has not been reviewed in the current cadence window.","default":true},"verify_ledgers":{"type":"boolean","title":"Verify Ledgers","default":true},"check_covenants":{"type":"boolean","title":"Check Covenants","description":"Test every active covenant on every line against the borrower's books, record the night's checks, emit covenant events and file a limit-review proposal on a third consecutive breach. Never changes a limit.","default":true},"evaluate_readiness":{"type":"boolean","title":"Evaluate Readiness","description":"Evaluate every active program's launch readiness, store the result, and alert when a check that passed in the previous stored result fails now. Skipped on a sandbox.","default":true},"run_collections":{"type":"boolean","title":"Run Collections","description":"Evaluate the program's delinquency ladder and apply the stage a line has reached (D-31). Actions are reversible; write-off stays an operator decision.","default":true},"match_bank_settlements":{"type":"boolean","title":"Match Bank Settlements","description":"Settle pending payments, and reverse returned ones, from the bank feed of the last 16 days, on programs with `bank_settlement_matching` on.","default":true}},"additionalProperties":false,"type":"object","title":"DailySweepRequest","description":"Everything DayZero runs on its own schedule, in dependency order.\n\nAccrual and past-due first, then month-end close for any period that\nhas ended, then the issuer spend-limit push and card reconciliation,\nthen pending underwriting measurement, then ledger verification."},"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."},"SuccessEnvelope_DailySweepResponse_":{"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/DailySweepResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[DailySweepResponse]"},"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":[]}]}