About App Instances

An app instance is an installation of your app on a specific Wix site, identified by a unique instanceId. This ID remains the same across all extensions of your app on that site, even if the app is uninstalled and reinstalled.

Depending on your use case, you might need access to:

  • App instance ID: A unique identifier for your app on a site.
  • App instance data: A set of properties that describe the app instance.

See example use cases.

Caution: Cloning a site creates a new app instance without triggering the consent flow. For apps using advanced OAuth, this means the new instance lacks a refresh token. You must prompt users to reinstall the app to generate the required token and complete the setup.

App instance ID

The app instance ID (instanceId) is the primary identifier for your app on a site and remains the same across all extensions of your app on that site, even if the app is uninstalled and reinstalled.

You can get instanceId from the following sources:

Tip: We recommend that you save instanceId upon app installation. You can subscribe to the App Instance Installed webhook or call Get App Instance (SDK | REST).

Security considerations

For security reasons, the instanceId isn’t directly accessible in extensions like dashboard pages, site widgets, settings panels, or embedded scripts. However, you can securely extract the instanceId in a backend API.

Learn how to:

App instance data

App instance data provides information about your app's installation on a specific Wix site. This data includes the instanceId and other properties that describe the app's state and configuration on the site.

You can access app instance data through several methods, depending on your use case:

Important: These methods don't return exactly the same properties.

REST API and SDK

You can get app instance data by calling Get App Instance (SDK | REST). In both cases, the method returns app instance information that is independent of user context, unlike the encoded query parameter. The data includes the instanceId and other details about your app on the site.

Note: Access tokens sent from site extensions have a site visitor or member identity. To call Get App Instance, you'd need to elevate permissions:

Velo API for Wix Blocks

You can get app instance data in Wix Blocks by calling getDecodedAppInstance(). The method returns the instanceId and the vendorProductId, which is the plan ID of the app installed on the site.

Encoded query parameter

When a user interacts with external pricing pages, external dashboards, or iframe apps, an encoded instance query parameter is generated client-side and sent to your app's server endpoints.

Learn more

When a user accesses your app through a frontend action, Wix provides data about the app instance as an encoded query parameter, instance, to your app endpoints. The instance query parameter includes the instanceId along with site and user information. The data is also signed to ensure its integrity and authenticity.

Apps that receive the encoded query parameter include:

  • iframe apps
  • External dashboard apps (when a user clicks Open App)
  • Apps with an external pricing page (when a user clicks Upgrade App)

Example use cases

Example use cases for instance data provided by the encoded query parameter include:

  • Activate features per site, including tracking upgrades and downgrades. For more information, see Identify and Manage Users.
  • Automatically log users into your app. Useful for users with multiple sites.
  • Identify the active user in an app settings iframe using the same instanceId as the app iframe.
  • Differentiate between site owner and site contributor roles.
  • Display content in the user's preferred language.

Data structure

The encoded instance parameter is composed of two parts separated by a dot:

  • Signature: HMACSHA-256 signature. Generated using the app secret and the data part of the instance. The signature is Base64 URL encoded.
  • Data: A Base64 URL encoded JSON object. This JSON includes the instance properties, listed below. You’ll need to decode the data to see these properties.

Here's an example of the encoded instance parameter:

Copy

For examples on how to parse the parameter, see Parse Encoded App Instance Data.

Properties

Once decoded, you'll have access to the following data:

FieldDescription
instanceIdThe instance ID of the app within Wix. Read more about the App Instance ID below.
signDateThe date of the payload signature.
uidThe ID of the Wix user or site member who is logged in.
permissionsThe permission set of the Wix user or site member:
Note: To check if the site owner is logged in, compare the uid to the siteOwnerId property.
ipAndPort (deprecated)The user's current IP address and port number.
vendorProductId(Optional, appears if the site owner upgraded the app) The Plan ID of the package the site owner purchased.
aidThe ID of an anonymous site visitor.
originInstanceId(Optional, appears in copied sites) The instance ID of the app in the original site.
siteOwnerIdThe ID of the site owner. When this value is the same as the uid, it means the site owner is logged in.

Warning: For dashboard security, restrict access if the aid parameter is returned, indicating that the user attempting to access the dashboard is anonymous. This applies to users who aren't the site's owner or collaborators, identifiable by the uid.

Note: The siteOwnerId associated with a particular instanceId may change. If a site owner transfers ownership to another user, the existing instanceId becomes linked to the new owner. For instance, if User A transfers the site to User B, the app retains its instanceId but becomes associated with User B's siteOwnerId.

JSON example

Copy

Example use cases

The following examples illustrate use cases for instanceId versus app instance data provided by Wix.

Use cases for instanceId

The app instance ID is useful in the following scenarios:

  • Store site-specific data: Use instanceId as a foreign key to store and retrieve data tied to a site, such as user preferences, analytics, or user-generated content. This ensures all app-related and user-generated data remains linked to its originating site.
  • Configure site-specific settings: Save and apply app settings specific to each site, such as themes, layouts, or integration preferences.
  • Implement usage-based billing: Monitor site-specific app usage, such as API requests or storage, to implement accurate usage-based billing.
  • Communicate with Wix support: Provide instanceId when troubleshooting or requesting support for a specific app installation.

Use cases for app instance data

App instance data provided by Wix is useful in the following scenarios:

  • Activate features: Enable or disable features based on subscription status, upgrades, or downgrades. For more information, see Identify and Manage Users.
  • Check for Wix business solutions: Determine if a site uses any Wix business solutions with the installedWixApps property, and adjust integrations accordingly.
  • Detect site cloning: Identify sites created from templates with the originInstanceId. If originInstanceId is blank or missing, the site wasn't cloned with the app installed. If present, it provides the instanceId of the original installation. For apps using advanced OAuth, you need to prompt users of cloned sites to reinstall the app to generate an access token.

See also

Did this help?