Product REST APIs
Async events API
Fetch API
Storage API

This API is only available for the new native Node.js runtime. For a complete list of updates and benefits of provided by this new runtime, see native Node.js runtime (Preview)

This section describes a Forge preview feature. Preview features are deemed stable; however, they remain under active development and may be subject to shorter deprecation windows. Preview features are suitable for early adopters in production environments.

We release preview features so partners and developers can study, test, and integrate them prior to General Availability (GA). For more information, see Forge release phases: EAP, Preview, and GA.

getAppContext (Preview)

Use getAppContext to get a Forge function's context details, including the app environments and versions it is executing in.

Method signature

1
2
export declare function getAppContext(): AppContext;

export type AppContext = {
    appAri: AppAri;
    appVersion: string;
    environmentAri: EnvironmentAri;
    environmentType: string;
    invocationId: string;
    installationAri: InstallationAri;
    moduleKey: string;
};

export type AppAri = {
    appId: string;
    toString: () => string;
};
export type EnvironmentAri = {
    environmentId: string;
    toString: () => string;
};
export type InstallationAri = {
    installationId: string;
    toString: () => string;
};

Returns

This API returns the following string values:

NamePropertiesDescription
appAritoString()The app's unique Atlassian Resource Identifier (ARI), as defined in the app.id field of the manifest.yml file.
appIdThe UUID part of the full appAri string.
appVersionApp Version.
environmentAritoString()The app environment's full ARI.
environmentIdThe UUID part of the full environmentAri string.
environmentTypeThe environment in which the app is running (for example, DEVELOPMENT, STAGING, or PRODUCTION).
invocationIdA unique identifier for the current invocation.
installationAritoString()The app installation's full ARI.
installationIdThe UUID part of the full installationAri string
moduleKeyThe key for the module as defined in the manifest.yml file.

Example

1
2
import { getAppContext } from "@forge/api";

const { appAri, appVersion, environmentAri, environmentType, invocationId, installationAri, moduleKey } = getAppContext();

console.log(appAri.toString());
// 'ari:cloud:ecosystem::app/00000000-0000-0000-0000-000000000000'

console.log(appAri.appId);
// '00000000-0000-0000-0000-000000000000'

console.log(appVersion);
// '1.0.0'

console.log(environmentAri.toString());
// 'ari:cloud:ecosystem::environment/00000000-0000-0000-0000-000000000000/11111111-1111-1111-0111-111111111111'

console.log(environmentAri.environmentId);
// '11111111-1111-1111-0111-111111111111'

console.log(environmentType);
// 'DEVELOPMENT'

console.log(invocationId);
// '33333333-3333-3333-0333-333333333333'

console.log(installationAri.toString());
// 'ari:cloud:ecosystem::installation/22222222-2222-2222-0222-222222222222'

console.log(installationAri.installationId);
// '22222222-2222-2222-0222-222222222222'

console.log(moduleKey);
// 'hello-world'

Rate this page: