> 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/account-level/premium/premium-platform/core-services/premium-asset-v2/sample-flows.md

## Article Content:

# Premium Assets V2: 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.

## Show a customer everything they pay for

An app or assistant acting for an account owner often needs to answer "what am I
paying for". Because a single account can hold plans, domains, business email,
and digital goods, one query returns the whole picture.

To list everything an account currently pays for:

1. Call [Query Premium Assets](https://dev.wix.com/docs/api-reference/account-level/premium/premium-platform/core-services/premium-asset-v2/query-premium-assets.md) with the account in the
   `targetAccountId` header, filtering for active assets:

    ```json
    {
      "cursorQuery": {
        "filter": { "status": "ACTIVE" },
        "cursorPaging": { "limit": 50 }
      }
    }
    ```

1. For each returned asset, read `productData.productTypeName` to identify what
   kind of purchase it is.
1. Build a display name for each asset. Use `productData.productName` for
   Premium plans. For domains, business email, and digital goods that field is
   empty, so use `domainsData.domain`, `mailboxesData.domainName`, or
   `digitalGoodsData.digitalGoodsType` instead.
1. Read `siteData.siteName` to tell the customer which site each asset belongs
   to. Assets that aren't assigned to a site don't have `siteData`.
1. If `pagingMetadata.hasNext` is `true`, call
   [Query Premium Assets](https://dev.wix.com/docs/api-reference/account-level/premium/premium-platform/core-services/premium-asset-v2/query-premium-assets.md) again with `cursorPaging.cursor` set to
   `pagingMetadata.cursors.next` until every asset is retrieved.

## Tell a customer when a subscription renews

Renewal questions are the most common thing a customer asks about a
subscription. The asset carries both the renewal behavior and the last invoice,
so no second call is needed.

To report the renewal state of an account's assets:

1. Call [Query Premium Assets](https://dev.wix.com/docs/api-reference/account-level/premium/premium-platform/core-services/premium-asset-v2/query-premium-assets.md) with the account in the
   `targetAccountId` header, sorted by the next invoice date:

    ```json
    {
      "cursorQuery": {
        "filter": { "status": "ACTIVE" },
        "sort": [ { "fieldName": "wixBillingDetails.nextInvoiceDetails.date", "order": "ASC" } ]
      }
    }
    ```

1. Read `renewalType` for each asset. `AUTO_RENEW_ON` means the customer is
   charged automatically, `AUTO_RENEW_OFF` means the subscription ends at the end
   of the period, and `MANUAL` means it renews only if the customer pays.
1. Read `wixBillingDetails.nextInvoiceDetails.date` for the next charge date. For
   assets with a `renewalType` of `AUTO_RENEW_OFF`, read `subscriptionEndDate`
   instead, since there's no next invoice.
1. Read `wixBillingDetails.lastInvoiceDetails` for what the customer last paid.
   Check `billingReference.providerName` before formatting `amount`, because its
   representation depends on the billing provider.
1. Check `freeTrialData`. When `inFreeTrialPeriod` is `true`, confirm that
   `pendingExternalActivation` is `false` before telling the customer they're in
   a free trial, because the same flag is set while billing is deferred.

## Work out why a Premium product stopped working

When a customer reports that a Premium feature stopped working, the asset shows
whether the underlying purchase is still active and, for domains, whether it's
still usable.

To investigate a product that stopped working:

1. Call [Query Premium Assets](https://dev.wix.com/docs/api-reference/account-level/premium/premium-platform/core-services/premium-asset-v2/query-premium-assets.md) with the account in the
   `targetAccountId` header and no status filter, so inactive assets are returned
   too.
1. Find the affected asset by `premiumId`, or by `siteData.metasiteId` when you
   know only the site. To retrieve only the assets with specific Premium IDs,
   filter on `premiumId`:

    ```json
    {
      "cursorQuery": {
        "filter": {
          "premiumId": {
            "$in": [
              "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
              "8046df3c-7575-4098-a5ab-c91ad8f33c47"
            ]
          }
        }
      }
    }
    ```
1. Read `status`. `NOT_ACTIVE` covers every inactive situation, including
   cancelled, expired, and failed subscriptions, so it confirms the purchase is
   no longer live without saying why. `TRANSFERRED` means a new asset was created
   for a different account.
1. Read `wixBillingDetails.lastInvoiceDetails.paymentStatus`. A value of
   `CHARGE_ATTEMPT_FAILED` points to a payment problem rather than a
   cancellation.
1. For domains, read `domainsData.validInRegistrar` and
   `domainsData.expirationDate`. A domain can be active as a purchase while no
   longer being valid at the registrar.
1. For domains still within their redemption period, read
   `domainsData.redemptionPeriod` to tell the customer how long they have to
   recover it.

## Check whether a site has an active Premium plan

An app that gates features on Premium needs a yes or no answer for a specific
site.

To check a single site:

1. Call [Query Premium Assets](https://dev.wix.com/docs/api-reference/account-level/premium/premium-platform/core-services/premium-asset-v2/query-premium-assets.md) with the account in the
   `targetAccountId` header, filtering on the site and an active status:

    ```json
    {
      "cursorQuery": {
        "filter": {
          "siteData.metasiteId": "<SITE_ID>",
          "status": "ACTIVE"
        }
      }
    }
    ```

1. Treat a non-empty `premiumAssets` array as the site having an active Premium
   purchase.
1. Read `productData.productTypeId` on the returned assets to decide whether the
   specific product type your app depends on is present.