# Create a share invite

Canonical page: https://docs.ovok.com/api/patient-sharing/create-a-share-invite

`POST /v1/patient-sharing/invites`

The signed-in patient creates a one-time invite to share Observations with the given codes with another patient. Set `includeMedications` to `true` to also share patient-scoped MedicationStatements and MedicationAdministrations. Hand the `inviteId` and `code` to the other patient, who accepts with `POST /v1/patient-sharing/invites/redeem`.

**Auth:** bearer token of a Patient.
**Scope:** the caller's project (from the token).

## Behaviour

- Patient sharing must be on for the project (`PUT /v1/patient-sharing/settings`).
- `codes`: 1 to 100 Observation codes, each 1 to 64 letters, digits, `.` or `-`. Duplicates are removed.
- `includeMedications`: optional, defaults to `false`. When true, the recipient can read the sharer's MedicationStatements and MedicationAdministrations until the share ends.
- `endsAt` must be `null`: a share lasts until it is ended. A date is refused for now.
- The invite is stored as a draft `Consent`. Only a SHA-256 hash of `code` is stored, so `code` is returned once, in this response.
- The invite expires 15 minutes after it is created (`expiresAt`).
- A patient can hold at most 10 unexpired invites at once.
- A 429 means the patient already holds 10 unexpired invites.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/patient-sharing/invites' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "codes": ["8480-6", "8462-4"], "endsAt": null, "includeMedications": true }'
```
