This article shares some possible use cases your app could support, as well as a sample flow that could support each use case. This can be a helpful jumping off point as you plan your app's implementation.
Your app can make Wix API calls by using OAuth.
Before your app can call Wix APIs, you need to set up OAuth.
Store your app’s secret key in a secure location. You can find it in your app’s OAuth settings page in the Wix Dev Center. Don’t share the key with anyone or make it public in any way.
Subscribe to the
Instance App Installed webhook.
This webhook is triggered every time a new user installs your app. Then, save the instanceId
.
Tip: You don’t need to subscribe to this webhook, if your app doesn’t need to call Wix APIs or manage a list of app installations. However, we highly recommend subscribing to the Instance App Installed webhook whenever you need a mapping to manage resources for every app instance.
Optional: Update Wix about the status of your new app instance. At this
point, your app instance’s state
is “Setup Incomplete”
. This state is
useful if your app requires user input such as creating an account or
configuring parameters in order for the app to become active. In case your
app doesn’t require user input, or after the user has completed their part,
update your app instance’s state by calling
Send BI Event.
Make sure to pass {"eventName": "APP_FINISHED_CONFIGURATION"}
.
To make API calls with OAuth:
body
field.body
. Keep in mind
that the access token is valid for only 4 hours.Your app can make Wix API calls by using advanced OAuth.
Before your app can call Wix APIs with advanced OAuth, you need to complete the following setup.
unsafe-none
. This enables Wix to close the redirect window as part of the flow. If the COOP of either URL has a different value, set it to unsafe-none
.token
query parameter value. We recommend that, at this point, you omit a sign-up or log-in step on your end. Instead, we recommend immediately forwarding new users to the authorization request that’s described in the next step.https://www.wix.com/installer/install
. There, they’re asked to approve the complete list of permissions that your app is requesting. Include the token
, your appId
, and redirectUrl
as query parameters. You may also pass a state
to identify your customers along the installation process.redirectUrl
. From the redirect’s query parameters, save the code
and instanceId
. Wix also includes state
as query parameter. In case it doesn’t match the one provided by you, the request may have been created by a third party. Then, we recommend aborting the process.code
is valid for 10 minutes. Use it to request your app’s refresh and access token by calling Request an Access Token. Note that the access token is only valid for 5 minutes. You need to request a new access token to make Wix API calls after it has expired.https://www.wix.com/installer/close-window?access_token=<ACCESS_TOKEN>
. Make sure to replace <ACCESS_TOKEN>
with your app instance’s access token.state
is“Setup Incomplete”
. This state is useful if your app requires users to create an account or set other configuration parameters in order for the app to become active. In case your app doesn’t require user input to become active, or after the user has completed their part, update your app instance’s state by calling Send BI Event. Make sure to pass {"eventName": "APP_FINISHED_CONFIGURATION"}
.After you’ve successfully set up advanced OAuth, you can call the relevant Wix APIs described in our API Reference.
To make API calls with advanced OAuth:
{"grant_type": "refresh_token"}
and your app’s secret key as client_secret
in the request.