> 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

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-management/seo/site-keyword-research-v1/sample-flows.md

## Article Content:

# Site Keyword Research: 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.

## Monitor research for a content plan flow

Your app follows a content plan flow requested by a site owner. It needs to distinguish research that has started from research that is ready before generating blog post briefs.

The field paths below use REST names. In SDK responses, the research ID is `siteKeywordResearch._id` instead of `siteKeywordResearch.id`; `contentPlanFlowId` has the same spelling in both clients.

> Prerequisite: Retain the actual flow ID returned by [Trigger Content Plan Generation Flow](https://dev.wix.com/docs/api-reference/business-management/seo/content-plan-content-plan-flow-v1/trigger-content-plan-generation-flow.md) for the site owner's requested generation job.

### Part 1: Wait for matching research

To monitor the research for the requested flow:

1. Call [Get Content Plan Flow](https://dev.wix.com/docs/api-reference/business-management/seo/content-plan-content-plan-flow-v1/get-content-plan-flow.md) with the actual flow ID. Retain this ID throughout monitoring. If the flow is `PENDING_REQUIREMENTS`, report that generation is waiting for required business information and ask the site owner to review their business information in the Wix dashboard. The public API does not identify the missing requirements. If the site owner wants to wait, continue monitoring within a finite window, waiting 10 to 15 seconds between requests; otherwise preserve the flow ID and stop monitoring.
1. When the flow reports `KEYWORD_RESEARCH`, read its `keywordResearchId`. This flow status means research has started; it does not establish readiness.
1. Call [Get Site Keyword Research](https://dev.wix.com/docs/api-reference/business-management/seo/site-keyword-research-v1/get-site-keyword-research.md) with that research ID. Require the returned `siteKeywordResearch.id` and `siteKeywordResearch.contentPlanFlowId` to match the research and flow being followed.
1. While research reports `IN_PROGRESS`, wait 10 to 15 seconds between requests within a finite monitoring window. A not found response can occur before the research record exists; retry a paced read and re-read the flow if it persists. Stop for `FAIL`, `CANCELED`, `REVERTED`, mismatched IDs, or an expired monitoring window. Preserve the IDs and report the last observed status instead of automatically triggering a replacement flow.

### Part 2: Generate and retrieve briefs

After the matching research has succeeded, follow the same flow through brief generation:

1. After matching research `SUCCESS`, call Get Content Plan Flow again with the same flow ID. If it still reports `KEYWORD_RESEARCH` with the same research ID, and the site owner requested brief generation, call [Create Content Plan](https://dev.wix.com/docs/api-reference/business-management/seo/content-plan-blog-post-candidate-v1/create-content-plan.md) once, provided no release has already been attempted for this flow. Set the request's `contentPlanFlowId` to the retained flow ID; don't omit it. Check `success` in its response as well as the HTTP status. A `false` result is not successful generation.
1. Compare Create's returned `contentPlanFlowId` with the retained ID. A different ID means a separate generation was started, for example if the flow completed between the readiness read and Create. Preserve both IDs and report the unexpected regeneration; don't present the original flow's briefs as its result. Follow the returned ID only when the site owner intended regeneration, using the same bounded monitoring and completion checks.
1. If the flow has already advanced to `CONTENT_PLAN` or `SUCCESS`, skip Create Content Plan. Some flows advance automatically. While it is `CONTENT_PLAN`, continue paced, bounded monitoring of the same flow. Stop for `FAIL`, `CANCELED`, or an expired monitoring window.
1. Once the same flow reports `SUCCESS`, call [List Blog Post Candidates](https://dev.wix.com/docs/api-reference/business-management/seo/content-plan-blog-post-candidate-v1/list-blog-post-candidates.md) with that flow ID to retrieve its briefs.

Calling Create Content Plan while research is `IN_PROGRESS` fails with `FLOW_NOT_READY_FOR_CONTENT_PLAN`. Elapsed time and an ID-less research read cannot substitute for matching readiness evidence.

## Retrieve the site's latest successful research

Your app wants to display the most recent completed research run, without tracking a particular content plan flow.

To display the site's latest completed research:

1. Call [Get Site Keyword Research](https://dev.wix.com/docs/api-reference/business-management/seo/site-keyword-research-v1/get-site-keyword-research.md) without `keywordResearchId`.
1. Read the returned research ID (`siteKeywordResearch.id` in REST or `siteKeywordResearch._id` in the SDK), `status`, and `contentPlanFlowId`. An ID-less request selects the latest successful research, excluding runs still in progress. If no successful run exists, the method returns a not found error.
1. Display the research ID and associated flow ID alongside its status so the site owner can identify the completed run.

Do not use this ID-less request to decide whether a different flow is ready for Create Content Plan. Follow the exact-ID monitoring flow above for that decision.