Skip to content
OpenTrain AIOpenTrain AIOpenTrain AIDocs

Ask OpenTrain

Answers from the documentation, with sources.

What would you like to do with OpenTrain?

AI answers can be mistaken. Check the linked sources. Don’t include private account information.

Open app

DEVELOPER DOCUMENTATION

Hosted LMS visual preview

Render the real worker course player, execute safe preview-only steps, and share short-lived employer review and no-login preview links without creating learner progress.

Hosted LMS visual preview lets an authorized employer or agent inspect the real worker course player without a local browser, a development server, or a worker account. It uses the same isolated Preview session as the existing LMS preview workflow.

Base path: /api/public/v1/lms/preview
  1. Create or restore a Preview session pinned to an exact draft revision or published course version.
  2. Select the module, lesson, or supported item with the normal session manage operation.
  3. Call render with the current expectedStateRevision.
  4. Inspect the returned PNG, ARIA snapshot, diagnostics, and provenance manifest artifacts.
  5. Use step only when you need to test one supported interaction.
  6. Optionally mint an observe-only link for a signed-in employer organization member, then revoke it when review is complete.

To show a published course to an employer who has no OpenTrain account, use a no-login employer preview link instead. It does not need a Preview session.

MethodPathPurpose
POST/sessions/{sessionId}/renderCapture the session’s current focus in desktop, mobile, or both viewports.
POST/sessions/{sessionId}/stepExecute one closed preview-only action and return before/after evidence.
POST/sessions/{sessionId}/linksMint a short-lived, observe-only employer review link.
GET/sessions/{sessionId}/linksList link records without recovering their secret URLs.
GET/sessions/{sessionId}/links/{linkId}Read one link’s lifecycle status.
POST/sessions/{sessionId}/links/{linkId}/revokeRevoke one review link.
GET/sessions/{sessionId}/artifactsList bounded Preview evidence records.
GET/artifacts/{artifactId}Read one ready artifact with a short-lived signed URL.

The OpenAPI document also describes the existing session create, restore, selection, answer, simulated-run, reset, and expiration operations.

POST /sessions/{sessionId}/render requires lms:write, an Idempotency-Key, and the current state revision:

{
"expectedStateRevision": 7,
"viewports": ["desktop", "mobile"],
"moduleKey": "reconciliation",
"lessonKey": "cutoff-testing"
}

The optional target fields are assertions. They do not navigate. Select the target first, then render it. A mismatch fails closed instead of producing a mislabeled screenshot.

The response contains:

  • evidenceClass: "SIMULATED_WORKER_PREVIEW";
  • the exact state and render revisions;
  • private PNG artifact records;
  • an ARIA snapshot for semantic inspection;
  • renderer diagnostics; and
  • a provenance manifest binding every artifact to the session, target, viewport, revision, checksum, and byte size.

POST /sessions/{sessionId}/step accepts a closed action vocabulary. It never accepts CSS selectors, JavaScript, arbitrary URLs, coordinates, or free-form browser instructions.

{
"op": "complete_content",
"lessonKey": "cutoff-testing",
"expectedStateRevision": 7,
"capture": "before_after",
"viewport": "desktop"
}

Supported actions in this release are open_lesson and complete_content. The receipt reports the canonical before and after state revisions and an outcome of APPLIED or ALREADY_SATISFIED.

POST /sessions/{sessionId}/links returns the URL exactly once. Treat it as a short-lived secret. Its fragment token is exchanged once for an HttpOnly cookie, and every read checks that the viewer is currently signed in as a member of the Preview session’s employer organization.

Links are observe-only. Opening one never changes the Preview session. Module and lesson deep links are supported. Exact-question links currently fail with ITEM_LINK_UNAVAILABLE rather than silently opening a broader view.

Later link reads return only metadata and lifecycle status: ACTIVE, CONSUMED, REVOKED, or EXPIRED. They cannot recover the URL.

An employer preview link shows one published course version the way assigned AI trainers see it. The person who opens it does not need an OpenTrain login. It follows the same rules as a review link:

  • It opens once. A second open, from any browser, is refused. The page shows an Open preview button and uses the link only when the person clicks it, so an email security scanner that loads the page does not use it up.
  • It expires. ttlSeconds defaults to 3600. The link never outlives the preview it opens, which lasts 2 hours, so a larger ttlSeconds is capped without an error. Read link.expiresAt for the real expiry.
  • It never shows answers, rubrics, or grading keys.
  • You can revoke it at any time.
  • Every mint, open, and revoke writes an audit record.

These endpoints use the course path, not the Preview base path:

MethodPathPurpose
POST/api/public/v1/lms/courses/{courseId}/employer-linksMint a link. Pass courseVersionId to pin a version; omit it for the current published version.
GET/api/public/v1/lms/courses/{courseId}/employer-linksList link records. Filter with ?courseVersionId=.
POST/api/public/v1/lms/courses/{courseId}/employer-links/{linkId}/revokeRevoke one link.

The create response returns url exactly once. Treat it as a short-lived secret and send it only to the intended employer. List reads return the same lifecycle statuses as review links and cannot recover the URL.

Each link starts its own preview, and that preview counts toward your organization’s limit of 25 live previews until it expires, 2 hours after the mint. Revoking the link does not free that slot. Minting and revoking count toward the same 60 requests per minute as other preview writes; above that the API returns 429 RATE_LIMITED with retryAfterSeconds.

Only your organization can mint, list, or revoke links for its own courses. A course, version, or link that belongs to another organization returns 404 NOT_FOUND. A course with no published version returns 409.

The same operations are available as opentrain lms courses employer-link create|list|revoke --course <id> in the CLI and as the opentrain_lms_create_employer_preview_link, opentrain_lms_list_employer_preview_links, and opentrain_lms_revoke_employer_preview_link MCP tools.

  • Render, step, link creation, and link revocation require lms:write and a stable Idempotency-Key. This includes employer preview links.
  • Artifact and link reads require lms:read.
  • Every operation enforces organization ownership of the Preview session or, for employer preview links, of the course.
  • State-changing Preview operations use an expected revision and fail with 409 when the session changed.
  • Renderer unavailability or capacity returns a retryable 503. Reuse the same idempotency key after an uncertain response.
  • Signed artifact URLs expire. Retrieve the artifact again when an authorized reviewer needs a fresh URL.

@opentrain-ai/sdk 0.15.0 or later exposes the same contract through:

  • renderLmsPreviewHosted;
  • stepLmsPreviewHosted;
  • createLmsPreviewLink;
  • getLmsPreviewLink;
  • listLmsPreviewLinks; and
  • revokeLmsPreviewLink.

SDK 0.41.0 adds createLmsEmployerPreviewLink, listLmsEmployerPreviewLinks, and revokeLmsEmployerPreviewLink for employer preview links.

Use the machine-readable OpenAPI document for the complete request, response, and error schemas.