Skip to main content
This is a Backend SDK method, not an HTTP endpoint. Call it from your server — never from the browser.

Install

npm install @recordorg/smartai-assessment-backend

Initialise

const AssessmentClient = require('@recordorg/smartai-assessment-backend');

const client = new AssessmentClient({
  apiKey:    process.env.ASSESSMENT_API_KEY,
  secretKey: process.env.ASSESSMENT_SECRET_KEY,
});

Signature

client.createSession({ users, recruiterId?, recruiterEmail? }): Promise<SessionToken>

Parameters

users
array
required
Array of candidate objects. Must have at least one item.
Example
[
  { "name": "Priya Sharma",  "email": "priya@example.com" },
  { "name": "Rahul Verma",   "email": "rahul@example.com" }
]
recruiterId / recruiter_id
string
Your internal recruiter ID. You can pass this or recruiterEmail — at least one is required. You may pass both.
recruiterEmail / recruiter_email
string
The recruiter’s email address. You can pass this or recruiterId — at least one is required. You may pass both.

Return value

token
string
A session token (JWT). Pass this directly to AssessmentPortal.open({ token }) in your frontend. Do not cache or store it — request a fresh one every time.

const session = await client.createSession({
  users: [
    { name: 'Priya Sharma', email: 'priya@example.com' },
    { name: 'Rahul Verma',  email: 'rahul@example.com' },
  ],
  recruiterEmail: 'admin@yourcompany.com',
});

console.log(session.token); // → 'eyJhbGci...'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uSWQiOiJzZXNzXzAxIn0.HMAC"
}

Error cases

ConditionError message
Neither recruiterId nor recruiterEmail providedProvide at least one of recruiterId or recruiterEmail — pass one or both
users is an empty array / listusers must be a non-empty array
name missing in single modename is required
email missing in single modeemail is required
Invalid API keyHTTP 401 from SmartAI platform
ASSESSMENT_API_KEY not setMissing API key