# Accept a share invite

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

`POST /v1/patient-sharing/invites/redeem`

The signed-in patient accepts another patient's share invite, and from then on can read what it shares.

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

## Behaviour

- Patient sharing must be on for the project.
- The invite is single use, expires 15 minutes after it was created, and cannot be accepted by the patient who made it.
- On success the invite's `Consent` becomes `active` and names the caller as recipient, and a grant is added to the caller's membership, in one atomic write. The caller's cached sessions are refreshed, so the new access applies on the next request.
- The grant lets the caller read and search the sharer's Observations with the shared codes, and read the sharer's Patient resource with contact details, identifiers and most other fields hidden.
- A share also grants a multi-value reading's group Observation when it covers every value the group repeats (systolic and diastolic for blood pressure, the waveform for an ECG, any part of an SpO2 or urine-strip reading), so the whole reading can be read and nothing more. The share's `codes` stay as the sharer chose them.
- A 409 that says your account changed meanwhile can be retried as is.
- A 503 means sharing is on but its template AccessPolicy is missing.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/patient-sharing/invites/redeem' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{
    "inviteId": "c3499c27-2973-0a7f-807e-fb8676a92dcb",
    "code": "<code from the invite>"
  }'
```
