Video processing
Measure a recorded video from your server — upload the file, create a job, read the result.
Video processing measures a recorded video instead of a live camera. Your server uploads
the file, creates a job and reads the result when it is ready. No browser or SDK is
involved. The result is the same measurement result a live
session produces, with origin: "cloud".
Video requirements
| Requirement | Value |
|---|---|
| Format | MP4, MOV or WebM |
| Length | 20–180 seconds |
| Frame rate | 20 fps or higher |
| Face | Visible in at least 70 % of frames, at least 100 px wide |
| File size | Up to 256 MB |
| Encoding | Intra-only, or a bitrate of at least 10 Mbit/s |
Use original camera recordings
Compression removes the pulse signal. Video-call recordings, screen recordings and re-encoded or compressed videos do not work.
Process a video
Every /sdk/v1 request is signed — see Authentication.
The upload itself is not.
Get an upload URL
POST /sdk/v1/cloud/uploads/presign
{ "kind": "video", "contentType": "video/mp4" }contentType is video/mp4 (default), video/quicktime or video/webm.
| Field | Description |
|---|---|
uploadUrl | Where to upload the file. Valid for 15 minutes |
objectKey | Upload ID, up_…. Pass it when you create the job |
expiresAt | When uploadUrl expires, epoch milliseconds |
contentType | The Content-Type to upload with |
maxBytes | Maximum file size in bytes: 268435456 (256 MB) |
minDurationSec, maxDurationSec | Accepted video length: 20 and 180 |
Treat uploadUrl as a secret: it grants write access to your upload. Do not log it.
Upload the file
PUT the file bytes to uploadUrl with the Content-Type header from the previous step.
The URL points to a storage host, not to neccessory.com — use it exactly as returned.
Create the job
POST /sdk/v1/cloud/jobs
| Field | Type | Default | Description |
|---|---|---|---|
objectKey | string | required | From the upload step |
kind | "video" | required | |
sha256 | string | required | SHA-256 of the uploaded file, 64 hex characters |
idempotencyKey | string | required | 16–200 characters, unique per video. See Idempotency |
consent | true | required | Confirms that the person in the video agreed to cloud processing |
features | string[] | every set the key allows | Metric sets to compute: hrv, bp, spo2, emotion, gaze. [] computes the core metrics only |
webhookUrl | string | — | HTTPS URL on a public host. Receives the job when it finishes. See Webhook for a single job |
userRef | string | — | Your pseudonymous ID for the person: 1–64 letters, digits and . _ : @ - |
platform | "server" | "web" | "ios" | "android" | "server" | Where the video comes from. Recorded on the job |
Returns 201 Created with the job object and status: "queued".
Get the result
Poll GET /sdk/v1/cloud/jobs/{jobId} every 2–5 seconds until the status is final. Or
pass webhookUrl and receive the job when it finishes. Organization
webhooks deliver it as well.
Complete example (Node.js)
import crypto from 'node:crypto';
import { readFile } from 'node:fs/promises';
const API = 'https://neccessory.com';
const KEY_ID = process.env.NECCESSORY_KEY_ID;
const SECRET = process.env.NECCESSORY_SECRET;
const FINAL = new Set(['completed', 'failed', 'aborted', 'expired']);
const sha256Hex = (data) => crypto.createHash('sha256').update(data).digest('hex');
async function neccessory(method, path, payload) {
const body = payload === undefined ? '' : JSON.stringify(payload);
const timestamp = String(Math.floor(Date.now() / 1000));
const nonce = crypto.randomUUID();
const canonical = ['NCS1', method, path.split('?')[0], timestamp, nonce, sha256Hex(body)].join('\n');
const headers = {
'x-key-id': KEY_ID,
'x-timestamp': timestamp,
'x-nonce': nonce,
'x-signature': crypto.createHmac('sha256', sha256Hex(SECRET)).update(canonical).digest('base64'),
};
if (body) headers['content-type'] = 'application/json';
const res = await fetch(API + path, { method, headers, body: body || undefined });
const json = await res.json();
if (!json.ok) {
throw Object.assign(new Error(json.error.message), { status: res.status, code: json.error.code });
}
return json.data;
}
async function processVideo(filePath, { recordingId, userRef }) {
const file = await readFile(filePath);
const sha256 = sha256Hex(file);
const upload = await neccessory('POST', '/sdk/v1/cloud/uploads/presign', {
kind: 'video',
contentType: 'video/mp4',
});
const put = await fetch(upload.uploadUrl, {
method: 'PUT',
headers: { 'content-type': upload.contentType },
body: file,
});
if (!put.ok) throw new Error(`Upload failed with HTTP ${put.status}`);
let job = await neccessory('POST', '/sdk/v1/cloud/jobs', {
objectKey: upload.objectKey,
kind: 'video',
sha256,
idempotencyKey: `${recordingId}-${sha256}`,
consent: true,
features: ['hrv'],
userRef,
});
while (!FINAL.has(job.status)) {
await new Promise((resolve) => setTimeout(resolve, 3000));
job = await neccessory('GET', `/sdk/v1/cloud/jobs/${job.jobId}`);
}
if (job.status !== 'completed') {
throw Object.assign(new Error(job.error?.message ?? job.status), { code: job.error?.code });
}
return job.measurement;
}
const measurement = await processVideo('./recording.mp4', { recordingId: 'rec_1024', userRef: 'u_42' });
console.log(measurement.quality.level, measurement.cardiac.heartRate.value);Send consent: true only for videos whose subjects agreed to cloud processing — see
Data & privacy.
The job object
{
"ok": true,
"data": {
"jobId": "cj_9b3e41f07a6c28d5e1b40f7a",
"mode": "batch_video",
"status": "completed",
"createdAt": 1767225600000,
"startedAt": 1767225601900,
"finishedAt": 1767225612400,
"secondsProcessed": 61.2,
"measurementId": "meas_2c8d7e1f40a95b36c7d0e1a2",
"userRef": "u_42",
"measurement": { "id": "meas_2c8d7e1f40a95b36c7d0e1a2", "origin": "cloud", "attested": true, … }
}
}| Field | Type | Description |
|---|---|---|
jobId | string | Job ID, cj_… |
mode | string | "batch_video" for video processing. Jobs of live sessions have other values |
status | string | See Statuses |
createdAt | number | When the job was created, epoch milliseconds |
startedAt | number | null | When processing started |
finishedAt | number | null | When the job reached a final status |
secondsProcessed | number | null | Seconds of video processed. The charge is based on it |
measurementId | string | null | ID of the stored result, once completed |
measurement | object | The full measurement result, once completed |
error | object | code and message when the job ended without a result |
userRef | string | Present when you sent one |
The job object can carry more fields. Ignore the ones you do not use. Add
?include=assessment to the request to get the result with its assessment.
Statuses
| Status | Meaning | Final |
|---|---|---|
queued | Accepted, waiting to be processed | No |
running | Being processed | No |
completed | Done. measurement holds the result | Yes |
failed | Processing produced no result. error.code says why | Yes |
aborted | Stopped before it finished, for example because the organization was deleted | Yes |
expired | The upload was removed before processing started | Yes |
Job error codes
| Code | Meaning | Fix |
|---|---|---|
too_short | The video is shorter than 20 seconds | Record at least 20 seconds |
insufficient_frame_rate | The frame rate is below 20 fps | Record at 20 fps or higher; 30 fps is ideal |
face_not_detected | No face in more than 30 % of the frames | Keep the face in frame and turned to the camera |
face_too_small | The face is narrower than 100 px | Record closer or at a higher resolution |
unsupported_media | The format or codec cannot be read | Upload an original MP4, MOV or WebM recording |
object_expired | The upload was removed before processing | Upload again and create a job with a new idempotencyKey |
sha256_mismatch | The stored file does not match sha256 | Upload again and create a job with a new idempotencyKey |
org_deleted | The organization was deleted | — |
| Any other code | Processing failed on our side | Create a job with a new idempotencyKey. If it repeats, write to support@neccessory.com with the jobId |
Request errors
| HTTP | Code | Cause |
|---|---|---|
| 400 | invalid_kind | kind is not "video" |
| 400 | invalid_content_type | contentType is not video/mp4, video/quicktime or video/webm |
| 400 | consent_required | consent is not true |
| 400 | validation_error | idempotencyKey length, userRef format, or webhookUrl is not HTTPS on a public host |
| 403 | feature_not_allowed | A requested metric set is not enabled on the key |
| 403 | quota_exceeded, token_quota_exceeded, insufficient_tokens | A quota, the spend ceiling or the balance blocks the job. See Limits & quotas and Pricing |
| 404 | object_not_found | Unknown objectKey, a file that was never uploaded, or an upload that already expired |
| 409 | idempotency_conflict | The idempotencyKey was used for a different file |
| 413 | object_too_large | The file is larger than 256 MB |
| 422 | sha256_mismatch | sha256 is not 64 hex characters or does not match the uploaded file |
| 503 | cloud_unavailable | Cloud processing is temporarily unavailable. Retry later |
Idempotency
idempotencyKey binds one job to one video under your API key. Use a value from your own
system, such as a recording ID.
- Same key, same
sha256— returns the existing job with200 OKand its current status. Retry a request that timed out without creating a second job. - Same key, different
sha256— fails with409 idempotency_conflict. - After a failure — the key stays bound to the failed job. To process the video again, use a new key, for example with an attempt number appended.
Webhook for a single job
With webhookUrl, Neccessory sends POST to that URL when the job reaches a final
status. The body is { "ok": true, "data": job }, where job is the job object with the
measurement when it completed.
The request is signed with your API key using the same NCS1 scheme as your own requests:
x-key-id holds your key ID, and the signed path is the path of your webhook URL.
Verify it with the same code you sign with.
import crypto from 'node:crypto';
import express from 'express';
const KEY_ID = process.env.NECCESSORY_KEY_ID;
const SECRET = process.env.NECCESSORY_SECRET;
const WEBHOOK_PATH = '/webhooks/neccessory-job';
const sha256Hex = (data) => crypto.createHash('sha256').update(data).digest('hex');
function isValidSignature(req, rawBody) {
const timestamp = req.get('x-timestamp') ?? '';
const nonce = req.get('x-nonce') ?? '';
const canonical = ['NCS1', 'POST', WEBHOOK_PATH, timestamp, nonce, sha256Hex(rawBody)].join('\n');
const expected = Buffer.from(
crypto.createHmac('sha256', sha256Hex(SECRET)).update(canonical).digest('base64'),
);
const received = Buffer.from(req.get('x-signature') ?? '');
return (
req.get('x-key-id') === KEY_ID &&
Math.abs(Date.now() / 1000 - Number(timestamp)) <= 300 &&
expected.length === received.length &&
crypto.timingSafeEqual(expected, received)
);
}
const app = express();
app.post(WEBHOOK_PATH, express.text({ type: 'application/json' }), (req, res) => {
if (!isValidSignature(req, req.body)) return res.sendStatus(401);
const { data: job } = JSON.parse(req.body);
res.sendStatus(200);
console.log(job.jobId, job.status, job.measurement?.quality.level);
});
app.listen(3000);- Neccessory makes up to 3 attempts. Only a
2xxresponse within 10 seconds counts as delivered. Redirects are not followed. - The same job can arrive more than once. Deduplicate by
jobId. - To reject replays, store each
x-noncefor 5 minutes and refuse repeats.
Test keys
With a test key, upload a real file — sha256 is checked. The job then completes with a
synthetic result about 2 seconds after creation. Nothing is processed and nothing is
charged. The result carries test: true.
Data retention
- The uploaded file is deleted as soon as the job finishes, whatever the outcome.
- Any upload is deleted at most 1 hour after its upload URL was created, used or not. A
job that has not started by then ends as
expired. - The measurement result is stored; the video is not. See Data & privacy.
Video processing is charged per second of video processed plus each metric set — see Pricing.