> 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: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/sample-flows.md

## Article Content:

# Marketing Plan API: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.

## Generate a marketing plan and publish its posts

The core flow: generate a plan for a site, then schedule its posts for publishing.

> **Prerequisite:** The site must be published, and the social channels you want to publish to must be connected through the Publisher API.

To generate a plan and publish its posts:

1. Call [Generate Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/generate-marketing-plan.md). The response returns a `status` of `GENERATING`.
1. Poll [Get Social Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-social-marketing-plan.md) until `status` is `ACTIVE`. The response contains the plan's `marketingActivities`, and the near-term activities already include generated posts in their `items`.
1. Collect the IDs of the `items` whose `status` is `DRAFT` from the activities you want to publish.
1. Call [Schedule Drafts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/schedule-drafts.md) with those IDs to schedule the posts for publishing. Note that `ScheduleDrafts` only schedules drafts for channels the site has connected through the Publisher; drafts for unconnected channels are left as drafts.

## Tailor the plan with marketing settings

Before generating, configure the site's marketing preferences so the AI produces a plan that matches the brand's goal, voice, and channels.

To tailor and generate a plan:

1. Optionally, call [Get Plan Goal Options](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-settings-v1/get-plan-goal-options.md) and [Get Point Of View Options](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-settings-v1/get-point-of-view-options.md) to retrieve the selectable values for those settings.
1. Call [Upsert Marketing Settings](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-settings-v1/upsert-marketing-settings.md) with the chosen goal, social channels, point of view, posting frequency, and other preferences.
1. Call [Generate Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/generate-marketing-plan.md). The response returns a `status` of `GENERATING`.
1. Poll [Get Social Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-social-marketing-plan.md) until `status` is `ACTIVE`. The generated activities and posts reflect the configured settings.

## Plan around a custom calendar event

Add an event, such as a seasonal sale or product launch, so the AI builds activities around it.

To plan around an event:

1. Call [Create Event](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/calendar-event-v1/create-event.md) with the event's name and date. For a repeating event, set a recurring rule instead of a date.
1. Call [Generate Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/generate-marketing-plan.md), or [Regenerate Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/regenerate-marketing-plan.md) if the site already has a plan. The response returns a `status` of `GENERATING`.
1. Poll [Get Social Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-social-marketing-plan.md) until `status` is `ACTIVE`. The plan's activities account for the event.

## Generate and schedule posts for more activities

When a plan is generated, posts are created automatically only for the near-term activities. Use this flow to generate posts for the remaining activities and schedule them.

To generate and schedule more posts:

1. Call [Get Social Marketing Plan](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-social-marketing-plan.md) and note the IDs of the activities that don't yet have posts.
1. Call [Generate Social Posts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/generate-social-posts.md) with those activity IDs. The response returns immediately while generation continues in the background.
1. Poll [Get Marketing Activity Posts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-marketing-activity-posts.md) for those activities until the posts appear.
1. Collect the IDs of the `items` whose `status` is `DRAFT`.
1. Call [Schedule Drafts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/schedule-drafts.md) with those IDs to schedule them for publishing. Note that `ScheduleDrafts` only schedules drafts for channels the site has connected through the Publisher; drafts for unconnected channels are left as drafts.

## Publish an activity's story

An activity in the plan can carry a story alongside its posts. This flow covers finding that story and publishing every one of its frames.

To publish an activity's story:

1. Call [Get Marketing Activity Posts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-marketing-activity-posts.md) for the activity and find the item whose `type` is `STORY`. Not every activity has one.
1. Note that item's `id` and the number of media items in its media list. Each media item is one frame.
1. Call [Publish Multi Story Draft](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-multi-story-draft.md) in the Publisher API with that `id`. Each frame is published as its own story.

## Replace a frame in an activity's story

A site owner likes a generated story but wants to swap out one of its images, without regenerating the rest.

To replace a single frame:

1. Call [Get Marketing Activity Posts](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/get-marketing-activity-posts.md) for the activity and find the item whose `type` is `STORY`.
1. Identify the position of the frame to replace in that item's media list. Positions are zero based.
1. Call [Update Marketing Activity Stories Media](https://dev.wix.com/docs/api-reference/business-management/marketing/marketing-plan/marketing-plan-v1/update-marketing-activity-stories-media.md) with the activity's ID, the new `mediaUrl` and `mediaType`, and that position as `mediaIndex`. The story's other frames are left unchanged.