Edit

Migrating Content into LearnHouse

This section explains how to bring existing course content into LearnHouse using the public API. There are two supported approaches:

  1. Programmatic Migration: you script every step (create the course, then chapters, then activities, then upload files). Use this when you need full control of the resulting structure. This is typical when migrating from another LMS where you already know the chapter/activity layout.
  2. AI-Assisted Migration: you upload a folder of media (videos, PDFs, images, audio) and LearnHouse asks the configured AI model to propose a chapter/activity tree. You review and confirm, and a single endpoint creates the entire course in one transaction. Use this when you have a pile of files but no predefined structure.

Moving from Moodle, Canvas, Blackboard, Brightspace, Open edX or another Common Cartridge platform? You don't need to script anything: upload the course export from the dashboard and LearnHouse converts it. See Import from Another LMS.

Both approaches share the same underlying data model: a Course contains Chapters, and each Chapter contains an ordered list of Activities.

All endpoints below are prefixed with /api/v1/. In local development the base URL is http://localhost:1338/api/v1/. In production it is served at /api/v1/ on your instance domain.

Authentication

Every migration call must be authenticated. There are two token types:

  • JWT access tokens (POST /api/v1/auth/login): a user session, 8-hour lifetime, refreshable.
  • API tokens (lh_…): issued per organization, valid until revoked or until their optional expiry date. On LearnHouse Cloud they need the Pro plan or higher.

Both are sent the same way:

curl http://localhost:1338/api/v1/courses/?org_id=1 \
  -H "Authorization: Bearer lh_your_api_token_here"

API tokens are bound to a single organization at creation time. Any attempt to operate on a different org_id is rejected at the auth layer, so a leaked token cannot reach across tenants.

Endpoint groupAPI tokenJWT
POST /courses/, PUT /courses/{uuid}, DELETE /courses/{uuid}✓✓
POST /chapters/, PUT /chapters/{id}/..., DELETE /chapters/{id}✓✓
POST /activities/, /activities/video, /activities/external_video, /activities/documentpdf✓✓
POST /blocks/{image,video,pdf,audio}✗✓
POST /assignments/, POST /assignments/{uuid}/tasks✓✓
POST /courses/migrate/upload / /suggest / /create✗✓

The media block endpoints and the AI-assisted migration endpoints reject an lh_* API token with 403 "API tokens cannot access this resource". For both, use the admin token-swap to mint a JWT first (see the callout above).

See API Authentication for creating tokens and choosing their rights.

The data model in one diagram

Organization (org_id)
└── Course (course_uuid, course_id)
    └── Chapter (chapter_uuid, chapter_id)
        └── Activity (activity_uuid, activity_id)
            └── (optional) Block (block_uuid)  ← media files referenced from a dynamic page

Two ID conventions to keep straight:

  • *_uuid strings (e.g. course_uuid, activity_uuid, chapter_uuid) are the public identifiers used in URLs and most GET endpoints.
  • *_id integers (e.g. course_id, chapter_id) are the internal primary keys. They are required when creating a child resource (a chapter needs course_id, an activity needs chapter_id).

Both are returned in every create response, so capture them as you go.

Activity types at a glance

activity_typeactivity_sub_typeWhat it isHow content is supplied
TYPE_DYNAMICSUBTYPE_DYNAMIC_PAGERich-text page (TipTap / ProseMirror)JSON document in content
TYPE_DYNAMICSUBTYPE_DYNAMIC_MARKDOWNPage rendered from a remote Markdown URLcontent: { markdown_url }
TYPE_DYNAMICSUBTYPE_DYNAMIC_EMBEDIframe embed (Google Doc, Notion, etc.)content: { embed_url }
TYPE_DYNAMICSUBTYPE_DYNAMIC_RESOURCEA file or other resource picked from the Librarycontent: { resource_uuid, resource_type }
TYPE_VIDEOSUBTYPE_VIDEO_HOSTEDSelf-hosted video fileMultipart upload to /activities/video
TYPE_VIDEOSUBTYPE_VIDEO_YOUTUBEEmbedded YouTube / Vimeo videoJSON POST /activities/external_video
TYPE_DOCUMENTSUBTYPE_DOCUMENT_PDFPDF documentMultipart upload to /activities/documentpdf
TYPE_DOCUMENTSUBTYPE_DOCUMENT_DOCGeneric documentReserved, not exposed via a dedicated upload endpoint
TYPE_ASSIGNMENTSUBTYPE_ASSIGNMENT_ANYGraded assignment with tasksThree-step: activity shell + assignment record + at least one task
TYPE_CUSTOMSUBTYPE_CUSTOMFree-form structured contentJSON content of any shape
TYPE_SCORMSUBTYPE_SCORM_12 / SUBTYPE_SCORM_2004SCORM packages (Enterprise)Reserved, handled by the SCORM uploader
TYPE_LIVE_SESSIONSUBTYPE_LIVE_SESSIONA live session linked to the course (Enterprise)Created by scheduling a session, not for migration

The full per-type content JSON schemas, including the dynamic page block list, are documented in Activity Types Reference.

Quick start: the four building blocks

A complete migration boils down to four call types, in order:

  1. Create a course. POST /api/v1/courses/?org_id={org_id} (multipart). Capture course_uuid and id from the response.
  2. Create chapters. POST /api/v1/chapters/ (JSON), one per chapter, passing course_id and org_id. Capture each chapter's id.
  3. Create activities. Either the generic POST /api/v1/activities/ (JSON, for dynamic / embed / markdown / custom / assignment shells) or one of the typed endpoints /activities/video, /activities/external_video, /activities/documentpdf (multipart, for hosted media).
  4. (Optional) Upload media blocks referenced from a dynamic page via /api/v1/blocks/{image,video,pdf,audio} (multipart) and embed them in the page's TipTap content.

A copy-pasteable bash script for the full flow lives in Programmatic Migration.

Common pitfalls

Set published: false while migrating and flip it to true only once you have spot-checked the result. Unpublished activities are returned by GET /courses/{course_uuid}/meta?with_unpublished_activities=true so you can preview the final tree before exposing it to learners.

Where to next