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

Folder Instructions API and SDK

Shared folder inventory, reviewed activation and migration, recovery, and scope-aware authoring contracts.

Use the shared folder guide for the complete safety workflow. All paths below are relative to https://app.opentrain.ai/api/public/v1/instructions/folders/{folderId}. Current employer authority is required for every request; token scopes alone do not grant access to another organization.

MethodSuffixSDK method
GETempty, optionally ?includeContent=truegetFolderInstructions
POST/changes/previewpreviewFolderInstructionChange
POST/changes/confirmconfirmFolderInstructionChange
GET/changes/{operationId}getFolderInstructionChange
POST/changes/{operationId}/applyapplyFolderInstructionChange
POST/changes/{operationId}/cancelcancelFolderInstructionChange
POST/changes/{operationId}/resumeresumeFolderInstructionChange
GET/changes/{operationId}/recoveryexportFolderInstructionRecovery

Preview accepts the guide’s strict ACTIVATE, APPEND or REVERSE request. Confirmation accepts { request, reviewedPlanDigest, confirmed: true }. Apply/cancel/resume accept an empty JSON object; their operation ID already identifies the confirmed request. Unknown fields are rejected.

Inventory, preview, status and recovery require instructions:read. Lifecycle writes require instructions:write. The existing verified-account requirement also applies to POST preview. Read and preview do not create operations, checkpoints or pages.

The TypeScript SDK returns typed domain results and throws typed API errors:

import { OpenTrainClient, type FolderInstructionOperationRequest } from "@opentrain-ai/sdk";
const api = new OpenTrainClient({ apiToken: process.env.OPENTRAIN_API_KEY! });
const folderId = "your-folder-id";
const inventory = await api.getFolderInstructions(folderId, { includeContent: true });
const request: FolderInstructionOperationRequest = {
kind: "APPEND",
idempotencyKey: "copy-reviewed-language-guide-v1",
sources: [{ jobId: "source-job-id", pageIds: ["source-page-id"], label: "French" }],
newPages: [],
};
const plan = await api.previewFolderInstructionChange(folderId, request);
// Inspect the complete plan and canApply before any confirmation.

Do not automatically confirm an example. After reviewing an applicable plan, call confirmFolderInstructionChange(folderId, { request, reviewedPlanDigest: plan.planDigest, confirmed: true }), save its operation ID, and respect quiesceReadyAt. Check status and apply the same operation; require verified readback before treating it as complete.

Folder authoring uses the same page/tree/document contracts as job authoring, with explicit folderId and canonicalSource: "FOLDER_INSTRUCTION_SET". Existing job paths and SDK methods remain unchanged.

AreaFolder suffixes
Active tree and pageGET /pages, GET /pages/{pageId}
Preview and preflightPOST /preview, POST /preflight
Page writesPOST /pages, PUT/PATCH/DELETE /pages/{pageId}
Atomic treePOST /tree/preflight, POST /tree/apply
ImagesPOST /assets/images/plan, POST /assets/images
VideosPOST /videos/prepare, GET /videos/{assetId}, POST /videos/{assetId}/cancel
History/pages/{pageId}/history and checkpoint read/compare/restore endpoints
SchemaPOST /pages/{pageId}/schema-upgrade
Links and verificationGET /pages/{pageId}/link, GET /verify, GET /visual-review

Authoring reads and no-write preflights require instructions:read; applied writes require instructions:write. Mutations use their documented explicit confirmation, checksum/preflight and receipt-key requirements. First activation must use migration rather than ordinary create. Incompatible published or unknown delivery refuses before mutation.

The SDK provides matching getFolderInstructionPage, preflightFolderInstructionOperation, createFolderInstructionPage, applyFolderInstructionTree, history/media/schema and other folder methods. Use the live OpenAPI document for complete closed request/response schemas and exact endpoint suffixes.

x-opentrain-authoring-retry in OpenAPI and the SDK’s FOLDER_INSTRUCTION_AUTHORING_RETRY describe exact-operation recovery. They do not make unkeyed mutations idempotent or safe to resend blindly. Schema status includes bounded current intent identity, revision and expiry; video cancellation distinguishes pending progress from an immutable READY asset.