apps-backend-api
Variables
Section titled “Variables”StudioHost
Section titled “StudioHost”const StudioHost: StudioBackendApi;StudioHost singleton that provides methods for apps to use on the backend.
Interfaces
Section titled “Interfaces”BackendApp
Section titled “BackendApp”Entry point format for modular apps. Modular apps are meant to run in the context of a startup app. until 2026.09
Properties
Section titled “Properties”StudioBackendApi
Section titled “StudioBackendApi”Extended by
Section titled “Extended by”Methods
Section titled “Methods”addUserPreferencesSchemaFile()
Section titled “addUserPreferencesSchemaFile()”addUserPreferencesSchemaFile(schemaPath): Promise<void>;Adds a schema json file to the user preferences.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
schemaPath | string | Path to the schema json file. |
Returns
Section titled “Returns”Promise<void>
appChannel()
Section titled “appChannel()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
channel | string | unique channel name within your app. |
Returns
Section titled “Returns”string
channel name that is unique among loaded apps.
attachRpcInterface()
Section titled “attachRpcInterface()”attachRpcInterface<T>(definition): void;Attach an RPC interface to the backend.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends RpcInterface |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
definition | RpcInterfaceDefinition<T> | RPC interface definition. |
Returns
Section titled “Returns”void
finalizeFrontendInitData()
Section titled “finalizeFrontendInitData()”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().
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jsonData | Record<string, JSONSchemaType> | JSON object containing initialization data. |
Returns
Section titled “Returns”void
A Promise that resolves when the data is finalized.
getLocations()
Section titled “getLocations()”getLocations(): Promise<StudioLocations>;Returns the locations of folders used by iTwin Studio for storing application-specific files.
Returns
Section titled “Returns”Promise<StudioLocations>
getUrlEnvironmentPrefix()
Section titled “getUrlEnvironmentPrefix()”getUrlEnvironmentPrefix(): UrlEnvironmentPrefix;Returns
Section titled “Returns”UrlEnvironmentPrefix
the current environment prefix iTwinStudio is in.
it returns url prefix like “dev-”, “qa-” or ""
getUserPreference()
Section titled “getUserPreference()”getUserPreference(preferenceName): undefined | JSONSchemaType;Gets a user preference from the user preferences.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
preferenceName | string | Name of the preference. |
Returns
Section titled “Returns”undefined | JSONSchemaType
initializeTelemetry()
Section titled “initializeTelemetry()”initializeTelemetry( instrumentalKey, enableAutoTracking?, recordExceptions?): void;Initialize telemetry service
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
instrumentalKey | string | instrumental key for app insights |
enableAutoTracking? | boolean | allow you to configure autoTracking for appInsights, false by default. |
recordExceptions? | boolean | allow Studio to post unhandled exceptions for you, true by default. |
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if instrumental key is undefined or empty string then this method throws
logError()
Section titled “logError()”logError(error, metaData?): void;Logs an error, with the category being the app name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
error | string | Error message. |
metaData? | LoggingMetaData | Additional metadata. |
Returns
Section titled “Returns”void
Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.
logException()
Section titled “logException()”logException(exception): void;Logs an exception, with the category being the app name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
exception | unknown | Exception object. |
Returns
Section titled “Returns”void
Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.
logInfo()
Section titled “logInfo()”logInfo(info, metaData?): void;Logs an info level message, with the category being the app name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
info | string | Info message. |
metaData? | LoggingMetaData | Additional metadata. |
Returns
Section titled “Returns”void
Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.
logTrace()
Section titled “logTrace()”logTrace(trace, metaData?): void;Logs a trace, with the category being the app name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
trace | string | Trace message. |
metaData? | LoggingMetaData | Additional metadata. |
Returns
Section titled “Returns”void
Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.
logWarning()
Section titled “logWarning()”logWarning(warning, metaData?): void;Logs a warning, with the category being the app name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
warning | string | Warning message. |
metaData? | LoggingMetaData | Additional metadata. |
Returns
Section titled “Returns”void
Please use studio-cli helpers migrate-to-logger path/to/src --logCategory category to migrate to Logger apis.
postTelemetry()
Section titled “postTelemetry()”postTelemetry(telemetry): void;Sends the telemetry to azure app insights Note: initializeTelemetry needs to be called first before using postTelemetry
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
telemetry | StudioTelemetry | telemetry data to send |
Returns
Section titled “Returns”void
resolveAssetPath()
Section titled “resolveAssetPath()”resolveAssetPath(pathFromProjectRoot): string;Resolves the path to the asset file.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pathFromProjectRoot | string | path to the asset file relative to the project root folder (where package.json is located). |
Returns
Section titled “Returns”string
path to the asset file.
Example
Section titled “Example”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 fileruntimeInfo()
Section titled “runtimeInfo()”runtimeInfo(): StudioHostRuntimeInfo;runtime information like product flavor and version etc
Returns
Section titled “Returns”saveUserPreferences()
Section titled “saveUserPreferences()”saveUserPreferences(newUserPreferences): Promise<void>;Saves the user preferences in the preferences property database.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
newUserPreferences | UserPreferenceObject | user/overwrite preferences. |
Returns
Section titled “Returns”Promise<void>
showOpenDialog()
Section titled “showOpenDialog()”showOpenDialog(options): Promise<OpenDialogReturnValue>;Shows a “open file” dialog.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | OpenDialogOptions | Electron open dialog options |
Returns
Section titled “Returns”Promise<OpenDialogReturnValue>
A Promise that resolves to the open dialog return value
showSaveDialog()
Section titled “showSaveDialog()”showSaveDialog(options): Promise<SaveDialogReturnValue>;Shows a “save file” dialog.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | SaveDialogOptions | Electron save dialog options |
Returns
Section titled “Returns”Promise<SaveDialogReturnValue>
A Promise that resolves to the save dialog return value
Properties
Section titled “Properties”StudioHostRuntimeInfo
Section titled “StudioHostRuntimeInfo”Properties
Section titled “Properties”| Property | Type |
|---|---|
productFlavor | string |
productVersion | string |
startupApp | object |
startupApp.config | Pick<AppConfigJsonSchema, "appId" | "gprId" | "displayNameEnglish" | "displayNameKey"> |
startupApp.version | string |
StudioLocations
Section titled “StudioLocations”Locations of folders used by iTwin Studio for storing app-specific files. All paths are determined by the operating system on which the app is running.
Properties
Section titled “Properties”StudioTelemetry
Section titled “StudioTelemetry”Telemetry data about a custom event of interest to send to Azure App Insights
Extends
Section titled “Extends”StudioBaseTelemetry