# Turn the calendar on or off and save its settings

`PUT /businesses/{bid}/calendar`

Requires the `businesses` scope.

The owner's alone (a shared or connected credential gets 404). The first time it is turned on stamps `setupAt`. Turning it off hides the calendar and deletes nothing.

## Path parameters

| Name | Type | | Description |
|---|---|---|---|
| `bid` | string | **required** | Business id, from `POST /businesses`. |

## Body

| Field | Type | | Description |
|---|---|---|---|
| `enabled` | boolean |  | Turn the calendar on or off. Turning it off hides it; nothing is deleted. |
| `locations` | array of string |  |  |
| `defaultMinutes` | integer |  | 5..720 |
| `hours` | object |  | As on Calendar; null resets to the default week (Sunday-Thursday 09:00-18:00, Friday until 13:00). |
| `billing` | string |  |  One of: `per_visit`, `package`, `quote_first`. |
| `teamIntent` | object |  |  |
| `teamIntent.solo` | boolean |  |  |
| `teamIntent.people` | integer |  | 1..100 when not solo |
| `feedDetail` | string |  |  One of: `full`, `minimal`. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `calendar` | Calendar | **required** | The calendar's switch and the answers its owner gave when turning it on. A business that never turned it on reads as these defaults with `enabled: false`. |

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/calendar" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/businesses/${BID}/calendar`, {
  method: 'PUT',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

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