# POST /api/v1/transactions/bulk-upload/preview

> Preview bulk transaction upload

- **Tag:** transactions
- **Operation ID:** `preview_bulk_transaction_upload_api_v1_transactions_bulk_upload_preview_post`

## Description

Preview and validate a CSV/Excel file before uploading transactions.

This endpoint allows you to:
- Validate the file format and structure
- See how many transactions will be uploaded
- Preview sample transactions
- Check for duplicate transactions (optional)
- Apply date range filtering

**Supported File Formats:** .csv, .xlsx, .xls

**Returns:** Validation results, statistics, and sample transactions without actually uploading.

## Authentication

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

## Request body

Schema: `BulkTransactionUploadPreviewRequest`

- `s3_key` (string · required) — S3 key of the CSV file containing transactions
- `start_date` (string · date) — Optional: Only preview transactions on or after this date (YYYY-MM-DD).
- `end_date` (string · date) — Optional: Only preview transactions on or before this date (YYYY-MM-DD).
- `check_duplicates` (boolean) — If true, checks for duplicate transactions against existing database records.
- `ledger_id` (string) — Optional: Ledger ID to check duplicates against. If not provided, checks all ledgers for the business.
- `financial_account_type` (string) — Financial account type selected for a new ledger. Used by preview to show the same signed amount DayZero will store after import.
- `column_mapping` (object) — User-supplied mapping from DayZero field names to CSV column names. Keys: 'date', 'amount', 'description', and optional 'category' (aliases: ledger, ledger_name, account, account_name, category_name). Values: the CSV header to use. When provided, auto-detection is skipped.

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_BulkTransactionUploadPreviewResponse_`

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

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/transactions/bulk-upload/preview' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "s3_key": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/transactions/bulk-upload/preview', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "s3_key": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "s3_key": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/transactions/bulk-upload/preview", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/transactions/preview-bulk-transaction-upload
- OpenAPI slice: https://www.ondayzero.com/docs/reference/transactions/preview-bulk-transaction-upload/openapi.json
- Other endpoints in **transactions**: https://www.ondayzero.com/docs/reference/transactions
