SDK

@learnhouse/sdk is a typed client generated from the same OpenAPI document as this reference. Any method and path listed here is a typed call.

Install and connect

The SDK has no runtime dependencies and runs in browsers, Node 18+, Bun, Deno, edge workers and React Native. Its version matches the LearnHouse release it was generated from. The full documentation lives at Developers → SDK.

Installnpm
npm install @learnhouse/sdk
Create a clientTypeScript
import { createClient } from "@learnhouse/sdk";

// Server: an lh_ API token
const lh = createClient({
  baseUrl: "https://api.learnhouse.io", // origin only, without /api/v1
  token: process.env.LEARNHOUSE_TOKEN,
});

// Browser on your LearnHouse domain: the session cookie
const web = createClient({ baseUrl: "https://api.learnhouse.io", credentials: "include" });

From endpoint to call

Take the method and path exactly as an endpoint page shows them. The method becomes lh.GET, lh.POST, lh.PUT, lh.PATCH or lh.DELETE; the path stays a template. Path parameters go in params.path, query parameters in params.query and the request body in body. Paths autocomplete, and a wrong parameter is a compile error. Calls return the response data or throw a LearnHouseError (see Errors).

MappingTypeScript
// GET /api/v1/courses/{course_uuid}/meta?slim=true
const meta = await lh.GET("/api/v1/courses/{course_uuid}/meta", {
  params: {
    path: { course_uuid: "course_…" },  // {placeholders} in the path
    query: { slim: true },              // query parameters
  },
});

// POST /api/v1/chapters/ with a JSON body
const chapter = await lh.POST("/api/v1/chapters/", {
  body: { name: "Week 2", course_id: 12, org_id: 1 },
});

// multipart/form-data: pass a FormData body
const form = new FormData();
form.append("thumbnail", file);
await lh.PUT("/api/v1/courses/{course_uuid}/thumbnail", {
  params: { path: { course_uuid: "course_…" } },
  body: form,
});

Every endpoint's code panel has an SDK tab with the full call, and with your token pasted in, it is ready to run.

One call per group

EndpointSDK call
AuthenticationGET/auth/mfa/org-policy/{org_id}lh.GET("/api/v1/auth/mfa/org-policy/{org_id}", { params: { path: { org_id: … } } })
API TokensGET/orgs/{org_id}/api-tokenslh.GET("/api/v1/orgs/{org_id}/api-tokens", { params: { path: { org_id: … } } })
OrganizationsGET/orgs/uuid/{org_uuid}lh.GET("/api/v1/orgs/uuid/{org_uuid}", { params: { path: { org_uuid: … } } })
UsersGET/users/authorize/ressource/{ressource_uuid}/action/{action}lh.GET("/api/v1/users/authorize/ressource/{ressource_uuid}/action/{action}", { params: { path: { ressource_uuid: …, action: … } } })
User GroupsGET/usergroups/{usergroup_id}lh.GET("/api/v1/usergroups/{usergroup_id}", { params: { path: { usergroup_id: … } } })
CoursesGET/courses/import/lms/analyze/{temp_id}lh.GET("/api/v1/courses/import/lms/analyze/{temp_id}", { params: { path: { temp_id: … }, query: { org_id: … } } })
ChaptersGET/chapters/{chapter_id}lh.GET("/api/v1/chapters/{chapter_id}", { params: { path: { chapter_id: … } } })
ActivitiesGET/activities/{activity_uuid}/versionslh.GET("/api/v1/activities/{activity_uuid}/versions", { params: { path: { activity_uuid: … } } })
BlocksGET/blocks/imagelh.GET("/api/v1/blocks/image", { params: { query: { block_uuid: … } } })
AssignmentsGET/assignments/{assignment_uuid}lh.GET("/api/v1/assignments/{assignment_uuid}", { params: { path: { assignment_uuid: … } } })
FoldersGET/folders/{folder_uuid}lh.GET("/api/v1/folders/{folder_uuid}", { params: { path: { folder_uuid: … } } })
MediaGET/media/{media_uuid}/filelh.GET("/api/v1/media/{media_uuid}/file", { params: { path: { media_uuid: … } } })
CertificationsGET/certifications/{certification_uuid}lh.GET("/api/v1/certifications/{certification_uuid}", { params: { path: { certification_uuid: … } } })
PaymentsGET/payments/{org_id}/configlh.GET("/api/v1/payments/{org_id}/config", { params: { path: { org_id: … } } })
SearchGET/search/org_slug/{org_slug}lh.GET("/api/v1/search/org_slug/{org_slug}", { params: { path: { org_slug: … }, query: { query: … } } })
AnalyticsGET/analytics/dashboard/detail/{query_name}lh.GET("/api/v1/analytics/dashboard/detail/{query_name}", { params: { path: { query_name: … }, query: { org_id: … } } })
WebhooksGET/orgs/{org_id}/webhooks/eventslh.GET("/api/v1/orgs/{org_id}/webhooks/events")
HeadlessGET/admin/{org_slug}/courses/{course_uuid}/access/{user_id}lh.request("GET", "/api/v1/admin/{org_slug}/courses/{course_uuid}/access/{user_id}", { params: { path: { org_slug: …, course_uuid: …, user_id: … } } })

Untyped routes

The SDK's generated types leave out internal, dev, demo, EE-only and headless admin routes. Those are still callable, without types, through lh.request(method, path, options), with the same auth, retries and errors. In this reference that applies to paths starting with /api/v1/internal, /api/v1/cloud_internal, /api/v1/dev, /api/v1/demo, /api/v1/ee, /api/v1/admin; their SDK tab already uses lh.request.