Node.js / TypeScript server integration
Install
Node.js 18+. Save the ES module JavaScript example as classroom.mjs, configure the environment and run node classroom.mjs.
npm install @eduskit/server-sdk@0.1.5
Classroom creation uses durationMinutes; the server calculates endsAt. npm 0.1.5 declares endsAt in CreateClassroomInput, so this example uses .mjs to pass the server input. TypeScript projects require an SDK build with matching declarations.
Create a classroom and issue a student credential
Set the backend environment variables. This example uses separate teacher and student accounts. Replace the example avatar URLs with accessible resources. Each run creates a new classroom; originId only makes user registration idempotent.
import { Eduskit, EduskitError } from '@eduskit/server-sdk';
function required(name) {
const value = process.env[name]?.trim();
if (!value) throw new Error(`Missing ${name}`);
return value;
}
export async function createDemoClassroom() {
const sdk = new Eduskit({
timeoutMs: 10_000,
client: {
baseUrl: required('EDU_SERVER_URL'),
appId: required('EDU_APP_ID'),
appKey: required('EDU_APP_KEY'),
appSecret: required('EDU_APP_SECRET'),
},
});
const teacher = await sdk.client.users.register({
originId: 'demo-teacher-001',
nickname: 'Teacher',
avatar: 'https://example.com/teacher.png',
});
const student = await sdk.client.users.register({
originId: 'demo-student-001',
nickname: 'Student',
avatar: 'https://example.com/student.png',
});
const classroom = await sdk.client.classrooms.create({
name: 'SDK integration',
startsAt: new Date(Date.now() + 15 * 60_000).toISOString(),
durationMinutes: 60,
teacherEduUserId: teacher.eduUserId,
studentEduUserIds: [student.eduUserId],
joinPolicy: 'invite_only',
});
const token = await sdk.client.auth.issueToken({
eduUserId: student.eduUserId,
originId: student.originId,
expiresIn: 3600,
});
return {
appId: token.appId,
classroomId: classroom.classroomId,
userId: student.eduUserId,
userToken: token.accessToken,
expiresAt: token.expiresAt,
};
}
try {
const entry = await createDemoClassroom();
console.log({ classroomId: entry.classroomId, userId: entry.userId });
} catch (error) {
if (error instanceof EduskitError) {
console.error({
code: error.errorCode,
status: error.status,
traceId: error.traceId,
source: error.source,
});
} else {
console.error(error instanceof Error ? error.message : 'Unexpected error');
}
process.exitCode = 1;
}
Return userToken through your entry endpoint to the authenticated student. In production, create classrooms during scheduling and issue tokens when users enter.
Calling conventions
sdk.client / sdk.whiteboardClient; asynchronous methods return Promises. Supply fetch to inject HTTP transport.
See Classroom API for members, permissions, courseware and start/end methods. See Whiteboard server integration for recordings and conversion, and Errors and troubleshooting for failure and retry behavior.
Application and tenant APIs
Source builds provide 50 application-authenticated HTTP routes through client, including users, classrooms, courseware libraries, live assets, and diagnostics. See application business APIs and workflow examples. The separate tenant management client uses tenant sessions for account, application, dashboard, and billing operations. The new methods require the matching server-api deployment and a source build; public 0.1.5 packages do not include them.