Skip to content

apps-backend-api

const StudioHost: StudioBackendApi;

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

Entry point format for modular apps. Modular apps are meant to run in the context of a startup app. until 2026.09

PropertyTypeDescription
cleanup?() => Promise<void>Performs any necessary cleanup before consuming application deactivates. :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::
initialize?() => Promise<void>Performs any startup logic required by packages. :::caution[Alpha] This API should not be used in production and may be trimmed from a public release. :::

addUserPreferencesSchemaFile(schemaPath): Promise<void>;

Adds a schema json file to the user preferences.

ParameterTypeDescription
schemaPathstringPath to the schema json file.

Promise<void>

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.

attachRpcInterface<T>(definition): void;

Attach an RPC interface to the backend.

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

void

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.

getLocations(): Promise<StudioLocations>;

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

Promise<StudioLocations>

getUrlEnvironmentPrefix(): UrlEnvironmentPrefix;

UrlEnvironmentPrefix

the current environment prefix iTwinStudio is in.

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

getUserPreference(preferenceName): undefined | JSONSchemaType;

Gets a user preference from the user preferences.

ParameterTypeDescription
preferenceNamestringName of the preference.

undefined | JSONSchemaType

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

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.

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.

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.

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.

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.

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

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
runtimeInfo(): StudioHostRuntimeInfo;

runtime information like product flavor and version etc

StudioHostRuntimeInfo

saveUserPreferences(newUserPreferences): Promise<void>;

Saves the user preferences in the preferences property database.

ParameterTypeDescription
newUserPreferencesUserPreferenceObjectuser/overwrite preferences.

Promise<void>

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

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

PropertyTypeDescription
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. :::
getActiveBriefcase() => undefined | BriefcaseDb-
initializeSentry(initializationOpts) => Promise<undefined | Scope>Initializes Sentry with the provided options. Note Sentry is only initialized in standard flavors of iTwin Studio.

PropertyType
productFlavorstring
productVersionstring
startupAppobject
startupApp.configPick<AppConfigJsonSchema, "appId" | "gprId" | "displayNameEnglish" | "displayNameKey">
startupApp.versionstring

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.

PropertyTypeDescription
appInstallationDirstringDirectory where iTwin Studio app bundles are installed. App bundles are prefixed with the appId, e.g., appInstallationDir/appId.
appLoggingDirstringDirectory where iTwin Studio saves log files for the currently running app.
baseLoggingDirstringRoot directory where iTwin Studio creates folders for each app to store log files.

Telemetry data about a custom event of interest to send to Azure App Insights

  • StudioBaseTelemetry
PropertyTypeDescriptionInherited from
additionalProperties?Record<string, any>Custom propertiesStudioBaseTelemetry.additionalProperties
changesetId?string-StudioBaseTelemetry.changesetId
eventId?stringOptional Guid that can be used to more accurately identify the telemetry event. This field is required when posting a telemetry event as feature usage to ULAS.StudioBaseTelemetry.eventId
eventNamestringHuman-readable name for the event being tracked-
iModelId?string-StudioBaseTelemetry.iModelId
iTwinId?string-StudioBaseTelemetry.iTwinId
trackerStartTime?Datetrack timeStudioBaseTelemetry.trackerStartTime