> 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-solutions/cms/operations/data-movement-jobs/sample-flows.md

## Article Content:

# Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful jumping off point as you plan your implementation.

## Export data from a collection to a file

Submit a job to export selected products from a [Wix data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/introduction.md) to a CSV file:

1. Call [Submit Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/submit-job.md) with the following parameters:

   ```json
   {
     "name": "Export Christmas products",
     "source": {
       "wixDataCollection": {
         "collectionId": "products",
         "filter": {
           "holidays": {
             "$in": ["xmas"]
           }
         }
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv"
       }
     }
   }
   ```

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Export Christmas products",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "INITIALIZING",
     "source": {
       "wixDataCollection": {
         "collectionId": "products",
         "filter": {
           "holidays": {
             "$in": ["xmas"]
           }
         }
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv",
         "url": "http://example.com/files/xmasProducts.csv"
       }
     }
   }
   ```

2. To check the job's status, call the [Get Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/get-job.md) method with the job's `id`.

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Export Christmas products",
     "startedAt": "2024-03-15T14\:32\:14.753Z",
     "status": "IN_PROGRESS",
     "progress": {
       "current": 15,
       "total": 25,
       "itemsRejected": 1,
       "itemsSuccessful": 14
     },
     "source": {
       "wixDataCollection": {
         "collectionId": "products",
         "filter": {
           "holidays": {
             "$in": ["xmas"]
           }
         }
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv",
         "url": "http://example.com/files/xmasProducts.csv"
       }
     },
     "logsRecorded": 1
   }
   ```

   A job is completed when its `status` updates to `COMPLETED` or `PARTIALLY_SUCCESSFUL`.

   > **Note**: To respond in real time when a job's `status` is updated, you can subscribe to the [Job Updated](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/job-updated.md) webhook. Learn more [about webhooks](https://dev.wix.com/docs/build-apps/develop-your-app/api-integrations/events-and-webhooks/about-webhooks.md).

3. When the job completes, download the file from the URL in the response's `destination.file.url` property.

4. To know more about the job's results, view the job's logs by calling [List Movement Jobs](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/list-movement-logs.md).

   The method returns a response such as:

   ```json
   {
     "logs": [
       {
         "sourceItemId": "5331fc15-9441-4fd4-bc7b-7f6870c69228",
         "failure": {
           "code": "WDE0074",
           "description": "An item with _id 5331fc15-9441-4fd4-bc7b-7f6870c69228 already exists."
         }
       }
     ],
     "pagingMetadata": {
       "count": 1,
       "hasNext": false
     }
   }
   ```

## Import data from a file to a collection

Submit a job to import products from a CSV file into a Wix data collection. If a product already exists in the destination collection, the job skips it:

1. Call [Create File Upload Url](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/create-file-upload-url.md) to generate a file upload URL.

   The method returns a response such as:

   ```json
   {
     "fileId": "temporary-files/1234567.dat",
     "uploadUrl": "http://example.com/temporary-files/1234567.dat"
   }
   ```

   Save `fileId` and `uploadUrl` for later use.

2. Upload the source file to the `uploadUrl` you saved in the previous step. For example:

   ```curl
   curl --request PUT --upload-file "./newProducts.csv" "http://example.com/temporary-files/1234567.dat"
   ```

   > **Note**: The upload URL is valid for 15 minutes.

3. Call [Submit Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/submit-job.md) with the following parameters. In the request's `source.file.fileId` property, specify the `fileId` you saved earlier:

   ```json
   {
     "name": "Import new products",
     "source": {
       "file": {
         "format": "CSV",
         "fileId": "temporary-files/1234567.dat"
       }
     },
     "destination": {
       "wixDataCollection": {
         "collectionId": "products",
         "writePolicy": "SKIP_EXISTING"
       }
     }
   }
   ```

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Import new products",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "INITIALIZING",
     "source": {
       "file": {
         "format": "CSV",
         "fileName": "temporary-files/1234567.dat",
         "url": "http://example.com/temporary-files/1234567.dat"
       }
     },
     "destination": {
       "wixDataCollection": {
         "collectionId": "products",
         "writePolicy": "SKIP_EXISTING"
       }
     }
   }
   ```

   Wix Data now begins importing the data from the file into the specified collection.

4. To check the job's status, call the [Get Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/get-job.md) method with the job's `id`.

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Import new products",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "COMPLETED",
     "source": {
       "file": {
         "format": "CSV",
         "fileId": "temporary-files/1234567.dat",
         "url": "http://example.com/files/xmasProducts.csv"
       }
     },
     "destination": {
       "wixDataCollection": {
         "collectionId": "products",
         "writePolicy": "SKIP_EXISTING"
       }
     },
     "finished_at": "2024-03-15T14\:32\:16.867Z"
   }
   ```

   A job is completed when its `status` updates to `COMPLETED` or `PARTIALLY_SUCCESSFUL`.

   > **Note**: To respond in real time when a job's `status` is updated, you can subscribe to the [Job Updated](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/job-updated.md) webhook. Learn more [about webhooks](https://dev.wix.com/docs/build-apps/develop-your-app/api-integrations/events-and-webhooks/about-webhooks.md).

When the job completes, you can access the imported items in the [CMS](https://support.wix.com/en/article/cms-content-management-system-an-overview) and with [Wix Data APIs](https://dev.wix.com/docs/rest/business-solutions/cms/introduction.md).

## Export, edit, and import localized CMS content

Submit a job to export localized CMS content to a CSV file. After editing its content, import it back to the site:

1. Call [Submit Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/submit-job.md) with the following parameters:

   ```json
   {
     "source": {
       "localization": {
         "languages": ["EN-US", "DE", "HE"]
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv"
       }
     },
     "name": "Export product translations"
   }
   ```

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Export xmas product translations",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "INITIALIZING",
     "source": {
       "localization": {
         "languages": ["EN-US", "DE", "HE"]
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv",
         "url": "http://example.com/files/xmasProducts.csv"
       }
     }
   }
   ```

2. To check the job's status, call [Get Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/get-job.md) with the job's `id`:

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Export xmas product translations",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "COMPLETED",
     "source": {
       "localization": {
         "languages": ["EN-US", "DE", "HE"]
       }
     },
     "destination": {
       "file": {
         "format": "CSV",
         "fileName": "xmasProducts.csv",
         "url": "http://example.com/files/xmasProducts.csv"
       }
     },
     "finishedAt": "2024-03-15T14\:33\:10.007Z"
   }
   ```

   A job is completed when its `status` updates to `COMPLETED` or `PARTIALLY_SUCCESSFUL`

   > **Note**: To respond in real time when a job's `status` is updated, you can subscribe to the [Job Updated](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/job-updated.md) webhook. Learn more [about webhooks](https://dev.wix.com/docs/build-apps/develop-your-app/api-integrations/events-and-webhooks/about-webhooks.md).

3. Download the file from the URL in the response's `destination.file.url` property and edit its content.

4. Call [Create File Upload Url](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/create-file-upload-url.md) to generate a file upload URL:

   ```json
   {
     "fileName": "xmasProducts"
   }
   ```

   The method returns a response such as:

   ```json
   {
     "fileId": "temporary-files/xmasProducts.dat",
     "uploadUrl": "http://example.com/temporary-files/xmasProducts.dat"
   }
   ```

   Save `fileId` and `uploadUrl` for later use.

5. Upload the edited file to the `uploadUrl` you saved in the previous step. For example:

   ```curl
   curl --request PUT --upload-file "./xmasProducts.csv" "http://example.com/temporary-files/xmasProducts.dat"
   ```

   > **Note**: The upload URL is valid for 15 minutes.

6. Call [Submit Job](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/submit-job.md) again to import the edited product translations back into the site's CMS. In the request's `source.file.fileId`, specify the `fileId` you saved earlier. In the request's `destination.localization.languages` array, specify the languages you want to import:

   > **Note**: The first language in the `destination.localization.languages` array is considered the main CMS language.

   ```json
   {
     "name": "Import edited product translations",
     "source": {
       "file": {
         "format": "CSV",
         "fileId": "temporary-files/xmasProducts.dat"
       }
     },
     "destination": {
       "localization": {
         "languages": ["EN-US", "DE", "HE"]
       }
     }
   }
   ```

   The method returns a response such as:

   ```json
   {
     "id": "8646fc6e-58f3-4d78-b3ab-6a63a5a46400",
     "name": "Import edited product translations",
     "startedAt": "2024-03-15T14\:30\:29.162Z",
     "status": "INITIALIZING",
     "source": {
       "file": {
         "format": "CSV",
         "fileId": "temporary-files/xmasProducts.dat"
       }
     },
     "destination": {
       "localization": {
         "languages": ["EN-US", "DE", "HE"]
       }
     }
   }
   ```

   A job is completed when its `status` is updated to `COMPLETED` or `PARTIALLY_SUCCESSFUL`.

   > **Note**: To respond in real time when a job's `status` is updated, you can subscribe to the [Job Updated](https://dev.wix.com/docs/rest/business-solutions/cms/data-movement-jobs/job-updated.md) webhook. Learn more [about webhooks](https://dev.wix.com/docs/build-apps/develop-your-app/api-integrations/events-and-webhooks/about-webhooks.md).

   When the job completes, you can access the imported items using:

   - The [Translation Manager](https://support.wix.com/en/article/wix-multilingual-using-the-translation-manager).
   - The [Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/introduction.md) APIs.
   - The [Wix Multilingual](https://dev.wix.com/docs/rest/business-management/multilingual/translation/introduction.md) APIs.