# POST /api/v1/books-audit/run-live

> Run a live Books Health & Leak Audit against the active business's synced ledger

- **Tag:** books-audit
- **Operation ID:** `run_live_books_audit`

## Description

Scan synced GL accounts and 90-day transactions and persist a shareable Books Audit.

## Authentication

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

## Request body

Schema: `BooksAuditLiveRunRequest`

- `provider` (string) (one of: qbo, xero, shopify, live_ledger)
- `referral_code` (string)

## Responses

### 201 — Successful Response

Schema: `BooksAuditPublicResponse`

- `share_token` (string · required)
- `share_url` (string · required)
- `badge_svg_url` (string · required)
- `company_name` (string · required)
- `source_type` (string · required)
- `country` (string · required)
- `currency` (string · required)
- `overall_grade` (string · required)
- `health_score` (integer · required)
- `estimated_leak_cents` (integer · required)
- `estimated_close_days` (integer · required)
- `dayzero_target_close_days` (integer)
- `findings` (array · BooksAuditFinding · required) → `BooksAuditFinding`
  - `category` (string · required) (one of: uncategorized_spend, duplicate_saas, coa_bloat, cogs_misclassification, nexus_exposure, close_velocity)
  - `severity` (string · required) (one of: critical, high, medium, low)
  - `title` (string · required)
  - `detail` (string · required)
  - `estimated_impact_cents` (integer)
  - `recommended_fix` (string · required)
- `summary_metrics` (object · required)
- `referral_code` (string)
- `created_at` (string · date-time)

### 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/books-audit/run-live' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "provider": "qbo",
  "referral_code": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/books-audit/run-live', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "provider": "qbo",
  "referral_code": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'provider': 'qbo', 'referral_code': 'string'}

response = httpx.post("https://api.ondayzero.com/api/v1/books-audit/run-live", headers=headers, json=payload)
data = response.json()
```

## See also

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