> 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

> **Deprecated.** This method is deprecated. Replacement: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/plans-v3/update-plan.md Planned removal date: 2025-12-31.

# UpdatePlan

# Package: pricingPlans

# Namespace: PlansServiceV2

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/plans-deprecated/update-plan.md

## Permission Scopes:
Manage Pricing Plans: SCOPE.DC-PAIDPLANS.MANAGE-PLANS

## Introduction

Updates a pricing plan.
Updating a plan doesn't impact existing orders made for the plan. All orders keep the details of the original plan that was active at the time of purchase.

---

## REST API

### Schema

```
 Method: updatePlan
 Description: Updates a pricing plan. Updating a plan doesn't impact existing orders made for the plan. All orders keep the details of the original plan that was active at the time of purchase.
 URL: https://www.wixapis.com/pricing-plans/v2/plans/{plan.id}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  plan, plan.id
 Method parameters: 
   param name: plan | type: Plan | description: Information about the pricing plan. | required: true 
        - name: id | type: string | description: Plan GUID. | required: true | read-only: true | validation: format GUID
        - name: name | type: string | description: Plan name.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Plan description.  | validation: maxLength 450
        - name: perks | type: StringList | description: List of text strings that promote what is included with this plan. For example, "Plenty of parking" or "Free gift on your birthday."  
           - name: values | type: array<string> | description:   | validation: maxItems 500, minLength 1, maxLength 1400
        - name: pricing | type: Pricing | description: Plan price, payment schedule, and expiration.  
           - ONE-OF: 
              - name: subscription | type: Recurrence | description: Pricing model indicating that the plan has recurring payments. This type of subscription is not a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and all pricing plan models.  
                 - name: cycleDuration | type: Duration | description: Number of payment cycles the subscription is valid for. `0` for unlimited plans or for plans that are valid until canceled.  
                    - name: count | type: integer | description: Number of days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`.  | validation: minimum 1, format int32
                    - name: unit | type: PeriodUnit | description: Unit of time for the cycle duration.  
                             - enum:
                             -     UNDEFINED: Not defined.
                             -     DAY: Time unit is a day.
                             -     WEEK: Time unit is a week.
                             -     MONTH: Time unit is a month.
                             -     YEAR: Time unit is a year.
                 - name: cycleCount | type: integer | description: Length of a payment cycle. For example, 1 month to have monthly payments. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, only a value of `1` is supported.  | validation: minimum 0, maximum 2000, format int32
              - name: singlePaymentForDuration | type: Duration | description: Pricing model indicating a single payment per cycle and the length of the cycle. The cycle is the duration of the plan, not a payment cycle.  
              - name: singlePaymentUnlimited | type: boolean | description: Pricing model indicating the plan is paid in a single payment. The plan is valid until canceled.  
           - name: price | type: Money | description: Amount for a single payment. For subscriptions, this is the amount to pay each payment cycle and it is required. For plans that are not recurring plans, it is the single payment amount for the whole subscription.  
              - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator. For example, `'3.99'`. Can't be negative.  | validation: decimalValue {"lt":"1000000000000","gte":"0.000","maxScale":3}
              - name: currency | type: string | description: Currency code. Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. For example, `'USD'`.  | validation: format CURRENCY
           - name: freeTrialDays | type: integer | description: Free trial period for the plan in days. Available only for recurring plans, meaning plans whose pricing model is `subscription`. Set to `0` to remove the free trial.  | validation: minimum 0, maximum 999, format int32
        - name: public | type: boolean | description: Whether the plan is public (visible to site visitors and members).  
        - name: maxPurchasesPerBuyer | type: integer | description: Number of times the same buyer can purchase the plan. Currently limited to support: - Empty value or a value of `0`, meaning no limitation. - Value of `1`, meaning limited to 1 purchase per buyer.  | validation: minimum 0, maximum 1, format int32
        - name: allowFutureStartDate | type: boolean | description: Whether the buyer can start the plan at a later date. Defaults to false.  
        - name: buyerCanCancel | type: boolean | description: Whether the buyer is allowed to cancel their plan. Defaults to false. If false, calling Request Cancellation returns an error.  
        - name: termsAndConditions | type: string | description: Any terms and conditions that apply to the plan. This information is displayed during checkout.  | validation: maxLength 3000
        - name: formId | type: string | description: GUID of the form associated with the plan at checkout.  Learn more about [forms](https://support.wix.com/en/article/wix-forms-an-overview).  | validation: format GUID
 Return type: UpdatePlanResponse
  - name: plan | type: Plan | description: Updated plan.  
     - name: id | type: string | description: Plan GUID.  | read-only: true | validation: format GUID
     - name: name | type: string | description: Plan name.  | validation: minLength 1, maxLength 50
     - name: description | type: string | description: Plan description.  | validation: maxLength 450
     - name: perks | type: StringList | description: List of text strings that promote what is included with this plan. For example, "Plenty of parking" or "Free gift on your birthday."  
        - name: values | type: array<string> | description:   | validation: maxItems 500, minLength 1, maxLength 1400
     - name: pricing | type: Pricing | description: Plan price, payment schedule, and expiration.  
        - ONE-OF: 
           - name: subscription | type: Recurrence | description: Pricing model indicating that the plan has recurring payments. This type of subscription is not a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and all pricing plan models.  
              - name: cycleDuration | type: Duration | description: Number of payment cycles the subscription is valid for. `0` for unlimited plans or for plans that are valid until canceled.  
                 - name: count | type: integer | description: Number of days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`.  | validation: minimum 1, format int32
                 - name: unit | type: PeriodUnit | description: Unit of time for the cycle duration.  
                         - enum:
                         -     UNDEFINED: Not defined.
                         -     DAY: Time unit is a day.
                         -     WEEK: Time unit is a week.
                         -     MONTH: Time unit is a month.
                         -     YEAR: Time unit is a year.
              - name: cycleCount | type: integer | description: Length of a payment cycle. For example, 1 month to have monthly payments. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, only a value of `1` is supported.  | validation: minimum 0, maximum 2000, format int32
           - name: singlePaymentForDuration | type: Duration | description: Pricing model indicating a single payment per cycle and the length of the cycle. The cycle is the duration of the plan, not a payment cycle.  
           - name: singlePaymentUnlimited | type: boolean | description: Pricing model indicating the plan is paid in a single payment. The plan is valid until canceled.  
        - name: price | type: Money | description: Amount for a single payment. For subscriptions, this is the amount to pay each payment cycle and it is required. For plans that are not recurring plans, it is the single payment amount for the whole subscription.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator. For example, `'3.99'`. Can't be negative.  | validation: decimalValue {"lt":"1000000000000","gte":"0.000","maxScale":3}
           - name: currency | type: string | description: Currency code. Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. For example, `'USD'`.  | validation: format CURRENCY
        - name: freeTrialDays | type: integer | description: Free trial period for the plan in days. Available only for recurring plans, meaning plans whose pricing model is `subscription`. Set to `0` to remove the free trial.  | validation: minimum 0, maximum 999, format int32
     - name: public | type: boolean | description: Whether the plan is public (visible to site visitors and members).  
     - name: archived | type: boolean | description: Whether the plan is archived. Archived plans are not visible and can't be purchased anymore, but existing purchases remain in effect.  | read-only: true 
     - name: primary | type: boolean | description: Whether the plan is marked as primary.  | read-only: true 
     - name: hasOrders | type: boolean | description: Whether the plan has any orders (including pending and unpaid orders).  | read-only: true 
     - name: createdDate | type: string | description: Date plan was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date plan was last updated.  | read-only: true | validation: format date-time
     - name: slug | type: string | description: URL-friendly version of plan name. Unique across all plans in the same site.  | read-only: true | validation: minLength 1, format URL_SLUG
     - name: maxPurchasesPerBuyer | type: integer | description: Number of times the same buyer can purchase the plan. Currently limited to support: - Empty value or a value of `0`, meaning no limitation. - Value of `1`, meaning limited to 1 purchase per buyer.  | validation: minimum 0, maximum 1, format int32
     - name: allowFutureStartDate | type: boolean | description: Whether the buyer can start the plan at a later date. Defaults to false.  
     - name: buyerCanCancel | type: boolean | description: Whether the buyer is allowed to cancel their plan. Defaults to false. If false, calling Request Cancellation returns an error.  
     - name: termsAndConditions | type: string | description: Any terms and conditions that apply to the plan. This information is displayed during checkout.  | validation: maxLength 3000
     - name: formId | type: string | description: GUID of the form associated with the plan at checkout.  Learn more about [forms](https://support.wix.com/en/article/wix-forms-an-overview).  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: client_data_is_invalid | Description: Client data format is invalid.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: free_trial_not_supported | Description: Free trial not supported for single payment plans.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: duration_missing | Description: Both duration unit and amount must be given.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: price_missing | Description: Recurring payment option must have a price.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: invalid_period_amount | Description: Period amount is out of range.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: update_not_supported | Description: Cannot update plan because it is archived.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_DURATION_UNIT | Description: Period unit is invalid.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SINGLE_PAYMENT_WITHOUT_DURATION | Description: For single-payment pricing, the plan must be either unlimited or have a set duration.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SINGLE_PAYMENT_FREE_TRIAL_UNSUPPORTED | Description: Free trials are not supported for single-payment plans.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SINGLE_PAYMENT_CYCLE_COUNT_INVALID | Description: The number of cycles must be greater than 0.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_CYCLE_COUNT_INVALID | Description: The number of cycles cannot be a negative number or 1.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_CYCLE_DURATION_TOO_SHORT | Description: The cycle length must be at least 7 days.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_PAYMENT_PRICE_MISSING | Description: The price must be defined when setting pricing options for recurring payments.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PERIOD_AMOUNT_OUT_OF_RANGE | Description: The total plan length in units is out of range.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PLAN_FEE_NAME_BLANK | Description: The plan fee name must not be empty.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PLAN_NAME_BLANK | Description: The plan name must not be empty.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_PLAN_ID | Description: To update a plan, the plan GUID must be provided.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: plan_not_found | Description: Pricing plan was not found.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PRICING_PLANS_NOT_INSTALLED | Description: The user does not have the Wix Pricing Plans app installed on the site.


```

### Examples

### UpdatePlan
```curl
~~~cURL
curl -X PATCH \
  https://www.wixapis.com/pricing-plans/v2/plans/31e40c78-...-0bf8436307fb
  --data-binary '{
        "plan": {
            "id": "31e40c78-...-0bf8436307fb",
            "name": {
                "value": "VIP Monthly Updated"
            },
            "archived": false,
            "primary": false
        }
  }'
  -H 'Authorization: <AUTH>'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.pricingPlans.plans.updatePlan(_id, plan)
 Description: Updates a pricing plan. Updating a plan doesn't impact existing orders made for the plan. All orders keep the details of the original plan that was active at the time of purchase.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  plan, _id
 Method parameters: 
   param name: _id | type: string | description: GUID of the plan to update. | required: true | validation: format GUID
   param name: plan | type: UpdatePlan | description: Information about the pricing plan. | required: true 
        - name: name | type: string | description: Plan name.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Plan description.  | validation: maxLength 450
        - name: perks | type: StringList | description: List of text strings that promote what is included with this plan. For example, "Plenty of parking" or "Free gift on your birthday."  
           - name: values | type: array<string> | description:   | validation: maxItems 500, minLength 1, maxLength 1400
        - name: pricing | type: Pricing | description: Plan price, payment schedule, and expiration.  
           - ONE-OF: 
              - name: subscription | type: Recurrence | description: Pricing model indicating that the plan has recurring payments. This type of subscription is not a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and all pricing plan models.  
                 - name: cycleDuration | type: Duration | description: Number of payment cycles the subscription is valid for. `0` for unlimited plans or for plans that are valid until canceled.  
                    - name: count | type: integer | description: Number of days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`.  | validation: minimum 1, format int32
                    - name: unit | type: PeriodUnit | description: Unit of time for the cycle duration.  
                             - enum:
                             -     UNDEFINED: Not defined.
                             -     DAY: Time unit is a day.
                             -     WEEK: Time unit is a week.
                             -     MONTH: Time unit is a month.
                             -     YEAR: Time unit is a year.
                 - name: cycleCount | type: integer | description: Length of a payment cycle. For example, 1 month to have monthly payments. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, only a value of `1` is supported.  | validation: minimum 0, maximum 2000, format int32
              - name: singlePaymentForDuration | type: Duration | description: Pricing model indicating a single payment per cycle and the length of the cycle. The cycle is the duration of the plan, not a payment cycle.  
              - name: singlePaymentUnlimited | type: boolean | description: Pricing model indicating the plan is paid in a single payment. The plan is valid until canceled.  
           - name: price | type: Money | description: Amount for a single payment. For subscriptions, this is the amount to pay each payment cycle and it is required. For plans that are not recurring plans, it is the single payment amount for the whole subscription.  
              - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator. For example, `'3.99'`. Can't be negative.  | validation: decimalValue {"lt":"1000000000000","gte":"0.000","maxScale":3}
              - name: currency | type: string | description: Currency code. Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. For example, `'USD'`.  | validation: format CURRENCY
           - name: freeTrialDays | type: integer | description: Free trial period for the plan in days. Available only for recurring plans, meaning plans whose pricing model is `subscription`. Set to `0` to remove the free trial.  | validation: minimum 0, maximum 999, format int32
        - name: public | type: boolean | description: Whether the plan is public (visible to site visitors and members).  
        - name: maxPurchasesPerBuyer | type: integer | description: Number of times the same buyer can purchase the plan. Currently limited to support: - Empty value or a value of `0`, meaning no limitation. - Value of `1`, meaning limited to 1 purchase per buyer.  | validation: minimum 0, maximum 1, format int32
        - name: allowFutureStartDate | type: boolean | description: Whether the buyer can start the plan at a later date. Defaults to false.  
        - name: buyerCanCancel | type: boolean | description: Whether the buyer is allowed to cancel their plan. Defaults to false. If false, calling Request Cancellation returns an error.  
        - name: termsAndConditions | type: string | description: Any terms and conditions that apply to the plan. This information is displayed during checkout.  | validation: maxLength 3000
        - name: formId | type: string | description: GUID of the form associated with the plan at checkout.  Learn more about [forms](https://support.wix.com/en/article/wix-forms-an-overview).  | validation: format GUID
 Return type: PROMISE<Plan>
  - name: _id | type: string | description: Plan GUID.  | read-only: true | validation: format GUID
  - name: name | type: string | description: Plan name.  | validation: minLength 1, maxLength 50
  - name: description | type: string | description: Plan description.  | validation: maxLength 450
  - name: perks | type: StringList | description: List of text strings that promote what is included with this plan. For example, "Plenty of parking" or "Free gift on your birthday."  
     - name: values | type: array<string> | description:   | validation: maxItems 500, minLength 1, maxLength 1400
  - name: pricing | type: Pricing | description: Plan price, payment schedule, and expiration.  
     - ONE-OF: 
        - name: subscription | type: Recurrence | description: Pricing model indicating that the plan has recurring payments. This type of subscription is not a "Wix subscription," which encompasses various types of subscriptions, such as Wix Stores subscriptions, Wix invoice subscriptions, and all pricing plan models.  
           - name: cycleDuration | type: Duration | description: Number of payment cycles the subscription is valid for. `0` for unlimited plans or for plans that are valid until canceled.  
              - name: count | type: integer | description: Number of days, months, weeks, or years in a single payment cycle. Currently limited to support only `1`.  | validation: minimum 1, format int32
              - name: unit | type: PeriodUnit | description: Unit of time for the cycle duration.  
                     - enum:
                     -     UNDEFINED: Not defined.
                     -     DAY: Time unit is a day.
                     -     WEEK: Time unit is a week.
                     -     MONTH: Time unit is a month.
                     -     YEAR: Time unit is a year.
           - name: cycleCount | type: integer | description: Length of a payment cycle. For example, 1 month to have monthly payments. Multiply `cycleDuration`'s `count` by `cycleCount` to get the subscription duration. Currently, only a value of `1` is supported.  | validation: minimum 0, maximum 2000, format int32
        - name: singlePaymentForDuration | type: Duration | description: Pricing model indicating a single payment per cycle and the length of the cycle. The cycle is the duration of the plan, not a payment cycle.  
        - name: singlePaymentUnlimited | type: boolean | description: Pricing model indicating the plan is paid in a single payment. The plan is valid until canceled.  
     - name: price | type: Money | description: Amount for a single payment. For subscriptions, this is the amount to pay each payment cycle and it is required. For plans that are not recurring plans, it is the single payment amount for the whole subscription.  
        - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator. For example, `'3.99'`. Can't be negative.  | validation: decimalValue {"lt":"1000000000000","gte":"0.000","maxScale":3}
        - name: currency | type: string | description: Currency code. Three-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format. For example, `'USD'`.  | validation: format CURRENCY
     - name: freeTrialDays | type: integer | description: Free trial period for the plan in days. Available only for recurring plans, meaning plans whose pricing model is `subscription`. Set to `0` to remove the free trial.  | validation: minimum 0, maximum 999, format int32
  - name: public | type: boolean | description: Whether the plan is public (visible to site visitors and members).  
  - name: archived | type: boolean | description: Whether the plan is archived. Archived plans are not visible and can't be purchased anymore, but existing purchases remain in effect.  | read-only: true 
  - name: primary | type: boolean | description: Whether the plan is marked as primary.  | read-only: true 
  - name: hasOrders | type: boolean | description: Whether the plan has any orders (including pending and unpaid orders).  | read-only: true 
  - name: _createdDate | type: Date | description: Date plan was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date plan was last updated.  | read-only: true 
  - name: slug | type: string | description: URL-friendly version of plan name. Unique across all plans in the same site.  | read-only: true | validation: minLength 1, format URL_SLUG
  - name: maxPurchasesPerBuyer | type: integer | description: Number of times the same buyer can purchase the plan. Currently limited to support: - Empty value or a value of `0`, meaning no limitation. - Value of `1`, meaning limited to 1 purchase per buyer.  | validation: minimum 0, maximum 1, format int32
  - name: allowFutureStartDate | type: boolean | description: Whether the buyer can start the plan at a later date. Defaults to false.  
  - name: buyerCanCancel | type: boolean | description: Whether the buyer is allowed to cancel their plan. Defaults to false. If false, calling Request Cancellation returns an error.  
  - name: termsAndConditions | type: string | description: Any terms and conditions that apply to the plan. This information is displayed during checkout.  | validation: maxLength 3000
  - name: formId | type: string | description: GUID of the form associated with the plan at checkout.  Learn more about [forms](https://support.wix.com/en/article/wix-forms-an-overview).  | validation: format GUID

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: client_data_is_invalid | Description: Client data format is invalid.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: free_trial_not_supported | Description: Free trial not supported for single payment plans.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: duration_missing | Description: Both duration unit and amount must be given.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: price_missing | Description: Recurring payment option must have a price.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: invalid_period_amount | Description: Period amount is out of range.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: update_not_supported | Description: Cannot update plan because it is archived.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_DURATION_UNIT | Description: Period unit is invalid.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: INVALID_SINGLE_PAYMENT_WITHOUT_DURATION | Description: For single-payment pricing, the plan must be either unlimited or have a set duration.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SINGLE_PAYMENT_FREE_TRIAL_UNSUPPORTED | Description: Free trials are not supported for single-payment plans.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: SINGLE_PAYMENT_CYCLE_COUNT_INVALID | Description: The number of cycles must be greater than 0.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_CYCLE_COUNT_INVALID | Description: The number of cycles cannot be a negative number or 1.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_CYCLE_DURATION_TOO_SHORT | Description: The cycle length must be at least 7 days.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: RECURRING_PLAN_PAYMENT_PRICE_MISSING | Description: The price must be defined when setting pricing options for recurring payments.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PERIOD_AMOUNT_OUT_OF_RANGE | Description: The total plan length in units is out of range.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PLAN_FEE_NAME_BLANK | Description: The plan fee name must not be empty.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: PLAN_NAME_BLANK | Description: The plan name must not be empty.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_PLAN_ID | Description: To update a plan, the plan GUID must be provided.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: plan_not_found | Description: Pricing plan was not found.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: PRICING_PLANS_NOT_INSTALLED | Description: The user does not have the Wix Pricing Plans app installed on the site.


```

### Examples

### Update a plan with optional fields (with elevated permissions)
```javascript
import { plans } from '@wix/pricing-plans';
import { auth } from '@wix/essentials';

/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0'
 * 
 * Sample plan value: 
 * {
 *   allowFutureStartDate: false,
 *   buyerCanCancel: true,
 *   description: 'For new users just getting the feel of the product',
 *   formId: 'ee62cefa-bdc2-4b5d-baab-6faeef83cecb',
 *   hasOrders: false,
 *   maxPurchasesPerBuyer: 0,
 *   name: 'Simple Plan',
 *   perks: {
 *     values: [
 *       'Login member access',
 *       'Access to real-time articles',
 *       'Included in mailing list'
 *     ]
 *   },
 *   pricing: {
 *     price: {
 *       currency: 'USD',
 *       value: '3'
 *     },
 *     singlePaymentForDuration: {
 *       count: 12,
 *       unit: 'MONTH'
 *     }
 *   },
 *   public: true,
 *   slug: 'simple-plan',
 *   termsAndConditions: 'I agree to refrain from sharing any of the exclusive content with non-members'
 * }
 */

export async function myUpdatePlanFunction(_id, plan) {
  try {
    const elevateUpdatePlan = auth.elevate(plans.updatePlan);
    const updatedPlan = await elevateUpdatePlan(_id, plan);

    return updatedPlan;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2024-01-07T07:13:04.076Z",
 *   "_id": "0b9a1993-c1ff-4952-9575-915b48d1a5e0",
 *   "_updatedDate": "2024-01-07T11:02:55.945Z",
 *   "allowFutureStartDate": false,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "For new users just getting the feel of the product",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 0,
 *   "name": "Simple Plan",
 *   "perks": {
 *     "values": [
 *       "Login member access",
 *       "Access to real-time articles",
 *       "Included in mailing list"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "value": "3",
 *       "currency": "USD"
 *     },
 *     "singlePaymentForDuration": {
 *       "count": 12,
 *       "unit": "MONTH"
 *     }
 *   },
 *   "primary": false,
 *   "public": true,
 *   "slug": "simple-plan"
 *   "termsAndConditions": "I agree to refrain from sharing any of the exclusive content with non-members"
 * }
 */
```

### Update a plan with optional fields
```javascript
import { plans } from '@wix/pricing-plans';

/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0'
 * 
 * Sample plan value: 
 * {
 *   allowFutureStartDate: false,
 *   buyerCanCancel: true,
 *   description: 'For new users just getting the feel of the product',
 *   formId: 'ee62cefa-bdc2-4b5d-baab-6faeef83cecb',
 *   hasOrders: false,
 *   maxPurchasesPerBuyer: 0,
 *   name: 'Simple Plan',
 *   perks: {
 *     values: [
 *       'Login member access',
 *       'Access to real-time articles',
 *       'Included in mailing list'
 *     ]
 *   },
 *   pricing: {
 *     price: {
 *       currency: 'USD',
 *       value: '3'
 *     },
 *     singlePaymentForDuration: {
 *       count: 12,
 *       unit: 'MONTH'
 *     }
 *   },
 *   public: true,
 *   slug: 'simple-plan',
 *   termsAndConditions: 'I agree to refrain from sharing any of the exclusive content with non-members'
 * }
 */

export async function myUpdatePlanFunction(_id, plan) {
  try {
    const updatedPlan = await plans.updatePlan(_id, plan);

    return updatedPlan;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2024-01-07T07:13:04.076Z",
 *   "_id": "0b9a1993-c1ff-4952-9575-915b48d1a5e0",
 *   "_updatedDate": "2024-01-07T11:02:55.945Z",
 *   "allowFutureStartDate": false,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "For new users just getting the feel of the product",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 0,
 *   "name": "Simple Plan",
 *   "perks": {
 *     "values": [
 *       "Login member access",
 *       "Access to real-time articles",
 *       "Included in mailing list"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "value": "3",
 *       "currency": "USD"
 *     },
 *     "singlePaymentForDuration": {
 *       "count": 12,
 *       "unit": "MONTH"
 *     }
 *   },
 *   "primary": false,
 *   "public": true,
 *   "slug": "simple-plan"
 *   "termsAndConditions": "I agree to refrain from sharing any of the exclusive content with non-members"
 * }
 */
```

### Update a plan (with elevated permissions)
```javascript
import { plans } from '@wix/pricing-plans';
import { auth } from '@wix/essentials';

/* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' 
 * 
 * Sample plan value: 
 * {
 *   description: 'Bronze membership to the MyGame World of Online Gaming',
 *   name: 'Bronze Plan'
 * }
 */

const elevatedUpdatePlan = auth.elevate(plans.updatePlan);

export async function myUpdatePlanFunction(_id, plan) {
  try {
    const updatedPlan = await elevatedUpdatePlan(_id, plan);

    return updatedPlan;
  } catch(errors) {
    console.error(errors);
    // Handle the error
  }
}
/* Promise resolves to:
 * {
 *   "_createdDate": "2024-01-04T12:51:42.249Z",
 *   "_id": "025a0d1f-7076-4e27-9696-4a67075dc2aa",
 *   "_updatedDate": "2024-01-07T12:53:53.562Z",
 *   "allowFutureStartDate": true,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "Bronze membership to the MyGame World of Online Gaming",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 1,
 *   "name": "Bronze Plan",
 *   "perks": {
 *     "values": [
 *       "Multiplayer",
 *       "Multiple devices",
 *       "No ads",
 *       "Unlimited access"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "currency": "USD",
 *       "value": "10.00"
 *     },
 *     "singlePaymentUnlimited": true
 *   },
 *   "primary": false,
 *   "public": false,
 *   "slug": "bronze-plan-1",
 *   "termsAndConditions": "No sharing access with others!"
 * }
 */
```

### Update a plan
```javascript
import { plans } from '@wix/pricing-plans';

/* Sample _id value: '025a0d1f-7076-4e27-9696-4a67075dc2aa' 
 * 
 * Sample plan value: 
 * {
 *   description: 'Bronze membership to the MyGame World of Online Gaming',
 *   name: 'Bronze Plan'
 * }
 */

export async function myUpdatePlanFunction(_id, plan) {
  try {
    const updatedPlan = await plans.updatePlan(_id, plan);

    return updatedPlan;
  } catch(errors) {
    console.error(errors);
    // Handle the error
  }
}
/* Promise resolves to:
 * {
 *   "_createdDate": "2024-01-04T12:51:42.249Z",
 *   "_id": "025a0d1f-7076-4e27-9696-4a67075dc2aa",
 *   "_updatedDate": "2024-01-07T12:53:53.562Z",
 *   "allowFutureStartDate": true,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "Bronze membership to the MyGame World of Online Gaming",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 1,
 *   "name": "Bronze Plan",
 *   "perks": {
 *     "values": [
 *       "Multiplayer",
 *       "Multiple devices",
 *       "No ads",
 *       "Unlimited access"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "currency": "USD",
 *       "value": "10.00"
 *     },
 *     "singlePaymentUnlimited": true
 *   },
 *   "primary": false,
 *   "public": false,
 *   "slug": "bronze-plan-1",
 *   "termsAndConditions": "No sharing access with others!"
 * }
 */
```

### updatePlan (self-managed)
Self-managed 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 { plans } from '@wix/pricing-plans';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function updatePlan(_id,plan) {
  const response = await myWixClient.plans.updatePlan(_id,plan);
};
```

---