> 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/social-media/sample-flows.md

## Article Content:

# Publisher 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.

## Connect a social channel

A site owner wants to connect a new social channel so they can publish to it, without leaving your app for the dashboard.

To connect a channel:

1. Call [Get Connect Url](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/get-connect-url.md) with the `channelName` to retrieve the channel's OAuth authorization URL.
1. Surface the URL to the site owner and have them open it and authorize the channel in their browser. The channel's OAuth redirect completes the connection server-side.
1. Poll [Get Long Lived Token Status](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/get-long-lived-token-status.md) with the `channelName` until the status is `VALID`, which confirms the channel is connected.
1. To disconnect the channel later, call [Disconnect](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/disconnect.md) with the `channelName`.

## Connect a channel and publish an AI-generated post

A site owner wants to connect a channel, generate a post caption and image with AI, and publish it, all in one flow.

To connect a channel and publish an AI-generated post:

1. Call [Get Long Lived Token Status](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/get-long-lived-token-status.md) with the `channelName` to check whether the channel is already connected.
1. If the status isn't `VALID`, connect the channel: call [Get Connect Url](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/get-connect-url.md) with the `channelName`, surface the returned OAuth authorization URL to the site owner to authorize in their browser (the OAuth redirect completes the connection server-side), then poll [Get Long Lived Token Status](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/get-long-lived-token-status.md) until the status is `VALID`.
1. Call [Generate Text](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/generate-text.md) with a prompt describing the post to get caption suggestions.
1. Call [Generate Image](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/generate-image.md) with a prompt and a source image (a source image is required, since the method edits an existing image rather than generating one from a text prompt alone) to start image generation, then poll [Get Generated Image](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/get-generated-image.md) with the returned `executionId` until the status is `READY` to get the image's `imageUrl` and `fileId`.
1. Call [Create Draft Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/create-draft-item.md) with the chosen caption and the generated image. The response includes the draft's `id`.
1. Call [Publish Item By ID](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-item-by-id.md) with the draft's `id` to publish it immediately, or include a `scheduledDate` to schedule it.

## Create and publish a post

A site owner wants to publish a post to one of their connected social channels.

> **Prerequisite:** The site owner must connect the channel in the site's dashboard before you can publish to it. See [Connecting to your social media accounts](https://support.wix.com/en/article/social-media-marketing-connect-to-your-social-media-accounts).

To create and publish a post:

1. Call [List Accounts](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/account-v1/list-accounts.md) for the channel to retrieve the connected account's `id`.
1. Call [Get Feature Data](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/premium-feature-v1/get-feature-data.md) with `PUBLISH_POST` to confirm the site can publish and has remaining quota.
1. Call [Create Draft Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/create-draft-item.md) with the post's channel, `type`, and content. The `type` and content must match a combination the channel supports. The response includes the draft's `id`.
1. Call [Publish Item By ID](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-item-by-id.md) with the draft's `id` to publish it immediately. The published post appears on the site's Social Media Marketing page in the dashboard.

## Schedule a post for a future date

A site owner wants to prepare a post now and have it published automatically at a later time.

To schedule a post:

1. Call [Create Draft Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/create-draft-item.md) with the post's channel, `type`, and content. The response includes the draft's `id`.
1. Call [Publish Item By ID](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-item-by-id.md) with the draft's `id` and a `scheduledDate`. The post is published at that date with a status of `SCHEDULED`.

## Reschedule or cancel a scheduled post

A site owner wants to change the publish date of a scheduled post, or stop it from being published.

To reschedule or cancel a scheduled post:

1. Call [Query Items](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/query-items.md) to find the scheduled post and get its `id` from the results.
1. To move the post to a different date, call [Reschedule Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/reschedule-item.md) with the `id` and the new `scheduledDate`. To stop it from being published, call [Cancel Scheduled Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/cancel-scheduled-item.md) with the `id`.

## Generate post content and publish it

A site owner wants to create a post from one of their site's assets, such as a product, without writing the content themselves.

To generate post content and publish it:

1. Get the asset's ID from the app that owns it. For example, call [Query Products](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/products-v3/query-products.md) for a `STORES_PRODUCT`, or [Query Posts](https://dev.wix.com/docs/api-reference/business-solutions/blog/posts-stats/query-posts.md) for a `BLOG_POST`.
1. Call [Generate Post Data](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/generate-post-data.md) with a single site asset (its `id` and `type`), a free-text `userInput`, or both, and optionally the channels to generate for. Supported asset types are `STORES_PRODUCT`, `STORES_CATEGORY`, `STORES_COUPON`, `BLOG_POST`, `EVENT`, and `BOOKINGS_SERVICE`. Only one asset is supported per call. The response returns ready-to-use content for each requested channel: image posts for Instagram, Facebook, LinkedIn, Pinterest, Google Business Profile, and TikTok. It doesn't return YouTube content or story and video formats.
1. Call [Create Draft Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/create-draft-item.md) with the generated content for the channel you want to post to. The response includes the draft's `id`.
1. Call [Publish Item By ID](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-item-by-id.md) with the draft's `id` to publish it, or include a `scheduledDate` to schedule it.

## Generate a caption for a post

A site owner wants to create a caption with AI to use in a post, rather than generate a full post.

To generate content and publish a post with it:

1. Call [Generate Text](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/generated-content-v1/generate-text.md) with a prompt describing the post to generate caption suggestions.
1. Call [Create Draft Item](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/create-draft-item.md) with the generated caption as the post's content. The response includes the draft's `id`.
1. Call [Publish Item By ID](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/publish-item-by-id.md) with the draft's `id` to publish it, or include a `scheduledDate` to schedule it.

## Find a site's scheduled posts

A site owner wants to see what's queued to go out, so they can confirm a post was scheduled before moving on.

To find a site's scheduled posts:

1. Call [Query Items](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/query-items.md) with `filter` set to `{"status": "SCHEDULED"}`. To narrow the results to one channel, add `channel`, and to narrow them to one format, add `type`.
1. Read the scheduled date of each returned item from `schedulingInfo.scheduledDate`.
1. Check the `status` of the returned items before treating the result as the site's schedule. An unsupported filter field is ignored rather than rejected, so a filter that names the wrong field returns every item instead of an error.

## Publish a multi-frame story

A site owner has a story draft made up of several images and wants to publish every frame.

To publish a multi-frame story:

1. Call [Query Items](https://dev.wix.com/docs/api-reference/business-management/marketing/social-media/item-v1/query-items.md) to find the story draft, and get its `id` from the results. A multi-frame story is an item whose `type` is `STORY` and whose media list holds more than one media item.
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) with the draft's `id`, or include `schedulingInfo.scheduledDate` to schedule the sequence. Each frame is published as its own story item, in media order.
1. Check `results` in the response. Each entry reports one frame. If any frame failed, the draft is kept so you can fix the problem and call the method again. Frames that already published are skipped on the retry.