Skip to content

Ingest Metrics

POST
/users/{user_id}/health/metrics
curl --request POST \
--url https://example.com/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/health/metrics \
--header 'Content-Type: application/json' \
--data '{ "readings": [ { "metadata": {}, "metric_type_slug": "example", "reading_group_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "recorded_at": "2026-04-15T12:00:00Z", "source": "example", "source_id": "example", "unit": "example", "value": 1 } ] }'

Batch-ingest metric readings. Idempotent: rows colliding on (user, source, source_id) — existing or duplicated within the batch — are skipped.

Built for volume (HealthKit can push thousands of samples per sync): a single bulk INSERT … ON CONFLICT DO NOTHING rather than a per-row savepoint, which also makes dedup race-safe under concurrent flushes.

user_id
required
User Id
string format: uuid
Media typeapplication/json
HealthMetricBatchIngest
object
readings
required
Readings
Array<object>
HealthMetricIngest

A single metric reading to ingest. Unit will be normalized to canonical on write.

object
metadata
Metadata
object
key
additional properties
any
metric_type_slug
required
Metric Type Slug
string
reading_group_id
Any of:
string format: uuid
recorded_at
required
Recorded At
string format: date-time
source
required
Source
string
source_id
Any of:
string
unit
Any of:
string
value
required
Value
number
Examplegenerated
{
"readings": [
{
"metadata": {},
"metric_type_slug": "example",
"reading_group_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"recorded_at": "2026-04-15T12:00:00Z",
"source": "example",
"source_id": "example",
"unit": "example",
"value": 1
}
]
}

Successful Response

Media typeapplication/json
HealthMetricBatchResult

Result of a batch ingest: newly created rows plus a count of duplicates skipped.

object
created
required
Created
Array<object>
HealthMetricRead
object
created_at
required
Created At
string format: date-time
id
required
Id
string format: uuid
metadata
required
Metadata
object
key
additional properties
any
metric_type_id
required
Metric Type Id
integer
metric_type_slug
required
Metric Type Slug
string
reading_group_id
required
Any of:
string format: uuid
recorded_at
required
Recorded At
string format: date-time
source
required
Source
string
source_id
required
Any of:
string
unit
required
Unit
string
updated_at
required
Updated At
string format: date-time
user_id
required
User Id
string format: uuid
value
required
Value
number
skipped_count
required
Skipped Count
integer
Examplegenerated
{
"created": [
{
"created_at": "2026-04-15T12:00:00Z",
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"metadata": {},
"metric_type_id": 1,
"metric_type_slug": "example",
"reading_group_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"recorded_at": "2026-04-15T12:00:00Z",
"source": "example",
"source_id": "example",
"unit": "example",
"updated_at": "2026-04-15T12:00:00Z",
"user_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"value": 1
}
],
"skipped_count": 1
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}