> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Add Service Plugin Extensions with the Wix CLI

## Article: Add Service Plugin Extensions with the Wix CLI

## Article Link: https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/service-plugins/add-service-plugin-extensions-with-the-wix-cli.md

## Article Content:

# Add Service Plugin Extensions with the Wix CLI

[Service plugin extensions](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/service-plugins/about-service-plugin-extensions.md) are a set of APIs defined by Wix that you can use to inject custom logic into the existing backend flows of [Wix business solutions](https://dev.wix.com/docs/build-apps/develop-your-app/wix-business-solutions/about-wix-business-solutions.md) or to introduce entirely new flows to Wix sites.

You can implement service plugin extensions in your project using the Wix CLI.

Follow the instructions below to:

1. Create a service plugin extension for your project.
2. Test your service plugin extension.

Once this task is complete, your project will have a service plugin extension with custom functions that Wix calls during a specific flow.

## Before you begin

+ You must have a project that was [created using the Wix CLI](https://dev.wix.com/docs/wix-cli/cli-for-apps/about-the-wix-cli-for-apps.md).
+ You must be logged into your Wix account. If you don't have one, [sign up for a Wix account](https://manage.wix.com/account/custom-apps).

## Step 1 | Create the extension

In the terminal:

1. Navigate to your project repo.
1. Run the [generate](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/generate.md) command.

1. The CLI will display a menu of extensions to generate. Select **Service Plugin** and hit enter to continue.
1. The CLI will prompt you to select a service plugin from a list of available service plugins.
1. The CLI will prompt you to name your service plugin. This is the name of the folder in the project repo that contains the service plugin code, and the name of the plugin that appears in your app dashboard when developing an app. Only you will see this name.

Upon completion, the extension files will be created in your project directory with the following structure:

```bash
src/
  └── extensions/
      └── backend/
          └── service-plugins/
              └── <your-service-plugin-name>/
                  ├── <your-service-plugin-name>.extension.ts
                  └── <your-service-plugin-name>.ts
```

> **Note:** This is the default folder structure created by the CLI. You can move these files to any location within the `src/` folder and update the references in your `extensions.ts` file. Learn more about the [flexible file system](https://dev.wix.com/docs/wix-cli/cli-for-apps/project-structure/folders-and-files/src-extensions.md).

Learn more about the [service plugin extension files](https://dev.wix.com/docs/build-apps/develop-your-app/develop-an-app-with-the-cli/supported-extensions/backend/service-plugins/service-plugin-extension-files-and-code.md).

## Step 2 | Test your service plugin extension

To check that your service plugin extension runs:

1. Make sure your project uses the latest version of the CLI. To check and update your CLI version, see [Keep the CLI up to date](https://dev.wix.com/docs/wix-cli/cli/about-the-cli.md#keep-the-cli-up-to-date).
2. Run the [`build`](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/build.md) command and then run the [`preview`](https://dev.wix.com/docs/wix-cli/cli-for-apps/command-reference/project-commands/preview.md) command.
3. Open one of the preview links the CLI prints, select a development site, and click **Install App**. If your app is already installed on that site, clicking **Install App** updates it to the new preview.
4. On that site, trigger the call to your service plugin.

    For example, to test a service plugin extension for [Additional Fees](https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/additional-fees/additional-fees-service-plugin/introduction.md) that adds a $5 packaging fee to all orders:

    1. Open the store.
    2. Select any product and add it to the cart, then view the cart.
    3. Check if the additional fee is listed in the order summary.

> **Note:** To learn how new and changed service plugins reach your app's users, see [About App Versioning](https://dev.wix.com/docs/build-apps/manage-your-app/versioning/about-app-versioning.md).

<!-- <blockquote class="important">

__Important:__

Logging in the backend logic of service plugins can't be tested in the CLI's local development environment (`npm run dev`). Instead, you must trigger the call to the service plugin from your project and check for the expected result.
</blockquote> -->

## Build and deploy your project

Once your project is ready for production, you can [build and deploy](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/project-development/build-and-deploy-a-project-with-the-wix-cli.md) it.

>**Note:**
> When you release an app project, you release a new version of the app allowing you to publish the app to the [Wix App Market](https://www.wix.com/app-market) or install it on a site with a direct install URL. You can view your app's [versions](https://manage.wix.com/app-selector?title=Select+an+App&primaryButtonText=Select+Site&actionUrl=https%3A%2F%2Fdev.wix.com%2Fapps%2F%7BappId%7D%2Fversions-app) in the app dashboard.

## Delete a service plugin extension

To delete a service plugin extension from your project:

1. Delete the folder under `src/extensions` that contains your service plugin extension's files.
2. Remove the import and `.use()` statements for the extension from the [`extensions.ts`](https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/wix-cli/supported-extensions/about-the-extensions-ts-file.md) file.

<blockquote class="important">

**For app projects:** 

If you already have a version of your app project, you must build and deploy the project again after removing the service plugin extension files. 

</blockquote>