TypeScript SDK

@cohesionauth/sdk on npm. Typed, retry-aware, Edge-runtime compatible.

Official TypeScript SDK for the COHESION scoring API.

What this is

Typed wrapper around the HTTP API. Works in Node.js 20+, Bun, Cloudflare Workers, and other WHATWG fetch environments.

Install

npm install @cohesionauth/sdk

Quickstart

import { Cohesion } from "@cohesionauth/sdk";

const client = new Cohesion({ apiKey: process.env.COHESION_API_KEY! });

const result = await client.score({
  session_id: "sess-001",
  operator_id: "analyst-42",
  domain: "financial",
  interaction: {
    ai_recommendation_presented: true,
    time_to_decision_ms: 1800,
    decision: "modified",
    modification_extent: 0.3,
    ai_available: true,
    scenario_type: "standard",
    outcome_correct: null,
    hover_events: 2,
    scroll_depth: 0.7,
    alternative_views_checked: 1,
  },
});

console.log(`JIS ${result.jis} (${result.band})`);

More