# Import activity

Operation ID: `patient.importActivity`

Import normalized wearable-device or FHIR activity Observations for the authenticated patient. When `source` is set, `payload` is normalized via the matching wearable adapter; otherwise `observations`/`entries` is imported as-is. Requires a patient Bearer JWT.

## Public method

`importActivity`

Signature: `patient.importActivity(source, payload)`

Return type: `Promise<JsonValue>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /patients/activity/import`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "entries": [],
  "observations": [],
  "payload": [],
  "source": "apple_health"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`ImportActivityResponse`](../models/ImportActivityResponse.md) | application/json | Activity import result |

## Success response examples

### 200

```json
{
  "imported": 0,
  "resource_ids": []
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The observations failed to normalize or import |
| `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 observations could not be imported

```json
{
  "error": "Invalid observation payload"
}
```

### 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 source = "<SOURCE>";

const payload = {
  "entries": [],
  "observations": [],
  "payload": [],
  "source": "apple_health"
};

const result = await patient.importActivity(source, payload);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"entries":[],"observations":[],"payload":[],"source":"apple_health"}' \
  'https://dev-api-patient.health.cloud/patients/activity/import'
```

## 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.
