Measurements
Store results computed on the device and read any measurement your key owns.
Store results that the SDK computed on the device, and read back any measurement your key owns. Cloud results are stored automatically when the cloud session or video job completes. Do not submit them.
Store an on-device result
POST /sdk/v1/measurementsSend the result the SDK delivered. The response is the stored measurement with its id.
Storing results is not billed.
Body
The body is the measurement result object.
| Field | Type | Description |
|---|---|---|
source | string | web (default), ios or playground |
durationSec | number | Measurement length in seconds |
isComplete | boolean | Default true. false when the measurement ended early |
quality | object | level, score, usable. When level is missing, it is derived from score |
cardiac, hrv, respiratory, stress | object | Core metric sections |
bloodPressure, spo2, emotion, behavior | object | Beta metric sections |
sdkVersion | string | SDK version that produced the result |
modelsVersion | string | Model version that produced the result |
userRef | string | Your identifier for the person measured. See End users |
raw | object | Beat-to-beat intervals and pulse waveform. Stored only with the advanced flag |
includeAdvanced | boolean | true stores raw and returns it in the response |
Server-owned fields (id, keyId, createdAt, origin, attested, requestId,
cloudJobId) are ignored. A stored on-device result always has origin: "on_device" and
attested: false.
Flags
| Flag | Where | Effect |
|---|---|---|
advanced=true | Query | Store the raw section and return it |
includeAdvanced: true | Body | Same as advanced=true |
include=assessment | Query | Add the wellness assessment to the response |
Version fields
sdkVersion and modelsVersion are 1–64 characters matching
^[A-Za-z0-9][A-Za-z0-9._+-]*$, for example 0.1.0 or 2026-08-01+web. The Web and iOS SDKs
fill both. A malformed value rejects the whole request with 400 validation_error.
Response
201 Created, abbreviated:
{
"ok": true,
"data": {
"id": "meas_9c1f4b7ae2d05138b6a37f42",
"keyId": "nk_live_sRwG9z2hK2hdV4Il83J7Cw",
"source": "web",
"origin": "on_device",
"attested": false,
"createdAt": 1790000000000,
"durationSec": 45,
"isComplete": true,
"quality": { "level": "good", "score": 0.82, "usable": true },
"cardiac": { "heartRate": { "value": 72, "unit": "bpm", "confidence": 0.88 } },
"respiratory": { "breathingRate": { "value": 15, "unit": "brpm" } },
"stress": { "index": 34, "level": "moderate", "unit": "index" },
"userRef": "u_42",
"requestId": "req_9a1c4e77b0d2358fc6e4",
"sdkVersion": "0.1.0",
"modelsVersion": "wv-5"
}
}Results stored with a test key also carry "test": true.
Errors
| HTTP | error.code | Cause |
|---|---|---|
| 400 | validation_error | source is not allowed, userRef or a version field is malformed |
| 401 | unauthorized | Signature or key problem. See Authentication |
| 413 | payload_too_large | The body is over 256 KB, usually because of a long raw section |
| 429 | rate_limited | The key's request limit is reached |
With the Web SDK helper
signAndSubmit from @neccessory/web-sdk signs and submits a result in one call. It uses the
Web Crypto API, so on a server it needs Node.js 20 or later. It rejects with { code, message }.
import { signAndSubmit } from '@neccessory/web-sdk';
const stored = await signAndSubmit({
keyId: process.env.NECCESSORY_KEY_ID,
secret: process.env.NECCESSORY_SECRET,
result,
});
console.log(stored.id);signAndSubmit sends the result without userRef. To attach one, sign the request yourself.
Signing the request yourself
This example uses signHeaders from Authentication.
import { signHeaders } from './neccessory.js';
export async function storeResult(result, userRef) {
const path = '/sdk/v1/measurements';
const body = JSON.stringify({ ...result, userRef });
const res = await fetch(`https://neccessory.com${path}?include=assessment`, {
method: 'POST',
headers: {
...signHeaders({
keyId: process.env.NECCESSORY_KEY_ID,
secret: process.env.NECCESSORY_SECRET,
method: 'POST',
path,
body,
}),
'content-type': 'application/json',
},
body,
});
const json = await res.json();
if (!json.ok) throw new Error(`${json.error.code} (${res.headers.get('x-request-id')})`);
return json.data;
}Read a measurement
GET /sdk/v1/measurements/{id}Returns a measurement stored under the signing key: cloud results and on-device results alike.
A measurement of any other key, including another key of your organization, returns
404 not_found.
| Query | Effect |
|---|---|
advanced=true | Include the raw section, when it was stored |
include=assessment | Include the wellness assessment |
The query string is not signed. For
GET /sdk/v1/measurements/meas_9c1f4b7ae2d05138b6a37f42?include=assessment you sign the path
/sdk/v1/measurements/meas_9c1f4b7ae2d05138b6a37f42.
import { neccessory } from './neccessory.js';
const measurement = await neccessory(
'GET',
'/sdk/v1/measurements/meas_9c1f4b7ae2d05138b6a37f42?include=assessment',
);With signAndFetchMeasurement from @neccessory/web-sdk, which also needs Node.js 20 or later
on a server:
import { signAndFetchMeasurement } from '@neccessory/web-sdk';
const measurement = await signAndFetchMeasurement({
keyId: process.env.NECCESSORY_KEY_ID,
secret: process.env.NECCESSORY_SECRET,
measurementId: 'meas_9c1f4b7ae2d05138b6a37f42',
includeAssessment: true,
});The response data is the full measurement result.
Verify results on your backend
Do not trust numbers sent by a client
A browser or app can send your backend any values. When a result drives a decision, have the
client send only the measurement id, then read the measurement with your key and check its
fields.
import { neccessory } from './neccessory.js';
export async function loadVerified(measurementId, { userRef, requireAttested = false }) {
if (!/^meas_[A-Za-z0-9]+$/.test(measurementId)) throw new Error('invalid measurement id');
const m = await neccessory('GET', `/sdk/v1/measurements/${measurementId}`);
if (m.test) throw new Error('test result');
if (m.userRef !== userRef) throw new Error('measurement belongs to another user');
if (requireAttested && !m.attested) throw new Error('result is not attested');
return m;
}attested: true means Neccessory computed the metrics in cloud mode from a complete measurement
with usable signal quality (good or fair). Results computed on the device are never attested. Require it when the decision must rest on values the client could
not have produced. See Attested results.