> 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/seo/page-optimization-v1/sample-flows.md

## Article Content:

# Page Optimization: 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.

## Optimize a page for its focus keyword

A site owner picked a focus keyword for their services page and wants the page's text rewritten to rank for it. Your app runs an optimization job and presents each suggested change for approval.

> **Prerequisite:** The page is a static page with a focus keyword set in its SEO settings, for example with the [Item SEO Tags API](https://dev.wix.com/docs/api-reference/business-management/seo/item-seo-tags-v1/introduction.md) for item type `STATIC_PAGE`. Other site items, such as blog posts or store products, can't be optimized and fail with `PAGE_NOT_SUPPORTED`.

To optimize a page:

1. Call [Trigger Page Optimization](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/trigger-page-optimization.md) with the page's `pageId` and its URL path in `pagePath`, for example `/services`. Keep the returned `predictionId`.
1. Poll [Get Page Optimization Results](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/get-page-optimization-results.md) with `?predictionId=<predictionId>` every few seconds. While `status` is `IN_PROGRESS`, keep polling. Generation typically takes under 2 minutes.
1. When `status` is `COMPLETED`, read `pageOptimization`. Present `metaTitle`, `metaDescription`, `h1`, `h2OrH3`, and each entry of `content` as a before/after pair the owner can accept or reject.
1. For each accepted pair, locate the element on the page by its `before` text and replace it with `after`. Apply the title tag and description tag through the page's SEO settings, for example with the [Item SEO Tags API](https://dev.wix.com/docs/api-reference/business-management/seo/item-seo-tags-v1/introduction.md).
1. If `status` is `FAILED`, call [Trigger Page Optimization](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/trigger-page-optimization.md) again to retry.

## Optimize the homepage

Your app offers a one-click SEO boost for the homepage. The homepage represents the whole site rather than one topic, so it has its own trigger method with homepage-specific guidance.

To optimize the homepage:

1. Call [Trigger Home Page Optimization](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/trigger-home-page-optimization.md). It takes no parameters, because Wix resolves which page is the site's homepage. Keep the returned `predictionId` and `pageId`.
1. Poll [Get Page Optimization Results](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/get-page-optimization-results.md) with `?predictionId=<predictionId>` until `status` is `COMPLETED`.
1. Present the suggestions and apply the accepted changes to the homepage, as in the previous flow.
1. If the owner comes back later, call [Get Page Optimization Results](https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/get-page-optimization-results.md) with `?pageId=<pageId>` instead, using the `pageId` the trigger returned. It returns the homepage's latest suggestion set even after the `predictionId` expired.