Ingest Metrics
POST
/users/{user_id}/health/metrics
const url = 'https://example.com/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/health/metrics';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"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}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”user_id
required
User Id
string format: uuid
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
HealthMetricBatchIngest
object
readings
required
Readings
Array<object>
HealthMetricIngestA 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
recorded_at
required
Recorded At
string format: date-time
source
required
Source
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 } ]}Responses
Section titled “Responses”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>
HealthMetricReadobject
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
recorded_at
required
Recorded At
string format: date-time
source
required
Source
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>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ]}