> 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

# TriggerHomePageOptimization

# Package: seo

# Namespace: PageOptimizationService

# Method link: https://dev.wix.com/docs/api-reference/business-management/seo/page-optimization-v1/trigger-home-page-optimization.md

## Permission Scopes:
Manage SEO Settings: SCOPE.PROMOTE.MANAGE-SEO

## Introduction

Starts generating optimization suggestions for the site's homepage.

The homepage gets its own method because its suggestions are generated
with homepage-specific guidance, representing the whole site, not one
topic. Same contract as Trigger Page Optimization: the homepage's focus
keyword must be set first, the call returns a `predictionId` to poll,
and triggering is idempotent per page while a job is in progress.

Must be called with a [Wix user identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md). Calls made with an API key fail.

---

## REST API

### Schema

```
 Method: triggerHomePageOptimization
 Description: Starts generating optimization suggestions for the site's homepage.  The homepage gets its own method because its suggestions are generated with homepage-specific guidance, representing the whole site, not one topic. Same contract as Trigger Page Optimization: the homepage's focus keyword must be set first, the call returns a `predictionId` to poll, and triggering is idempotent per page while a job is in progress.  Must be called with a [Wix user identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md). Calls made with an API key fail.
 URL: https://www.wixapis.com/seo/suggestions/v1/page-optimization/trigger-home
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  pageId, pagePath
 Method parameters: 
   param name: pageId | type: pageId | description: GUID of the site's homepage. | required: true | validation: minLength 1, maxLength 1000
   param name: pagePath | type: pagePath | description: URL path of the homepage. Usually `/`. | required: true | validation: minLength 1, maxLength 1000
 Return type: TriggerHomePageOptimizationResponse
  - name: predictionId | type: string | description: GUID of the generation job. Pass to Get Page Optimization Results.  | read-only: true | validation: maxLength 200

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SUGGESTIONS_ALREADY_IN_PROGRESS | Description: A generation job for this page is already in progress with a different focus keyword. Wait for it to finish, or poll its results.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CONTENT_TOO_SHORT | Description: The page doesn't have enough text content to optimize.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FOCUS_KEYWORD_NOT_SET | Description: The page has no focus keyword set. Run keyword research, set the page's focus keyword, then trigger.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_SUPPORTED | Description: The site can't be optimized, for example, a headless project with no Wix-rendered site.
   HTTP Code: 429 | Status Code: RESOURCE_EXHAUSTED | Application Code: QUOTA_LIMIT_REACHED | Description: The caller's generation quota is exhausted. Reserved for future metering and not currently returned.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: GENERATION_FAILED | Description: The AI generation pipeline failed. Retry the call.


```

### Examples

### Start optimizing the site's homepage
```curl
curl -X POST \
'https://www.wixapis.com/seo/suggestions/v1/page-optimization/trigger-home' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "pageId": "c1dmp",
  "pagePath": "/"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.seo.pageOptimization.triggerHomePageOptimization(pageId, options)
 Description: Starts generating optimization suggestions for the site's homepage.  The homepage gets its own method because its suggestions are generated with homepage-specific guidance, representing the whole site, not one topic. Same contract as Trigger Page Optimization: the homepage's focus keyword must be set first, the call returns a `predictionId` to poll, and triggering is idempotent per page while a job is in progress.  Must be called with a [Wix user identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md). Calls made with an API key fail.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  pageId, options.pagePath, options
 Method parameters: 
   param name: options | type: TriggerHomePageOptimizationOptions  none | required: true 
        - name: pagePath | type: string | description: URL path of the homepage. Usually `/`. | required: true | validation: minLength 1, maxLength 1000
   param name: pageId | type: string | description: GUID of the site's homepage. | required: true | validation: minLength 1, maxLength 1000
 Return type: PROMISE<TriggerHomePageOptimizationResponse>
  - name: predictionId | type: string | description: GUID of the generation job. Pass to Get Page Optimization Results.  | read-only: true | validation: maxLength 200

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SUGGESTIONS_ALREADY_IN_PROGRESS | Description: A generation job for this page is already in progress with a different focus keyword. Wait for it to finish, or poll its results.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CONTENT_TOO_SHORT | Description: The page doesn't have enough text content to optimize.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: FOCUS_KEYWORD_NOT_SET | Description: The page has no focus keyword set. Run keyword research, set the page's focus keyword, then trigger.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_SUPPORTED | Description: The site can't be optimized, for example, a headless project with no Wix-rendered site.
   HTTP Code: 429 | Status Code: RESOURCE_EXHAUSTED | Application Code: QUOTA_LIMIT_REACHED | Description: The caller's generation quota is exhausted. Reserved for future metering and not currently returned.
   HTTP Code: 500 | Status Code: INTERNAL | Application Code: GENERATION_FAILED | Description: The AI generation pipeline failed. Retry the call.


```

### Examples

### Start optimizing the site's homepage
```javascript
import { pageOptimization } from "@wix/seo";

async function triggerHomePageOptimization() {
  const response = await pageOptimization.triggerHomePageOptimization("c1dmp", {
    pagePath: "/",
  });
}

/* Promise resolves to:
 * {
 *   "predictionId": "9b2e7d4a-1c3f-4e8b-a6d5-7f0c2b9e4d1a"
 * }
 */

```

### triggerHomePageOptimization (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 { pageOptimization } from '@wix/seo';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function triggerHomePageOptimization(pageId,options) {
  const response = await myWixClient.pageOptimization.triggerHomePageOptimization(pageId,options);
};
```

---