Service plugin extensions (formerly SPIs) are a set of APIs defined by Wix that you can use to enable your app to inject custom logic into existing app flows or to introduce entirely new flows to Wix sites.
Unlike traditional API endpoints where your app initiates a call with Wix, service plugins invert the process. Here, Wix calls your service during a specific flow, waits for your response, and then continues the flow based on your response.
For example, your app can use the Validations service plugin to validate a site visitor's checkout and check for additional violations, such as restricting certain purchases to site members only. When a customer updates a checkout on a site with your app installed, Wix sends a Get Validation Violations service plugin request to your app.
Your server validates the request and returns a response. Note that the response must be returned per the specification exactly as documented or Wix will not handle your response correctly. In this case, your app returns an object containing an empty list if the validation is successful, or an object detailing the violation if unsuccessful.
Use the Wix JavaScript SDK to further simplify the entire process. With a single provideHandlers()
function you define the logic you want to inject all in one convenient place. The process()
function decodes JWT-encrypted requests and allows you to expose all of your service plugin functionalities at once, without worrying about the specific sub-path for each endpoint.
Use the Wix CLI for a streamlined alternative with minimal setup and configuration. Automatically add a service plugin extension to your app, generate the necessary code files, and have Wix host the endpoints for you. Simply provide the configuration details and define the handler functions that implement your business logic.