> 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: addSitePlugin()

## Article: addSitePlugin()

## Article Link: https://dev.wix.com/docs/sdk/host-modules/dashboard/add-site-plugin.md

## Article Content:

# addSitePlugin()

> **Developer Preview**  
> This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Adds a site plugin to one of the slots supported in an [app created by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md). You can optionally specify a single slot in which you want to add the plugin. If you don't specify a slot, your plugin is placed in the first available slot according to the order you defined in the plugin's installation settings in your [app's dashboard](https://manage.wix.com/account/custom-apps). If that slot is occupied, it's added in the next available slot, and so on. If there are no available slots, it isn't added.

> **Notes:**
>
> - This method isn't supported for [extending sites](https://dev.wix.com/docs/develop-websites.md).
> - Before using this method, you need a site plugin extension. Learn more about [site plugins](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/site-plugins/about-site-plugin-extensions.md).

## Method declaration
```ts
(pluginId: string, options: { slotId?: string, placement?: PluginPlacement }) => Promise<void>
```

## Parameters

| Name          | Type                                        | Description            |
|:--------------|:--------------------------------------------|:-----------------------|
| `pluginId` | `string`                                    | ID of your site plugin, which you can find in your app's dashboard, in the site plugin extension's settings. |
| `options` | [addSitePluginOptions](#addsitepluginoptions-object)  | Options to use when adding a site plugin. |

### addSitePluginOptions object

> **Notes**:
>
> - The `placement` property is deprecated. Use the `slotId` property instead.
> - The `slotId` value is the same ID as an item in the plugin's `placementsSlotIds` configuration.

```ts
{
    slotId?: string;
    placement?: PluginPlacement;
}
```

| Name          | Type                                        | Description            |
|:--------------|:--------------------------------------------|:-----------------------|
| `slotId` | string  | Optional. The ID of the slot in which you want to add the plugin. Learn more about the [slots available on Wix app pages](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/site-plugins/supported-wix-app-pages/about-slots.md). |
| `placement` | [PluginPlacement](#pluginplacement-object-deprecated)  | **(Deprecated)** Optional. Details of the slot in which you want to add the plugin using the legacy slot notation method. Use the `slotId` property instead. |

### PluginPlacement object (deprecated)

```ts
{
    appDefinitionId: string;
    widgetId: string;
    slotId: string;
}
```

| Name | Type | Description |
|---|---|---|
| `appDefinitionId` | `string` | ID of the app created by Wix whos widget you want to add your plugin to. You can find the IDs of these apps in [this list of apps created by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md). |
| `widgetId` | `string` | ID of the host widget in which the slot is located. A host widget is a widget provided by an app created by Wix. Check the [slots documentation](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/site-plugins/supported-wix-app-pages/about-slots.md) to find the IDs of site widgets provided by apps created by Wix. |
| `slotId` | `string` | ID of the slot in the host widget using the legacy slot notation method.|

## Returns

```ts
Promise<void>
```

## Errors

The `addSitePlugin()` method can reject with the following errors:

| Code | Message |
|---|---|
| 3001 | Slot occupied |
| 3002 | Slot not found |
| 3003 | Error adding plugin |
| 3004 | Error replacing existing plugin |
| 3005 | Error loading modal data |
| 3006 | Aborted by user |
| 3007 | Site not published yet |

## Examples

> **Note:** To call this method in [self-managed apps](https://dev.wix.com/docs/api-reference/articles/platform-overview/about-self-managed-apps.md), you need to create a [client](https://dev.wix.com/docs/sdk/articles/set-up-a-client/about-the-wix-client.md). See the [setup](https://dev.wix.com/docs/sdk/host-modules/dashboard/introduction.md) guide for more details.

### Add a site plugin to a specific slot

```ts
import { dashboard } from '@wix/dashboard';

const pluginId = '975bffb7-3c04-42cc-9840-3d48c24e73d5';
const slotId = 'a91a0543-d4bd-4e6b-b315-9410aa27bcde';

dashboard.addSitePlugin(pluginId, { slotId })
  .then(() => {
    console.log('Plugin added successfully');
  })
  .catch(error => {
    console.error('Error adding plugin:', error);
  });

```

### Add a site plugin without specifying a slot

```ts
import { dashboard } from '@wix/dashboard';

const pluginId = '975bffb7-3c04-42cc-9840-3d48c24e73d5';

dashboard.addSitePlugin(pluginId, {})
  .then(() => {
    console.log('Plugin added successfully');
  })
  .catch(error => {
    console.error('Error adding plugin:', error);
  });
```