> 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`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GenerateMarketingPlan

# Package: marketingPlan

# Namespace: AiPlanGeneratorService

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/generate-marketing-plan.md

## Permission Scopes:
Manage Marketing Plans: SCOPE.PROMOTE.MANAGE-MARKETING-PLAN

## Introduction

Generates a marketing plan for the site.

Generation is asynchronous. The response immediately returns a `status` of `GENERATING`.
Poll `GetSocialMarketingPlan` until `status` is `ACTIVE` (ready) or `FAILED`.
The plan's activities span the whole plan period (today through the end of next month), but
social posts are generated automatically only for the nearest-term activities (how far ahead
can depend on the site's social marketing premium plan). To generate posts for the remaining
activities, call `GenerateSocialPosts`.
The site should be published before calling this method, because generation draws on the
published site. This isn't validated at call time: an unpublished site results in either a
`FAILED` status or an `ACTIVE` plan with no generated posts. Verify the site is published
before generating. Marketing settings are optional; sensible defaults are applied at generation time.

---

## REST API

### Schema

```
 Method: generateMarketingPlan
 Description: Generates a marketing plan for the site.  Generation is asynchronous. The response immediately returns a `status` of `GENERATING`. Poll `GetSocialMarketingPlan` until `status` is `ACTIVE` (ready) or `FAILED`. The plan's activities span the whole plan period (today through the end of next month), but social posts are generated automatically only for the nearest-term activities (how far ahead can depend on the site's social marketing premium plan). To generate posts for the remaining activities, call `GenerateSocialPosts`. The site should be published before calling this method, because generation draws on the published site. This isn't validated at call time: an unpublished site results in either a `FAILED` status or an `ACTIVE` plan with no generated posts. Verify the site is published before generating. Marketing settings are optional; sensible defaults are applied at generation time.
 URL: https://www.wixapis.com/promote/marketing-plan-service/v1/marketing-plan/generate-marketing-plan
 Method: POST
 Return type: GenerateMarketingPlanResponse
  - name: status | type: PlanStatus | description: Current plan status. Returns `GENERATING` immediately; poll `GetSocialMarketingPlan` until `ACTIVE` or `FAILED`.  
     - enum:
     -     NEVER_CREATED: No plan has been generated for this site yet.
     -     GENERATING: The plan is currently being generated. Poll `GetSocialMarketingPlan` until status changes.
     -     ACTIVE: The plan is ready to use and activities are available.
     -     INACTIVE: The plan was automatically deactivated after a long period without engagement. An `INACTIVE` plan returns no activities. Calling `GetSocialMarketingPlan` after a long idle period can itself trigger this transition. Generating or regenerating reactivates the plan.
     -     FAILED: Generation failed. Call a generate or regenerate method to try again.


```

### Examples

### Generate a marketing plan
Generate a new social marketing plan for the site. Generation runs asynchronously, so the response returns the current plan status.

```curl
curl -X POST \
'https://www.wixapis.com/promote/marketing-plan-service/v1/marketing-plan/generate-marketing-plan' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.promoteGrowthToolsMarketingPlan.marketingPlan.generateMarketingPlan()
 Description: Generates a marketing plan for the site.  Generation is asynchronous. The response immediately returns a `status` of `GENERATING`. Poll `GetSocialMarketingPlan` until `status` is `ACTIVE` (ready) or `FAILED`. The plan's activities span the whole plan period (today through the end of next month), but social posts are generated automatically only for the nearest-term activities (how far ahead can depend on the site's social marketing premium plan). To generate posts for the remaining activities, call `GenerateSocialPosts`. The site should be published before calling this method, because generation draws on the published site. This isn't validated at call time: an unpublished site results in either a `FAILED` status or an `ACTIVE` plan with no generated posts. Verify the site is published before generating. Marketing settings are optional; sensible defaults are applied at generation time.
 Return type: PROMISE<GenerateMarketingPlanResponse>
  - name: status | type: PlanStatus | description: Current plan status. Returns `GENERATING` immediately; poll `GetSocialMarketingPlan` until `ACTIVE` or `FAILED`.  
     - enum:
     -     NEVER_CREATED: No plan has been generated for this site yet.
     -     GENERATING: The plan is currently being generated. Poll `GetSocialMarketingPlan` until status changes.
     -     ACTIVE: The plan is ready to use and activities are available.
     -     INACTIVE: The plan was automatically deactivated after a long period without engagement. An `INACTIVE` plan returns no activities. Calling `GetSocialMarketingPlan` after a long idle period can itself trigger this transition. Generating or regenerating reactivates the plan.
     -     FAILED: Generation failed. Call a generate or regenerate method to try again.


```

### Examples

### Generate a marketing plan
```javascript
import { marketingPlan } from "@wix/promote-growth-tools-marketing-plan";

async function generateMarketingPlan() {
  const response = await marketingPlan.generateMarketingPlan();
}

/* Promise resolves to:
 * {
 *   "status": "GENERATING"
 * }
 */

```

### generateMarketingPlan (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { marketingPlan } from '@wix/promote-growth-tools-marketing-plan';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { marketingPlan },
  // Include the auth strategy and host as relevant
});


async function generateMarketingPlan() {
  const response = await myWixClient.marketingPlan.generateMarketingPlan();
};
```

---