# Schedule a report

`PUT /businesses/{bid}/report-schedules/{report}`

Requires the `businesses` scope.

Create or replace one report's schedule. Saving never mails a backlog: the period already closed counts as sent. `movein` needs the MOVEIN settings saved first; `pcn874` is not for a עוסק פטור or a yearly frequency. Owner only.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |
| `report` | string | **required** |  One of: `workbook`, `full`, `profit`, `incomes`, `expenses`, `receivables`, `months`, `parties`, `documents_zip`, `movein`, `documents_csv`, `pcn874`. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `emails` | array of string | **required** |  |
| `frequency` | string |  | Default: this dealer type's. One of: `monthly`, `bimonthly`, `yearly`. |
| `sendOnDay` | integer |  | Day of the month AFTER the period, 1..28. Default 1. |
| `active` | boolean |  | Default true; false pauses without losing the settings. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `schedule` | object | **required** |  |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X PUT "$BASE/businesses/$BID/report-schedules/{report}" \
  -H "X-Api-Key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "emails": []
  }'
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/report-schedules/{report}`, {
  method: 'PUT',
  headers: {
    'X-Api-Key': KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "emails": []
  }),
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.put(
    f"{BASE}/businesses/{BID}/report-schedules/{report}",
    headers={"X-Api-Key": KEY},
    json={
      "emails": []
    },
)
data = res.json()
```