# POST /api/v1/credit/sweeps/daily

> Run the daily credit sweep

- **Tag:** credit
- **Operation ID:** `run_daily_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`).

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `DailySweepRequest`

- `as_of` (string · date)
- `accrue` (boolean)
- `close_periods` (boolean)
- `push_spend_limits` (boolean)
- `sync_cards` (boolean)
- `reconcile_settlements` (boolean)
- `recognize_fees` (boolean)
- `recognize_interchange` (boolean)
- `snapshot_bank_balances` (boolean)
- `email_statements` (boolean)
- `send_notices` (boolean) — Email the borrower notices each program has switched on, for the credit events since the last run.
- `run_assessments` (boolean)
- `alert_adverse_actions` (boolean) — List pending adverse-action notices and alert on those due within five days or overdue. Nothing is sent.
- `review_limits` (boolean) — 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.
- `verify_ledgers` (boolean)
- `check_covenants` (boolean) — 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.
- `evaluate_readiness` (boolean) — 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.
- `run_collections` (boolean) — 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.
- `match_bank_settlements` (boolean) — Settle pending payments, and reverse returned ones, from the bank feed of the last 16 days, on programs with `bank_settlement_matching` on.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_DailySweepResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (DailySweepResponse)

### 400 — Bad Request - Invalid input

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/credit/sweeps/daily' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "as_of": "2026-01-01",
  "accrue": false,
  "close_periods": false,
  "push_spend_limits": false,
  "sync_cards": false,
  "reconcile_settlements": false
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/credit/sweeps/daily', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "as_of": "2026-01-01",
  "accrue": false,
  "close_periods": false,
  "push_spend_limits": false,
  "sync_cards": false,
  "reconcile_settlements": false
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {'as_of': '2026-01-01',
 'accrue': False,
 'close_periods': False,
 'push_spend_limits': False,
 'sync_cards': False,
 'reconcile_settlements': False}

response = httpx.post("https://api.ondayzero.com/api/v1/credit/sweeps/daily", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/credit/run-daily-sweep
- OpenAPI slice: https://www.ondayzero.com/docs/reference/credit/run-daily-sweep/openapi.json
- Other endpoints in **credit**: https://www.ondayzero.com/docs/reference/credit (markdown bundle: https://www.ondayzero.com/docs/reference/credit.md, OpenAPI: https://www.ondayzero.com/docs/reference/credit/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
