# Patient messages

> Read the messages your practice has sent to, or received from, its patients.

Source: https://docs.usejump.co.uk/api-reference/messages

* **Two levels of access.** `read_messages` returns a message's metadata. Its subject and body need `read_message_content` as well, because recorded content can contain patient links and personal information. Existing keys don't gain either scope automatically.
  * **Patient messages only.** A message is included when it belongs to your practice, its patient does too, and it was addressed to the patient (`recipient_scope` is `patient`). A message *about* a patient that wasn't sent to them is not included, nor are internal notifications, drafts, or rows with an unknown status.
  * **Channels:** `email`, `sms`, `push` and `app`. Notes, calls and other channels aren't covered yet.
  * **Metadata** is identity, patient, channel, direction, status and delivery code, whether there are attachments, and the created, updated, occurred, sent, failed, read and retracted times. It never includes the body, subject, addresses, phone numbers, failure detail, provider ids, status history or attachment paths.
  * **A delivery code is what the provider reported.** It isn't proof of delivery, of the recipient's identity, or of clinical review. An attachment flag doesn't mean the attachment can be fetched through this API.
  * **Retracted messages** stay in the list, but their content is unavailable.

  ## Listing

  Filters: `patient_id`, `channel_type`, `direction`, `status`, plus `limit` (default 20, max 100) and `offset` (max 100,000). An empty, repeated or unsupported parameter returns `422`; a `patient_id` you can't see returns `404`. Newest first (`created_at`, then `id`). See [Pagination](https://docs.usejump.co.uk/getting-started/pagination) for what live paging means during concurrent changes.

  ## Reading content

  `GET /messages/{id}/content` returns `{ id, patient_id, available, content? }`.

  * **Sent messages** (sent, delivered, read, opened or bounced) return the copy as sent: `sent_html` as `format: html` when it was recorded, otherwise `sent_body` as `format: native`. The draft is never substituted for what was sent.
  * **Received messages** return the recorded body and subject as `format: native`. That doesn't establish who sent it, and the source may not be plain text.
  * **No copy** returns `available: false` with a reason: `not_recorded`, `not_sent_or_received` (still queued, sending or failed) or `retracted`. An empty recorded copy comes back empty.
  * **HTML is returned as stored, not sanitised.** Apply your own safe-rendering policy before displaying it.
  * **Size:** content over 1 MiB of body or 4,096 bytes of subject is refused rather than truncated.
  * Responses carry `Cache-Control: no-store`.

  Sending, retrying, drafts, marking as read and fetching attachments are not part of this API.
## List messages addressed to permitted patients

`GET /messages`

API-key scope: `read_messages`

Requires live read_messages. Applies recipient_scope=patient; rows merely
about a patient but addressed internally are excluded. Drafts, unknown
statuses and channels outside email/sms/push/app are excluded. Native
workflow and delivery state are preserved without inferring successful
delivery or verified identity. No bodies, subjects or raw addresses.
Sort: created_at DESC NULLS LAST, id DESC. Unsupported, empty and
repeated query parameters are rejected. Retracted metadata is retained.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | no |  |
| `offset` | query | integer | no |  |
| `patient_id` | query | string (uuid) | no |  |
| `channel_type` | query | string | no | One of: `email`, `sms`, `push`, `app`. |
| `direction` | query | string | no | One of: `inbound`, `outbound`. |
| `status` | query | string | no | One of: `queued`, `sending`, `in_progress`, `sent`, `delivered`, `read`, `opened`, `bounced`, `failed`, `error`, `received`. |

### Responses

- `200` Bounded metadata page with Cache-Control no-store
- `403` Missing live message metadata authority
- `404` Patient or message not available
- `422` Invalid query
- `500` Message read failed

## Get authorised patient message metadata

`GET /messages/{id}`

API-key scope: `read_messages`

Requires read_messages. Accepts no query parameters; content requires a separate grant and endpoint.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Responses

- `200` Message metadata with Cache-Control no-store
- `403` Missing live message metadata authority
- `404` Message not available
- `422` Invalid identifier or query
- `500` Message read failed

## Get recorded sent or received message content

`GET /messages/{id}/content`

API-key scope: `read_messages`, `read_message_content`

Requires BOTH read_messages and read_message_content on a live key.
Accepts no query parameters. Prefers recorded sent_html, otherwise
reports the native sent_body representation without substituting a
current draft. Inbound received rows preserve recorded source content
without a verified-sender claim. Missing, pending, failed and retracted
copies are explicitly unavailable. Body responses are capped at 1 MiB
UTF-8 bytes and subjects at 4096 bytes. HTML is a stored representation,
not newly sanitised; native content does not imply a plaintext format.
Attachments and sending are separate operations.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Responses

- `200` Recorded-copy availability with Cache-Control no-store
- `403` One or both explicit message grants missing
- `404` Message not available
- `422` Invalid identifier or query
- `500` Content read failed or recorded copy exceeds limits
