HomeProducts— Affect— PersonaTechnologyDocs— Quick Start— Authentication— Client SDK— Webhooks— ErrorsSandboxSign In
EN · 中文
Documentation

Get your first report in three steps

Lynxin captures behavioral signals on-device with a front-end SDK, then delivers a personality report to your back end over a webhook. Set up the receiving side first, then start the SDK — your first report lands on your webhook in about 5–15 minutes.

Before you start — no console access yet? Request it through Early Access; once approved, your account is provisioned with a client key (pk_) and a server key (sk_). You'll use three credentials (see Authentication): your tenantId (not shown in the console yet — contact us for it), a client key pk_ (console → Keys), and a webhook signing secret whsec_ you generate in Step 2. New to the key model? Skim Authentication first.

01 Receive the report on your back end

Expose one endpoint. Verify the signature with your webhook secret (whsec_, from Step 2), then store the report.

# ② Backend webhook receiver (verify with whsec_ → dedupe → correlate → store · sk_ for fallback fetch)
import hmac, hashlib, time

def verify(sig, ts, body, secret):        # body = raw request bytes
    if abs(time.time() - int(ts)) > 300:   # reject stale deliveries (>5 min) — replay protection
        raise ValueError("stale timestamp")
    msg = f"{ts}.".encode() + body          # timestamp + "." + raw body
    expected = "sha256=" + hmac.new(secret.encode(), msg, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, sig):
        raise ValueError("bad signature")

@app.post("/hooks/lynxin")
def on_report(request):
    verify(request.headers["X-Lynxin-Signature"],
           request.headers["X-Lynxin-Timestamp"],
           request.raw_body, WEBHOOK_SECRET)     # whsec_ webhook signing secret
    delivery_id = request.headers["X-Lynxin-Delivery"]
    if already_handled(delivery_id):             # a delivery can arrive more than once — dedupe by delivery ID
        return
    event = request.json
    if event["event"] == "analysis.completed":
        user_id = event["client_ref"]            # correlate to your user
        reports = event["result"]                # result.model1 = signal report · result.model2 = personality report
        save_report(user_id, reports)            # store permanently
    mark_handled(delivery_id)
    # fallback: within 30 days, fetch with sk_ via GET /v1/results?client_ref=user_20394

02 Configure the webhook once

In the console: point the Callback URL at your Step-1 endpoint, generate the signing secret (whsec_), pick events, then Send a test event to confirm your endpoint verifies the signature and receives it. (Testing locally? A test event can't reach localhost — expose your endpoint with a tunnel such as ngrok and point the Callback URL at the public URL.)

03 Trigger from the front end

Add the SDK and call ingestAndAnalyze(). The client key you use needs Personality Profiling enabled (it is on by default for new keys); about 5–15 minutes later, two reports — the signal report and the personality report — reach your backend through your webhook.

import { PhaseSense } from "@lynxin/sdk-web";  // contact us for the SDK package — see the Web SDK page

const sdk = await PhaseSense.create({
  tenantId: "YOUR_TENANT_ID",
  apiKey: "pk_YOUR_KEY",          // uploads & triggers analysis — reads no reports unless enabled; usage is billed
  record: true,                   // required for upload / one-call
  consent: { assessment: true },
});
await sdk.attach(videoEl);        // your <video> element
await sdk.start();

// …later (e.g. a "Finish" button):
const r = await sdk.ingestAndAnalyze("user_20394");  // echoed back
Only need Lynxin Affect? After recording, call uploadAndSubmit(), which doesn't trigger analysis; your backend reads the Lynxin Affect report with your server key — see “Which product you get” on the client SDK page.
Names. Lynxin Affect = the signal report = model1 in callbacks; its key permission is Behavioral Sensing. Lynxin Persona = the personality report = model2; its key permission is Personality Profiling.
First call ≠ first report. Your first call (ingestAndAnalyze()) is minutes of work; your first report lands on your webhook 5–15 minutes later — a report is a post-session computation, not an instant response.

04 Next steps