# Add a notification

Operation ID: `patient.addNotification`

Create a FHIR Communication notification for the authenticated patient. Requires a patient Bearer JWT.

## Public method

`saveNotification`

Signature: `patient.saveNotification(data, notificationId)`

Return type: `Promise<JsonValue>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/notifications`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`NotificationUpsertRequest`](../models/NotificationUpsertRequest.md) | Yes |  |  |  | No |  |

Request model: [`NotificationUpsertRequest`](../models/NotificationUpsertRequest.md)

## Request example

```json
{
  "createdAt": "2026-08-10T23:36:51Z",
  "description": "Synthetic notification example",
  "icon": "info",
  "read": false,
  "severity": "info",
  "title": "Test notification"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`AddNotificationResponse`](../models/AddNotificationResponse.md) | application/json | Notification created |

## Success response examples

### 201

```json
{
  "createdAt": "2026-08-10T23:36:51Z",
  "description": "Synthetic notification example",
  "icon": "info",
  "id": "notification-example-001",
  "read": false,
  "severity": "info",
  "title": "Test notification"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The request body failed schema validation |
| `401` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Authorization required — missing, invalid, expired, or non-patient Bearer JWT |
| `404` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The authenticated patient has no FHIR Patient record |

## Error examples

### 400 — The request body failed validation

```json
{
  "details": [
    {
      "loc": [
        "title"
      ],
      "msg": "String should have at most 200 characters",
      "type": "string_too_long"
    }
  ],
  "error": "Invalid request body"
}
```

### 401 — Missing or invalid access token

```json
{
  "error": "Authorization required"
}
```

### 404 — Patient not found

```json
{
  "error": "Patient not found"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
```

```ts
const data = "<DATA>";

const notificationId = "<NOTIFICATION_ID>";

const result = await patient.saveNotification(data, notificationId);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"createdAt":"2026-08-10T23:36:51Z","description":"Synthetic notification example","icon":"info","read":false,"severity":"info","title":"Test notification"}' \
  'https://dev-api-patient.health.cloud/patients/notifications'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
