Saved trains
Build formations, set driving profiles, group functions and assign trains to layouts.
Source 0.1.0 Private source package
How the calls fit together
Read the saved train and its settings before editing. Retain reviewed versions; saving settings does not change or restart a moving train.
JavaScript examples
Supply your configured client. Each call awaits a decoded result; errors pass to your caller. These identifiers and values are fictional. Use selected development records and review every change before running it. Opening this page sends no API requests.
See the complete TypeScript workflow · Explore the Node starter
trainFormations.list
Lists account-owned train formations.
const result = await client.trainFormations.list(
"account 1",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formations.
options· optionalRailDeckRequestControlOptionsOptional filters or request controls shown in the type. The example demonstrates the supplied fields.
Returns Promise<RailDeckTrainFormationListResponse>.
Example evidence: Retained SDK transport fixture.
trainFormations.getFunctionGrouping
Loads the train's complete function grouping for viewing or review.
const result = await client.trainFormations.getFunctionGrouping(
"23",
"12",
{}
);TypeScript parameters and return type
accountId· requiredstringOwning account.
trainFormationId· requiredstringSelected train.
options· optionalRailDeckRequestControlOptionsOptional cancellation for retired readers.
Returns Promise<TrainFunctionGrouping>.
Example evidence: Retained SDK transport fixture.
trainFormations.saveFunctionGrouping
Saves one complete, reviewed train grouping without replaying uncertain writes.
const result = await client.trainFormations.saveFunctionGrouping(
"23",
"12",
{
"expectedRevision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"groups": [
{
"key": "function:8",
"label": "Short horn",
"functionIds": [
"8"
]
}
]
}
);TypeScript parameters and return type
accountId· requiredstringOwning account.
trainFormationId· requiredstringSelected train.
input· requiredSaveTrainFunctionGroupingSource revision and desired groups.
Returns Promise<TrainFunctionGrouping>.
Example evidence: Retained SDK transport fixture.
trainFormations.previewDuplication
Reviews every vehicle in a train.
const result = await client.trainFormations.previewDuplication(
"23",
"9",
{}
);TypeScript parameters and return type
accountId· requiredstringAuthorised account containing the selected railway records.
id· requiredstringIdentifier of the explicitly selected record in your authorised development environment.
options· optionalRailDeckRequestControlOptionsOptional filters or request controls shown in the type. The example demonstrates the supplied fields.
Returns Promise<RailDeckTrainDuplicationPreview>.
Example evidence: Retained SDK transport fixture.
trainFormations.duplicate
Atomically copies the complete train and its vehicles.
const result = await client.trainFormations.duplicate(
"23",
"9",
{
"displayName": "{{fixtureDisplayName}}",
"expectedSourceRevision": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"includeNotes": true,
"includePhotographs": true
}
);TypeScript parameters and return type
accountId· requiredstringAuthorised account containing the selected railway records.
id· requiredstringIdentifier of the explicitly selected record in your authorised development environment.
input· requiredDuplicateRailDeckTrainInputThe operation input. Use the complete typed shape shown in the example and retain reviewed versions for writes.
Returns Promise<RailDeckTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.getDrivingSettings
Loads train-owned choices, retaining inheritance instead of copying locomotive settings.
const result = await client.trainFormations.getDrivingSettings(
"account 1",
"train 1",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierOwning account.
trainFormationId· requiredRailDeckIdentifierSaved train whose settings were opened.
options· optionalRailDeckRequestControlOptionsOptional cancellation.
Returns Promise<RailDeckTrainDrivingSettings>.
Example evidence: Retained SDK transport fixture.
trainFormations.saveDrivingSettings
Saves complete style/handling choices without changing formation members.
const result = await client.trainFormations.saveDrivingSettings(
"account 1",
"train 1",
{
"expectedRevision": 0,
"style": {
"mode": "inherit"
},
"handling": {
"mode": "none"
}
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierOwning account.
trainFormationId· requiredRailDeckIdentifierSaved train being configured.
input· requiredSaveRailDeckTrainDrivingSettingsInputChoices and revision retained when opened.
Returns Promise<RailDeckTrainDrivingSettings>.
Example evidence: Retained SDK transport fixture.
trainFormations.listLayoutAssignments
Lists train formations assigned to one layout.
const result = await client.trainFormations.listLayoutAssignments(
"account 1",
"layout 1",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the layout.
layoutId· requiredRailDeckIdentifierLayout whose train formations should be listed.
options· optionalRailDeckRequestControlOptionsOptional filters or request controls shown in the type. The example demonstrates the supplied fields.
Returns Promise<RailDeckLayoutTrainFormationListResponse>.
Example evidence: Retained SDK transport fixture.
trainFormations.create
Creates one account-owned train formation.
const result = await client.trainFormations.create(
"account 1",
{
"displayName": "{{fixtureDisplayName}}",
"members": [
{
"memberType": "locomotive",
"memberId": "loco-1"
},
{
"memberType": "rolling_stock",
"memberId": "stock-1",
"loadState": "laden"
}
]
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that will own the train formation.
input· requiredCreateRailDeckTrainFormationInputTrain formation details and optional initial members.
Returns Promise<RailDeckTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.assignToLayout
Assigns an account train formation to a layout.
const result = await client.trainFormations.assignToLayout(
"account 1",
"layout 1",
{
"trainFormationId": "formation-2",
"displayOrder": 2,
"isActive": true
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the layout and train formation.
layoutId· requiredRailDeckIdentifierLayout receiving the train formation assignment.
input· requiredAssignRailDeckTrainFormationToLayoutInputTrain formation id and optional display settings.
Returns Promise<RailDeckLayoutTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.get
Loads one account-owned train formation.
const result = await client.trainFormations.get(
"account 1",
"formation-2",
{}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formation.
trainFormationId· requiredRailDeckIdentifierTrain formation to load.
options· optionalRailDeckRequestControlOptionsOptional filters or request controls shown in the type. The example demonstrates the supplied fields.
Returns Promise<RailDeckTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.getHandlingProfile
Loads the advisory handling profile for one train formation.
const result = await client.trainFormations.getHandlingProfile(
"account 1",
"formation-2"
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formation.
trainFormationId· requiredRailDeckIdentifierTrain formation whose handling profile should be loaded.
Returns Promise<RailDeckTrainFormationHandlingProfile>.
Example evidence: Retained SDK transport fixture.
trainFormations.update
Updates one account-owned train formation.
const result = await client.trainFormations.update(
"account 1",
"formation-2",
{
"displayName": "{{fixtureDisplayName}}",
"expectedUpdatedAt": "2026-07-02T09:00:00.000Z"
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formation.
trainFormationId· requiredRailDeckIdentifierTrain formation to update.
input· requiredUpdateRailDeckTrainFormationInputChanged fields and the updatedAt version retained when opened.
Returns Promise<RailDeckTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.updateLayoutAssignment
Updates display state for a train formation assigned to a layout.
const result = await client.trainFormations.updateLayoutAssignment(
"account 1",
"layout 1",
"formation-2",
{
"isActive": false
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the layout and train formation.
layoutId· requiredRailDeckIdentifierLayout containing the assignment.
trainFormationId· requiredRailDeckIdentifierTrain formation assignment to update.
input· requiredUpdateRailDeckLayoutTrainFormationInputPartial layout assignment update.
Returns Promise<RailDeckLayoutTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.replaceMembers
Replaces all ordered members for one train formation.
const result = await client.trainFormations.replaceMembers(
"account 1",
"formation-2",
{
"expectedUpdatedAt": "2026-07-02T09:00:00.000Z",
"members": [
{
"memberType": "locomotive",
"memberId": "loco-1",
"displayOrder": 0
}
]
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formation.
trainFormationId· requiredRailDeckIdentifierTrain formation receiving replacement members.
input· requiredReplaceRailDeckTrainFormationMembersInputComplete replacement members and the updatedAt version retained when opened.
Returns Promise<RailDeckTrainFormation>.
Example evidence: Retained SDK transport fixture.
trainFormations.delete
Deletes one account-owned train formation.
const result = await client.trainFormations.delete(
"account 1",
"formation-2",
{
"expectedUpdatedAt": "2026-07-02T09:00:00.000Z"
}
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the train formation.
trainFormationId· requiredRailDeckIdentifierTrain formation to delete.
input· requiredDeleteRailDeckTrainFormationInputThe updatedAt version reviewed before deletion.
Returns Promise<RailDeckSuccessResponse>.
Example evidence: Retained SDK transport fixture.
trainFormations.removeFromLayout
Removes one train formation assignment from a layout.
const result = await client.trainFormations.removeFromLayout(
"account 1",
"layout 1",
"formation-2"
);TypeScript parameters and return type
accountId· requiredRailDeckIdentifierAccount that owns the layout and train formation.
layoutId· requiredRailDeckIdentifierLayout containing the assignment.
trainFormationId· requiredRailDeckIdentifierTrain formation assignment to remove.
Returns Promise<RailDeckSuccessResponse>.
Example evidence: Retained SDK transport fixture.
Download all TypeScript method examples
JavaScript calls and TypeScript downloads are checked through the real SDK using local response fixtures. This verifies the calls and decoding for those fixtures.
The complete TypeScript workflow
Follow how the calls fit together, including the review and recovery steps. Supply your configured client and explicitly selected development records. Importing the download performs no requests; mutations are never retried automatically.
import type { RailDeckDirectIntegrationClient as Client } from '@raildeck/frontend-sdk/direct-integration';
/**
* Read a formation and its driving settings for review.
* @param client - Configured client; the caller owns current authority.
* @param accountId - Authorised account for this workflow.
* @param trainId - Explicitly selected saved train.
* @param signal - Caller-owned cancellation signal.
* @returns The saved train and original settings revision.
*/
export async function openSavedTrain(
client: Client,
accountId: string,
trainId: string,
signal: AbortSignal,
) {
const options = { signal, timeoutMs: 15_000 };
const train = await client.trainFormations.get(accountId, trainId, options);
const settings = await client.trainFormations.getDrivingSettings(accountId, trainId, options);
return { train, settings };
}
/**
* Change a confirmed saved style while retaining reviewed handling and revision.
* @param client - Configured client; the caller owns current authority.
* @param accountId - Authorised account for this workflow.
* @param trainId - Explicitly selected saved train.
* @param opened - Record retained from the review that authorised this change.
* @param style - Driving style explicitly chosen for the saved train.
* @returns Saved settings; saving them does not restart a moving train.
*/
export async function saveReviewedTrainStyle(
client: Client,
accountId: string,
trainId: string,
opened: Awaited<ReturnType<Client['trainFormations']['getDrivingSettings']>>,
style: Parameters<Client['trainFormations']['saveDrivingSettings']>[2]['style'],
) {
return client.trainFormations.saveDrivingSettings(accountId, trainId, {
expectedRevision: opened.revision, style, handling: opened.handling,
});
}
Download TypeScript example