# POST /api/v1/month-end-packages

> Queue a month-end package build

- **Tag:** month-end-packages
- **Operation ID:** `create_package_api_v1_month_end_packages_post`

## Description

Persist a queued package row and start the Temporal build workflow.

## Authentication

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

## Request body

Schema: `MonthEndPackageCreateRequest`

- `accounting_period_id` (string) — Optional accounting period UUID. If omitted, ``period_start`` and ``period_end`` are used directly.
- `period_start` (string · date) — Required if ``accounting_period_id`` is not provided.
- `period_end` (string · date) — Required if ``accounting_period_id`` is not provided.
- `report_format` (MonthEndPackageFormatEnum) → `MonthEndPackageFormatEnum` — Per-report format inside the zip (``pdf`` or ``xlsx``).
- `selected_reports` (array · string · required) — Report keys to include in the package. Supported values: pl, balance_sheet, cash_flow, ar_aging, ap_aging, budget_vs_actual, bank_reconciliation.

## Responses

### 201 — Successful Response

Schema: `MonthEndPackageQueuedResponse`

- `package` (MonthEndPackageResponse · required) → `MonthEndPackageResponse` — The freshly created package record
  - `id` (string · required) — Month-end package UUID
  - `business_id` (string · required) — Owning business UUID
  - `accounting_period_id` (string) — Linked accounting period UUID, if any
  - `period_start` (string · date-time · required) — Start of the covered period
  - `period_end` (string · date-time · required) — End of the covered period
  - `status` (MonthEndPackageStatusEnum · required) → `MonthEndPackageStatusEnum` — Build status: queued, in_progress, ready, or failed
  - `report_format` (MonthEndPackageFormatEnum · required) → `MonthEndPackageFormatEnum` — Per-report format inside the zip
  - `selected_reports` (array · string) — Report keys included in the package
  - `workflow_id` (string) — Temporal workflow id driving the build
  - `file_size_bytes` (integer) — Final zip size in bytes (set when ready)
  - `filename` (string) — Suggested attachment filename for the zip download
  - `error_message` (string) — Failure reason when ``status == 'failed'``
  - `requested_by_user_id` (string) — User who requested the package
  - `started_at` (string · date-time) — When the build started
  - `ready_at` (string · date-time) — When the package became downloadable
  - `created_at` (string · date-time · required) — Creation timestamp
  - `updated_at` (string · date-time · required) — Last update timestamp
- `workflow_id` (string) — Temporal workflow id (also on ``package``)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 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/month-end-packages' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "selected_reports": []
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/month-end-packages', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "selected_reports": []
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {
  "selected_reports": []
}

response = httpx.post("https://api.ondayzero.com/api/v1/month-end-packages", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/month-end-packages/create-package
- OpenAPI slice: https://www.ondayzero.com/docs/reference/month-end-packages/create-package/openapi.json
- Other endpoints in **month-end-packages**: https://www.ondayzero.com/docs/reference/month-end-packages
