# Fetch all pages of sleep records

Operation ID: `connectors.ouraGetAllSleeps`

Fetch all pages of sleep records. Calls Oura through the HealthCloud connector gateway.

## Public method

`getAllSleeps`

Signature: `connectors.oura.createClient(config).getAllSleeps(body)`

Return type: `Promise<OuraSleepResponse[]>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /connectors/oura/get-all-sleeps`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

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

## Request example

```json
{
  "access_token": "example-access-token",
  "client_id": "12345",
  "client_secret": "example-client-secret",
  "end_date": "2024-12-31",
  "mode": "sandbox",
  "start_date": "2024-01-01"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`OuraGetAllSleepsResponse`](../models/OuraGetAllSleepsResponse.md) | application/json | Successful response |

## Success response examples

### 200

```json
[
  {
    "average_breath": 1,
    "average_heart_rate": 1,
    "average_hrv": 1,
    "awake_time": 1,
    "bedtime_end": "example-bedtime-end",
    "bedtime_start": "example-bedtime-start",
    "day": "example-day",
    "deep_sleep_duration": 1,
    "efficiency": 1,
    "id": "12345",
    "latency": 1,
    "light_sleep_duration": 1,
    "low_battery_alert": true,
    "lowest_heart_rate": 1,
    "period": 1,
    "rem_sleep_duration": 1,
    "restless_periods": 1,
    "time_in_bed": 1,
    "total_sleep_duration": 1000,
    "type": "example-type"
  }
]
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | Connector validation rejected the payload, or a required field was missing or of the wrong type. |
| `401` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The HealthCloud bearer token is missing or invalid, or the vendor rejected the supplied connector credentials. |
| `500` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The connector failed unexpectedly. |
| `502` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor returned an application or transport-level failure. |
| `504` | [`StandardErrorResponse`](../models/StandardErrorResponse.md) | application/json | The vendor did not respond within the connector timeout. |

## Error examples

### 400 — Invalid request

```json
{
  "error": "Invalid request"
}
```

### 401 — Authorization required

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

### 500 — Internal error

```json
{
  "error": "Internal error"
}
```

### 502 — Upstream vendor error

```json
{
  "error": "Upstream vendor error"
}
```

### 504 — Upstream timeout

```json
{
  "error": "Upstream timeout"
}
```

## NodeJS / TypeScript implementation

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

```ts
const body = {
  "access_token": "example-access-token",
  "client_id": "12345",
  "client_secret": "example-client-secret",
  "end_date": "2024-12-31",
  "mode": "sandbox",
  "start_date": "2024-01-01"
};

const result = await connectors.oura.createClient(config).getAllSleeps(body);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"access_token":"example-access-token","client_id":"12345","client_secret":"example-client-secret","end_date":"2024-12-31","mode":"sandbox","start_date":"2024-01-01"}' \
  'https://dev-api-connectors.health.cloud/connectors/oura/get-all-sleeps'
```

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