- [HTTP request](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.HTTP_TEMPLATE)
- [Path parameters](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.PATH_PARAMETERS)
- [Request body](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.request_body)
  - [JSON representation](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.response_body)
  - [JSON representation](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.RollUpDataPointsResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#body.aspect)
- [RollupDataPoint](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#RollupDataPoint)
  - [JSON representation](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#RollupDataPoint.SCHEMA_REPRESENTATION)
- [Examples](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#examples)
- [Try it!](https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#try-it)

Roll up data points over physical time intervals for supported data types.

### HTTP request

`POST https://health.googleapis.com/v4/{parent=users/*/dataTypes/*}/dataPoints:rollUp`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax. To know more about valid error responses that can be thrown by this HTTP request, please refer to the [service error catalog](https://developers.google.com/health/reference/rest/v4/errors)

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. Parent data type of the Data Point collection. Format: `users/{user}/dataTypes/{dataType}`, e.g.: - `users/me/dataTypes/steps` - `users/me/dataTypes/distance` For a list of the supported data types see the `https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#RollupDataPoint` union field. It takes the form `users/{user}/dataTypes/{datatype}`. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "range": { object (`https://developers.google.com/health/reference/rest/Shared.Types/Interval`) }, "windowSize": string, "pageSize": integer, "pageToken": string, "dataSourceFamily": string } ``` |

| Fields ||
|---|---|
| `range` | ``object (`https://developers.google.com/health/reference/rest/Shared.Types/Interval`)`` Required. Closed-open range of data points that will be rolled up. The maximum range for `calories-in-heart-rate-zone`, `heart-rate`, `active-minutes` and `total-calories` is 14 days. The maximum range for all other data types is 90 days. |
| `windowSize` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#duration` format)`` Required. The size of the time window to group data points into before applying the aggregation functions. Must be at least 1 second. If the requested range is not an exact multiple of `windowSize`, the final bucket chronologically will be truncated at the upper endpoint of the range and will cover a duration shorter than `windowSize`. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `"3.5s"`. |
| `pageSize` | `integer` Optional. The maximum number of data points to return. If unspecified, at most 1440 data points will be returned. The maximum page size is 10000; values above that will be truncated accordingly. |
| `pageToken` | `string` Optional. The nextPageToken from a previous request, if any. All other request fields need to be the same as in the initial request when the page token is specified. |
| `dataSourceFamily` | `string` Optional. The data source family name to roll up. If empty, data points from all available data sources will be rolled up. Format: `users/me/dataSourceFamilies/{dataSourceFamily}` The supported values are: - `users/me/dataSourceFamilies/all-sources` - Default value. Includes data from all available data sources. - `users/me/dataSourceFamilies/google-wearables` - Includes data from Google and Fitbit tracker devices (such as Fitbit trackers and Pixel Watch). Excludes manually logged data. - `users/me/dataSourceFamilies/google-sources` - Includes first-party Google data, such as data from tracker devices, manually logged data, and Health Connect. - `users/me/dataSourceFamilies/self-sources` - Includes only the data the calling client wrote through this API, that is, data points whose data source was registered through this API with the same OAuth client ID as the caller. Callers that were only granted write scopes for the requested data type may only read the data they wrote themselves: their requests are implicitly restricted to `self-sources`, and requesting any other data source family fails with `PERMISSION_DENIED`. If no data point matches the requested data source family, the response is an empty list rather than an error. |

### Response body

Response containing the list of rolled up data points.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "rollupDataPoints": [ { object (`https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#RollupDataPoint`) } ], "nextPageToken": string } ``` |

| Fields ||
|---|---|
| `rollupDataPoints[]` | ``object (`https://developers.google.com/health/reference/rest/v4/users.dataTypes.dataPoints/rollUp#RollupDataPoint`)`` Values for each aggregation time window. |
| `nextPageToken` | `string` A token, which can be sent as `pageToken` to retrieve the next page. If this field is omitted, there are no subsequent pages. |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/googlehealth.activity_and_fitness.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.location.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.nutrition.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.sleep.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.reproductive_health.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.logged_symptoms.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.mindfulness.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.ecg.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.irn.readonly`
- `
  https://www.googleapis.com/auth/googlehealth.activity_and_fitness.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.health_metrics_and_measurements.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.nutrition.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.sleep.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.reproductive_health.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.logged_symptoms.writeonly`
- `
  https://www.googleapis.com/auth/googlehealth.mindfulness.writeonly`

For more information, see the [OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2).

## RollupDataPoint

Value of a rollup for a single physical time interval (aggregation window) of reconciled data points from all data sources, excluding those data points that are identified as recorded by wearables in intervals when they were not actually worn.

| JSON representation |
|---|
| ``` { "startTime": string, "endTime": string, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "steps": { object (`https://developers.google.com/health/reference/rest/v4/StepsRollupValue`) }, "floors": { object (`https://developers.google.com/health/reference/rest/v4/FloorsRollupValue`) }, "heartRate": { object (`https://developers.google.com/health/reference/rest/v4/HeartRateRollupValue`) }, "weight": { object (`https://developers.google.com/health/reference/rest/v4/WeightRollupValue`) }, "altitude": { object (`https://developers.google.com/health/reference/rest/v4/AltitudeRollupValue`) }, "distance": { object (`https://developers.google.com/health/reference/rest/v4/DistanceRollupValue`) }, "bodyFat": { object (`https://developers.google.com/health/reference/rest/v4/BodyFatRollupValue`) }, "totalCalories": { object (`https://developers.google.com/health/reference/rest/v4/TotalCaloriesRollupValue`) }, "activeZoneMinutes": { object (`https://developers.google.com/health/reference/rest/v4/ActiveZoneMinutesRollupValue`) }, "sedentaryPeriod": { object (`https://developers.google.com/health/reference/rest/v4/SedentaryPeriodRollupValue`) }, "runVo2Max": { object (`https://developers.google.com/health/reference/rest/v4/RunVO2MaxRollupValue`) }, "caloriesInHeartRateZone": { object (`https://developers.google.com/health/reference/rest/v4/CaloriesInHeartRateZoneRollupValue`) }, "activityLevel": { object (`https://developers.google.com/health/reference/rest/v4/ActivityLevelRollupValue`) }, "nutritionLog": { object (`https://developers.google.com/health/reference/rest/v4/NutritionLogRollupValue`) }, "hydrationLog": { object (`https://developers.google.com/health/reference/rest/v4/HydrationLogRollupValue`) }, "timeInHeartRateZone": { object (`https://developers.google.com/health/reference/rest/v4/TimeInHeartRateZoneRollupValue`) }, "activeMinutes": { object (`https://developers.google.com/health/reference/rest/v4/ActiveMinutesRollupValue`) }, "swimLengthsData": { object (`https://developers.google.com/health/reference/rest/v4/SwimLengthsDataRollupValue`) }, "coreBodyTemperature": { object (`https://developers.google.com/health/reference/rest/v4/CoreBodyTemperatureRollupValue`) }, "activeEnergyBurned": { object (`https://developers.google.com/health/reference/rest/v4/ActiveEnergyBurnedRollupValue`) }, "bloodGlucose": { object (`https://developers.google.com/health/reference/rest/v4/BloodGlucoseRollupValue`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `startTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Start time of the window this value aggregates over Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `endTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` End time of the window this value aggregates over Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| Outcome of a rollup of the requested data type. `{DataType}RollupValue` messages for each data type contain aggregated values for all supported fields. The field names usually follow the format `{original_field_name}_{aggregation_function}`. For example: `confidence_min`, `confidence_sum`. If there were no manual, on-wrist data points in this interval, the value will not be set. When the value is set, but the data shows zero, e.g. `steps.count_sum = 0`, it means that a device was worn but it did not record any data points for this data type. These messages represent the aggregated data payload for each data type and are embedded within the `RollupDataPoint`. They are not standalone resources themselves. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `steps` | ``object (`https://developers.google.com/health/reference/rest/v4/StepsRollupValue`)`` Returned by default when rolling up data points from the `steps` data type, or when requested explicitly using the `steps` rollup type identifier. |
| `floors` | ``object (`https://developers.google.com/health/reference/rest/v4/FloorsRollupValue`)`` Returned by default when rolling up data points from the `floors` data type, or when requested explicitly using the `floors` rollup type identifier. |
| `heartRate` | ``object (`https://developers.google.com/health/reference/rest/v4/HeartRateRollupValue`)`` Returned by default when rolling up data points from the `heart-rate` data type, or when requested explicitly using the `heart-rate` rollup type identifier. |
| `weight` | ``object (`https://developers.google.com/health/reference/rest/v4/WeightRollupValue`)`` Returned by default when rolling up data points from the `weight` data type, or when requested explicitly using the `weight` rollup type identifier. |
| `altitude` | ``object (`https://developers.google.com/health/reference/rest/v4/AltitudeRollupValue`)`` Returned by default when rolling up data points from the `altitude` data type, or when requested explicitly using the `altitude` rollup type identifier. |
| `distance` | ``object (`https://developers.google.com/health/reference/rest/v4/DistanceRollupValue`)`` Returned by default when rolling up data points from the `distance` data type, or when requested explicitly using the `distance` rollup type identifier. |
| `bodyFat` | ``object (`https://developers.google.com/health/reference/rest/v4/BodyFatRollupValue`)`` Returned by default when rolling up data points from the `body-fat` data type, or when requested explicitly using the `body-fat` rollup type identifier. |
| `totalCalories` | ``object (`https://developers.google.com/health/reference/rest/v4/TotalCaloriesRollupValue`)`` Returned by default when rolling up data points from the `total-calories` data type, or when requested explicitly using the `total-calories` rollup type identifier. |
| `activeZoneMinutes` | ``object (`https://developers.google.com/health/reference/rest/v4/ActiveZoneMinutesRollupValue`)`` Returned by default when rolling up data points from the `active-zone-minutes` data type, or when requested explicitly using the `active-zone-minutes` rollup type identifier. |
| `sedentaryPeriod` | ``object (`https://developers.google.com/health/reference/rest/v4/SedentaryPeriodRollupValue`)`` Returned by default when rolling up data points from the `sedentary-period` data type, or when requested explicitly using the `sedentary-period` rollup type identifier. |
| `runVo2Max` | ``object (`https://developers.google.com/health/reference/rest/v4/RunVO2MaxRollupValue`)`` Returned by default when rolling up data points from the `run-vo2-max` data type, or when requested explicitly using the `run-vo2-max` rollup type identifier. |
| `caloriesInHeartRateZone` | ``object (`https://developers.google.com/health/reference/rest/v4/CaloriesInHeartRateZoneRollupValue`)`` Returned by default when rolling up data points from the `calories-in-heart-rate-zone` data type, or when requested explicitly using the `calories-in-heart-rate-zone` rollup type identifier. |
| `activityLevel` | ``object (`https://developers.google.com/health/reference/rest/v4/ActivityLevelRollupValue`)`` Returned by default when rolling up data points from the `activity-level` data type, or when requested explicitly using the `activity-level` rollup type identifier. |
| `nutritionLog` | ``object (`https://developers.google.com/health/reference/rest/v4/NutritionLogRollupValue`)`` Returned by default when rolling up data points from the `nutrition-log` data type, or when requested explicitly using the `nutrition-log` rollup type identifier. |
| `hydrationLog` | ``object (`https://developers.google.com/health/reference/rest/v4/HydrationLogRollupValue`)`` Returned by default when rolling up data points from the `hydration-log` data type, or when requested explicitly using the `hydration-log` rollup type identifier. |
| `timeInHeartRateZone` | ``object (`https://developers.google.com/health/reference/rest/v4/TimeInHeartRateZoneRollupValue`)`` Returned by default when rolling up data points from the `time-in-heart-rate-zone` data type, or when requested explicitly using the `time-in-heart-rate-zone` rollup type identifier. |
| `activeMinutes` | ``object (`https://developers.google.com/health/reference/rest/v4/ActiveMinutesRollupValue`)`` Returned by default when rolling up data points from the `active-minutes` data type, or when requested explicitly using the `active-minutes` rollup type identifier. |
| `swimLengthsData` | ``object (`https://developers.google.com/health/reference/rest/v4/SwimLengthsDataRollupValue`)`` Returned by default when rolling up data points from the `swim-lengths-data` data type, or when requested explicitly using the `swim-lengths-data` rollup type identifier. |
| `coreBodyTemperature` | ``object (`https://developers.google.com/health/reference/rest/v4/CoreBodyTemperatureRollupValue`)`` Returned by default when rolling up data points from the `core-body-temperature` data type, or when requested explicitly using the `core-body-temperature` rollup type identifier. |
| `activeEnergyBurned` | ``object (`https://developers.google.com/health/reference/rest/v4/ActiveEnergyBurnedRollupValue`)`` Returned by default when rolling up data points from the `active-energy-burned` data type. |
| `bloodGlucose` | ``object (`https://developers.google.com/health/reference/rest/v4/BloodGlucoseRollupValue`)`` Returned by default when rolling up data points from the `blood-glucose` data type. |
| End of mutually exclusive fields. ||