NeccessoryNeccessory
Cloud

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

RequirementValue
FormatMP4, MOV or WebM
Length20–180 seconds
Frame rate20 fps or higher
FaceVisible in at least 70 % of frames, at least 100 px wide
File sizeUp to 256 MB
EncodingIntra-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.

FieldDescription
uploadUrlWhere to upload the file. Valid for 15 minutes
objectKeyUpload ID, up_…. Pass it when you create the job
expiresAtWhen uploadUrl expires, epoch milliseconds
contentTypeThe Content-Type to upload with
maxBytesMaximum file size in bytes: 268435456 (256 MB)
minDurationSec, maxDurationSecAccepted 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

FieldTypeDefaultDescription
objectKeystringrequiredFrom the upload step
kind"video"required
sha256stringrequiredSHA-256 of the uploaded file, 64 hex characters
idempotencyKeystringrequired16–200 characters, unique per video. See Idempotency
consenttruerequiredConfirms that the person in the video agreed to cloud processing
featuresstring[]every set the key allowsMetric sets to compute: hrv, bp, spo2, emotion, gaze. [] computes the core metrics only
webhookUrlstring—HTTPS URL on a public host. Receives the job when it finishes. See Webhook for a single job
userRefstring—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, … }
  }
}
FieldTypeDescription
jobIdstringJob ID, cj_…
modestring"batch_video" for video processing. Jobs of live sessions have other values
statusstringSee Statuses
createdAtnumberWhen the job was created, epoch milliseconds
startedAtnumber | nullWhen processing started
finishedAtnumber | nullWhen the job reached a final status
secondsProcessednumber | nullSeconds of video processed. The charge is based on it
measurementIdstring | nullID of the stored result, once completed
measurementobjectThe full measurement result, once completed
errorobjectcode and message when the job ended without a result
userRefstringPresent 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

StatusMeaningFinal
queuedAccepted, waiting to be processedNo
runningBeing processedNo
completedDone. measurement holds the resultYes
failedProcessing produced no result. error.code says whyYes
abortedStopped before it finished, for example because the organization was deletedYes
expiredThe upload was removed before processing startedYes

Job error codes

CodeMeaningFix
too_shortThe video is shorter than 20 secondsRecord at least 20 seconds
insufficient_frame_rateThe frame rate is below 20 fpsRecord at 20 fps or higher; 30 fps is ideal
face_not_detectedNo face in more than 30 % of the framesKeep the face in frame and turned to the camera
face_too_smallThe face is narrower than 100 pxRecord closer or at a higher resolution
unsupported_mediaThe format or codec cannot be readUpload an original MP4, MOV or WebM recording
object_expiredThe upload was removed before processingUpload again and create a job with a new idempotencyKey
sha256_mismatchThe stored file does not match sha256Upload again and create a job with a new idempotencyKey
org_deletedThe organization was deleted—
Any other codeProcessing failed on our sideCreate a job with a new idempotencyKey. If it repeats, write to support@neccessory.com with the jobId

Request errors

HTTPCodeCause
400invalid_kindkind is not "video"
400invalid_content_typecontentType is not video/mp4, video/quicktime or video/webm
400consent_requiredconsent is not true
400validation_erroridempotencyKey length, userRef format, or webhookUrl is not HTTPS on a public host
403feature_not_allowedA requested metric set is not enabled on the key
403quota_exceeded, token_quota_exceeded, insufficient_tokensA quota, the spend ceiling or the balance blocks the job. See Limits & quotas and Pricing
404object_not_foundUnknown objectKey, a file that was never uploaded, or an upload that already expired
409idempotency_conflictThe idempotencyKey was used for a different file
413object_too_largeThe file is larger than 256 MB
422sha256_mismatchsha256 is not 64 hex characters or does not match the uploaded file
503cloud_unavailableCloud 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 with 200 OK and its current status. Retry a request that timed out without creating a second job.
  • Same key, different sha256 — fails with 409 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 2xx response 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-nonce for 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.