Skip to content

startup-apps-backend-api

const StudioStartupHost: StartupAppsBackendApi;

StudioHost singleton that provides methods for apps to use on the backend.

PropertyType
activateBackend() => Promise<void>
deactivateBackend() => Promise<void>

PropertyTypeInherited from
activateBackend() => Promise<void>BackendAppModule.activateBackend
deactivateBackend() => Promise<void>BackendAppModule.deactivateBackend
startupOptions() => Promise<StudioHostConfigurableOpts>-

Props for downloading and opening a briefcase via Studio.

Type Parameter
T
PropertyTypeDescription
downloadProps?TCan be used to track & display progress. File name and briefcase id will be decided by Studio. Downloaded briefcase will always be a fully qualified one, allowing both pulling and pushing.
iModelIdstringiModel id
iTwinIdstringiTwin id
openFileProps?OpenBriefcaseFilePropsProps for opening briefcase via Studio. briefcase location and path is fully controlled by Studio.
upgradeSchemas?UpgradeSchemasIf set, schema versions will be checked & upgraded if they are outdated. See BriefcaseDb.validateSchemas and BriefcaseDb.upgradeSchemas for more details. Defaults to not upgrading schemas.

Options for executing code in a sandbox. until 2026.09

PropertyTypeDescription
signal?AbortSignalOptional abort signal to cancel execution. Aborting will terminate the sandbox. :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
timeoutMs?numberOptional timeout in milliseconds. Defaults to 30_000ms. :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::

Handle returned from StudioStartupHost.createSandbox. until 2026.09 This api is experimental and may change or be removed in future releases for better alternatives.

execute(code, options?): Promise<unknown>;

Executes code in the sandbox and returns the result.

ParameterTypeDescription
codestringThe JavaScript code to execute. Use ‘return’ to return a value.
options?SandboxExecuteOptionssee SandboxExecuteOptions.

Promise<unknown>

A promise that resolves with the execution result.

Error if the sandbox is disposed, execution fails, or times out. Callers should wrap this in a try-catch to handle execution errors gracefully.

try {
const result = await sandbox.execute("return 2 + 2");
console.log(result); // 4
} catch (err) {
console.error("Sandbox execution failed:", err);
sandbox.exit();
}
PropertyTypeDescription
exit() => voidCloses the sandbox window and cleans up resources. After calling this, the sandbox is no longer usable. :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::

Options for creating a sandbox. until 2026.09

PropertyTypeDescription
api?Record<string, SandboxApiFunction>API methods to expose to the sandbox. Each method must be an async function that accepts serializable arguments and returns a serializable value. The sandbox can call these methods via the global api object. Example const sandbox = await StudioStartupHost.createSandbox({ api: { add: async (a: number, b: number) => a + b, greet: async (name: string) => Hello, ${name}!, }, }); const result = await sandbox.execute("return api.add(2, 3)"); // result === 5 :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::

Backend API for startup apps, including functions imported from StudioBackendApi.

addUserPreferencesSchemaFile(schemaPath): Promise<void>;

Adds a schema json file to the user preferences.

ParameterTypeDescription
schemaPathstringPath to the schema json file.

Promise<void>

StudioBackendApi.addUserPreferencesSchemaFile

appChannel(channel): string;

Wraps given IPC channel name with a prefix matching the app name. Ensures IPC channel is unique among apps. Not using this wrapper might cause IPC channel name clashes among different apps. Use StudioApp.appChannel to wrap the IPC channel in the frontend.

ParameterTypeDescription
channelstringunique channel name within your app.

string

channel name that is unique among loaded apps.

StudioBackendApi.appChannel

appInstallPath(): string;

gets the locations where the application bundle, assets or schema sub-folders resides

string

attachRpcInterface<T>(definition): void;

Attach an RPC interface to the backend.

Type Parameter
T extends RpcInterface
ParameterTypeDescription
definitionRpcInterfaceDefinition<T>RPC interface definition.

void

StudioBackendApi.attachRpcInterface

closeBriefcase(key): void;

closes briefcase connection

ParameterTypeDescription
keystring

void

deleteBriefcase(key): Promise<void>;

Delete existing briefcase, releasing its briefcase id. If briefcase is still open, this will close it. Note - should be extremely sparingly. All local changes, including those made by other Studio apps, will be lost. until 2026.09

ParameterType
keystring

Promise<void>

downloadAndOpenBriefcase(args): Promise<BriefcaseDb>;

Opens a briefcase, downloading it if it does not exist on disk.

ParameterType
argsDownloadAndOpenArgs<DownloadBriefcaseProps>

Promise<BriefcaseDb>

error if DownloadAndOpenArgs.upgradeSchema is true and the schema is too old or too new.

finalizeFrontendInitData(jsonData): void;

Sets the initialization or configuration data for the app’s frontend. This function must be invoked before calling StudioApp.getFrontendInitData() in the frontend. If not invoked, the StudioApp.getFrontendInitData() function will time out. Ideally, finalizeFrontendInitData() should be called at the very beginning of activateBackend().

ParameterTypeDescription
jsonDataRecord<string, JSONSchemaType>JSON object containing initialization data.

void

A Promise that resolves when the data is finalized.

StudioBackendApi.finalizeFrontendInitData

getLocations(): Promise<StudioLocations>;

Returns the locations of folders used by iTwin Studio for storing application-specific files.

Promise<StudioLocations>

StudioBackendApi.getLocations

getUrlEnvironmentPrefix(): UrlEnvironmentPrefix;

UrlEnvironmentPrefix

the current environment prefix iTwinStudio is in.

it returns url prefix like “dev-”, “qa-” or ""

StudioBackendApi.getUrlEnvironmentPrefix

getUserEntitlement(iTwinId): Promise<Entitlement>;

Get user entitlement for the application.

ParameterTypeDescription
iTwinIdstringId of the iTwin.

Promise<Entitlement>

User entitlement information.

getUserPreference(preferenceName): undefined | JSONSchemaType;

Gets a user preference from the user preferences.

ParameterTypeDescription
preferenceNamestringName of the preference.

undefined | JSONSchemaType

StudioBackendApi.getUserPreference

initializeTelemetry(
instrumentalKey,
enableAutoTracking?,
recordExceptions?): void;

Initialize telemetry service

ParameterTypeDescription
instrumentalKeystringinstrumental key for app insights
enableAutoTracking?booleanallow you to configure autoTracking for appInsights, false by default.
recordExceptions?booleanallow Studio to post unhandled exceptions for you, true by default.

void

if instrumental key is undefined or empty string then this method throws

StudioBackendApi.initializeTelemetry

logError(error, metaData?): void;

Logs an error, with the category being the app name.

ParameterTypeDescription
errorstringError message.
metaData?LoggingMetaDataAdditional metadata.

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

StudioBackendApi.logError

logException(exception): void;

Logs an exception, with the category being the app name.

ParameterTypeDescription
exceptionunknownException object.

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

StudioBackendApi.logException

logInfo(info, metaData?): void;

Logs an info level message, with the category being the app name.

ParameterTypeDescription
infostringInfo message.
metaData?LoggingMetaDataAdditional metadata.

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

StudioBackendApi.logInfo

logTrace(trace, metaData?): void;

Logs a trace, with the category being the app name.

ParameterTypeDescription
tracestringTrace message.
metaData?LoggingMetaDataAdditional metadata.

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

StudioBackendApi.logTrace

logWarning(warning, metaData?): void;

Logs a warning, with the category being the app name.

ParameterTypeDescription
warningstringWarning message.
metaData?LoggingMetaDataAdditional metadata.

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

StudioBackendApi.logWarning

postFeatureUsage(featureGuid): Promise<void>;

Posts feature usage to the licensing service.

ParameterTypeDescription
featureGuidstringFeature guid against which the feature is tracked.

Promise<void>

Only works in iTwinStudio standard edition in the prod env and iTwinStudio standard edition beta builds for the qa env, and requires a valid GPRID is defined in app.config.json.

postTelemetry(telemetry): void;

Sends the telemetry to azure app insights Note: initializeTelemetry needs to be called first before using postTelemetry

ParameterTypeDescription
telemetryStudioTelemetrytelemetry data to send

void

StudioBackendApi.postTelemetry

resolveAssetPath(pathFromProjectRoot): string;

Resolves the path to the asset file.

ParameterTypeDescription
pathFromProjectRootstringpath to the asset file relative to the project root folder (where package.json is located).

string

path to the asset file.

const path = StudioHost.resolveAssetPath("assets/my-asset.ext");
// path === "C:/path/to/app/install/dist/assets/my-asset.ext"
fs.readFileSync(path); // read the asset file

StudioBackendApi.resolveAssetPath

runtimeInfo(): StudioHostRuntimeInfo;

runtime information like product flavor and version etc

StudioHostRuntimeInfo

StudioBackendApi.runtimeInfo

saveUserPreferences(newUserPreferences): Promise<void>;

Saves the user preferences in the preferences property database.

ParameterTypeDescription
newUserPreferencesUserPreferenceObjectuser/overwrite preferences.

Promise<void>

StudioBackendApi.saveUserPreferences

setBriefcase(key): void;

iTwin studio holds a single instance of briefcase connection at a time. To notify the backend about the change of briefcase, call this method on iModel selection and when switching between apps.

ParameterTypeDescription
keystring

void

setLogLevel(minLevel): void;

Set the minimum logging level for an app. Logging category will be the app name, which is used by logging functions logException, logError, logWarning, logInfo and logTrace.

ParameterTypeDescription
minLevelLogLevelLeast severe level at which messages in the specified category should be displayed

void

Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.

showOpenDialog(options): Promise<OpenDialogReturnValue>;

Shows a “open file” dialog.

ParameterTypeDescription
optionsOpenDialogOptionsElectron open dialog options

Promise<OpenDialogReturnValue>

A Promise that resolves to the open dialog return value

StudioBackendApi.showOpenDialog

showSaveDialog(options): Promise<SaveDialogReturnValue>;

Shows a “save file” dialog.

ParameterTypeDescription
optionsSaveDialogOptionsElectron save dialog options

Promise<SaveDialogReturnValue>

A Promise that resolves to the save dialog return value

StudioBackendApi.showSaveDialog

terminate(): void;

Gracefully closes Studio instance that is running this app.

void

PropertyTypeDescriptionInherited from
checkInternetConnectivity() => Promise<InternetConnectivityStatus>Performs an in-depth check to determine the current internet connectivity status. Recommended to use after http requests throw. until 2026.09 :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::StudioBackendApi.checkInternetConnectivity
createSandbox?(options?) => Promise<SandboxHandle>Provides methods for creating and managing sandboxed execution environments. Sandboxes are hidden BrowserWindows with no network or filesystem access. They also cannot access require or import. Example const sandbox = await StudioStartupHost.createSandbox({ api: { add: async (a: number, b: number) => a + b, greet: async (name: string) => Hello, ${name}!, }, }); const result = await sandbox.execute("return api.add(2, 3)"); // result === 5 :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::-
getActiveBriefcase() => undefined | BriefcaseDb-StudioBackendApi.getActiveBriefcase
initializeSentry(initializationOpts) => Promise<undefined | Scope>Initializes Sentry with the provided options. Note Sentry is only initialized in standard flavors of iTwin Studio.StudioBackendApi.initializeSentry
onNewInstance(listener) => () => voidFired when a new instance of the startup app is run.-
trackAnalyticsEvent(event) => Promise<void>Tracks an analytics event using the Amplitude platform. Your app must have a valid GPR ID defined in app.config.json to successfully track events. When naming events, make sure that they are in Sentence case like shown in the example below. When providing custom properties, make sure that they are snake_case like shown in the example below. Example trackAnalyticsEvent({ event_name: "Home button clicked", custom_property: "value" }); :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::-

Options that an app can provide to customize StudioHost startup. until 2026.09

PropertyTypeDescription
disableITwinSelection?booleanwhen true, the iTwin selection page will be disabled regardless of the value defined in the app.config.json file :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
nativeHost?NativeHostOpts:::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
presentation?Omit<PresentationProps, "localeDirectories" | "defaultLocale" | "defaultUnitSystem">:::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
rpcManager?object:::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
rpcManager.interfaces?RpcInterfaceDefinition<RpcInterface>[]-

Re-exports StudioHostRuntimeInfo


Re-exports StudioTelemetry

type DownloadBriefcaseProps = Omit<RequestNewBriefcaseArg, "fileName" | "briefcaseId" | "iTwinId" | "iModelId" | "asOf">;

Props for downloading briefcase via Studio. briefcase location, path and briefcase id is fully controlled by Studio. Will always download the latest version.


type OpenBriefcaseFileProps = Omit<CoreOpenBriefcaseProps, "fileName">;

Props for opening briefcase via Studio. briefcase location and path is fully controlled by Studio.


type SandboxApiFunction = (...args) => Promise<unknown>;

A function that can be exposed to the sandbox. Must be an async function that returns a serializable value.

ParameterType
argsany[]

Promise<unknown>

Arguments and return values are serialized via the structured clone algorithm.

https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm until 2026.09


type UpgradeSchemas = "afterDownload" | "always" | undefined;

Indicates when to validate & upgrade schemas (if needed).

  • “afterDownload”: Only upgrade if the briefcase was freshly downloaded.
  • “always”: Upgrade schemas even if the briefcase was cached. NOTE: Cached briefcases might contain local changes. Upgrade will cause all local changes to be pushed together with schema changes.
  • undefined: Do not try to upgrade schemas. (default)