Data Consolidation
Control how a user's connected providers are combined into canonical daily metrics.
When two or more providers report the same metric for the same calendar day, Sonar consolidates their values into one result. Every configurable metric has a catalog default, and each user can override that method or exclude selected providers.
| Method | Behavior |
|---|---|
max |
Uses the largest value reported by an enabled provider |
avg |
Uses the arithmetic mean of values reported by enabled providers |
sum |
Adds the values reported by enabled providers |
The catalog is authoritative. Do not hard-code configurable metric keys or default methods in your application.
Consolidation Catalog
/v1/consolidation/catalogReturns every configurable daily metric and metric group, its default method, and the methods it accepts.
Parameters and shapes
Response 200: ConsolidationCatalog
category_order- string[] required
metrics- CatalogMetric[] required
CatalogMetric
key- string required
display_name- string required
category- string required
kind- string required one of metric, group
default_method- string required one of avg, max, sum
allowed_methods- string[] required
{
"category_order": ["Activity", "Energy", "Body Composition", "Sleep", "Vitals", "Nutrition"],
"metrics": [
{
"key": "steps",
"display_name": "Steps",
"category": "Activity",
"kind": "metric",
"default_method": "max",
"allowed_methods": ["avg", "max", "sum"]
},
{
"key": "global_sleep",
"display_name": "Sleep",
"category": "Sleep",
"kind": "group",
"default_method": "max",
"allowed_methods": ["avg", "max", "sum"]
}
]
}A group applies one setting to its related daily metrics. Workouts and sleep are sessions, not daily numbers, so they follow session rules instead: when two providers record the same workout, Sonar returns it once, from the provider first in the default order. Endpoints to set the provider order for workouts and sleep per user arrive later this year.
Retrieve User Configuration
/v1/users/{id}/consolidationReturns the effective configuration after applying catalog defaults and the user’s overrides.
Parameters and shapes
Path parameters
id- string (uuid) required
Response 200: UserConsolidation
providers- ProviderState[] required
metrics- MetricConsolidation[] required
ProviderState
provider- string required
enabled- boolean required
MetricConsolidation
key- string required
category- string required
default_method- string required one of avg, max, sum
method- string required one of avg, max, sum
overridden- boolean required
providers- ProviderState[] required
{
"providers": [
{ "provider": "garmin", "enabled": true },
{ "provider": "oura", "enabled": true }
],
"metrics": [
{
"key": "steps",
"category": "Activity",
"default_method": "max",
"method": "sum",
"overridden": true,
"providers": [
{ "provider": "garmin", "enabled": true },
{ "provider": "oura", "enabled": false }
]
}
]
}The top-level provider state applies to every metric. A provider can also be excluded only for an individual metric. Metric provider state is effective state, so it is false when the provider is disabled either globally or for that metric.
Update User Configuration
/v1/users/{id}/consolidationAtomically updates only the supplied settings and returns 202 Accepted.
Parameters and shapes
Path parameters
id- string (uuid) required
Request body: PatchConsolidationRequest
metrics- map of MetricPatch
providers- map of boolean
Response 202: ConsolidationAccepted
status- string required one of reconsolidating, unchanged
configuration- UserConsolidation required
MetricPatch
method- string or null one of avg, max, sum
providers- map of boolean
UserConsolidation
providers- ProviderState[] required
metrics- MetricConsolidation[] required
ProviderState
provider- string required
enabled- boolean required
MetricConsolidation
key- string required
category- string required
default_method- string required one of avg, max, sum
method- string required one of avg, max, sum
overridden- boolean required
providers- ProviderState[] required
response = requests.patch(
f"{BASE}/users/{user_id}/consolidation",
headers=HEADERS,
json={
"metrics": {
"steps": {
"method": "sum",
"providers": {"oura": False},
}
},
"providers": {"garmin": True},
},
)
response.raise_for_status()Set a metric’s method to null to remove its override and restore the current catalog default. Provider keys must identify providers currently connected to that user.
{
"status": "reconsolidating",
"configuration": {
"providers": [],
"metrics": []
}
}status is unchanged when the submitted state already matches the stored configuration.
Updates rebuild historical data
The setting is stored before the response, but existing historical outputs are reconsolidated asynchronously. When the rebuild changes available data, a subsequent subject.synced webhook indicates that refreshed data is available. Multiple changes made close together are coalesced into one rebuild.
Reset to Defaults
/v1/users/{id}/consolidationRemoves method overrides and provider exclusions and returns 202 Accepted. It does not change connected providers, workout ordering, or unrelated user settings.
Parameters and shapes
Path parameters
id- string (uuid) required
Response 202: ConsolidationAccepted
status- string required one of reconsolidating, unchanged
configuration- UserConsolidation required
UserConsolidation
providers- ProviderState[] required
metrics- MetricConsolidation[] required
ProviderState
provider- string required
enabled- boolean required
MetricConsolidation
key- string required
category- string required
default_method- string required one of avg, max, sum
method- string required one of avg, max, sum
overridden- boolean required
providers- ProviderState[] required
Errors
| Code | Status | Meaning |
|---|---|---|
invalid_body |
400 | The request shape or method is invalid |
user_not_found |
404 | The user does not exist in the API key’s environment |
invalid_metric |
422 | The metric key is not present in the consolidation catalog |
invalid_method |
422 | The method is not allowed for that metric |
invalid_provider |
422 | The provider is not currently connected to the user |
Sonar