# A link that adds the appointment to the customer's calendar

`POST /businesses/{bid}/appointments/{id}/invite`

Requires the `businesses` scope.

Answers a signed path (`/cal/<token>.ics`) to send the customer. Opened, it returns the appointment as an .ics file, which a phone offers to add to its own calendar. The event is read when the link is opened, so a moved visit opens at its new hour and a cancelled one as cancelled. The token carries only the appointment id and a signature.

## Path parameters

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

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `token` | string | **required** | The signed token. |
| `path` | string |  | The path to send, on this API's host: `/cal/<token>.ics`. |

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 POST "$BASE/businesses/$BID/appointments/$DOC_ID/invite" \
  -H "X-Api-Key: $KEY"
```
### Node

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

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