> 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

# GetChargeLimit

# Package: appBilling

# Namespace: CustomChargesProvider

# Method link: https://dev.wix.com/docs/api-reference/app-management/app-billing/custom-charges-service-plugin/get-charge-limit.md

## Introduction

Wix calls this method to retrieve the initial charge limit for a paid instance
of your app. This happens every time a customer is upgrading to a paid version of
your app.

You can't update the charge limit after you've set an initial
value. Customers can increase the limit in their site's dashboard, currently they
aren't allowed to decrease it.

> **Note:**
> This feature isn't yet available to all users. Your app can have only 1 usage-based plan and no other plans. To add a usage-based plan to your app, [submit a request to add a usage-based plan](https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels).

---

## REST API

### Schema

```
 Method: getChargeLimit
 Description: Wix calls this method to retrieve the initial charge limit for a paid instance of your app. This happens every time a customer is upgrading to a paid version of your app.  You can't update the charge limit after you've set an initial value. Customers can increase the limit in their site's dashboard, currently they aren't allowed to decrease it.  > **Note:** > This feature isn't yet available to all users. Your app can have only 1 usage-based plan and no other plans. To add a usage-based plan to your app, [submit a request to add a usage-based plan](https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels).
 URL: {DEPLOYMENT-URI}/v1/charge-limit
 Method: POST
 Method parameters:
   param name: currency | type: currency | description: Supported values: `AUD`, `BRL`, `CAD`, `EUR`, `GBP`, `ILS`, `INR`, `JPY`, `MXN`, `PLN`, `RUB`, `TRY`, `USD`.  3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format of the charge limit. Wix may add supported currencies in the future.  | validation: format CURRENCY
   param name: cycle | type: Cycle    
        - name: cycleType | type: CycleType | description: Payment type. + `UNKNOWN`: The payment type hasn't been set. + `ONE_TIME`: The reseller pays Wix in a single payment. + `RECURRING`: The reseller pays Wix on a recurring schedule.  
             - enum: ONE_TIME, RECURRING
        - name: cycleDuration | type: Duration | description: Duration of the billing cycle. Available only for `RECURRING` payments.  
           - name: unit | type: DurationUnit | description: Unit of the billing cycle.  
                 - enum:
                 -     DAY: day
                 -     WEEK: week
                 -     MONTH: month
                 -     YEAR: year
           - name: count | type: integer | description: Count of units that make up the billing cycle.  | validation: minimum 0
   param name: subscriptionId | type: subscriptionId | description: GUID of the subscription for which Wix retrieves the charge limit. Equals `null` in case Wix hasn't created the subscription when retrieving an initial charge limit. To track usage and billing for apps, we recommend to use `instanceId` instead of the `subscriptionId`.  | validation: format GUID
 Return type: GetChargeLimitResponse
  - name: chargeLimit | type: string | description: Retrieved charge limit for the app instance. You can't update the charge limit after you've set an initial value. Site owners can increase the limit in their site's dashboard, currently they aren't allowed to decrease it.  | validation: format DECIMAL_VALUE, decimalValue {"gt":"0.00"}


```

### Examples

### Return an app instance's initial charge limit.
The data payload includes the following object as an encoded JWT. Here, we show the request and response objects decoded.

```curl
curl -X POST \
'https://provider.example.com/v1/charge-limit' \
-H 'Authorization: <AUTH>' \
-d '{
  "data": {
    "request": {
      "subscriptionId": "efa6b37d-74c6-44bb-b639-28c4af3957dd",
      "currency": "USD"
    },
    "metadata": {
      "requestId": "1680014776.67327419774788218037",
      "identity": {
        "identityType": "APP",
        "appId": "365288ae-38f4-4932-92d5-d45c596c7260"
      },
      "instanceId": "3aa496c3-aa49-4369-84e6-3fa1876f191d"
    }
  },
  "aud": "6675724b-bf3e-482a-9a00-65616953b570",
  "iss": "wix.com",
  "iat": 1680014777,
  "exp": 1683614777
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.appManagement.customCharges.getChargeLimit(request, metadata)
 Description: Wix calls this method to retrieve the initial charge limit for a paid instance of your app. This happens every time a customer is upgrading to a paid version of your app.  You can't update the charge limit after you've set an initial value. Customers can increase the limit in their site's dashboard, currently they aren't allowed to decrease it.  > **Note:** > This feature isn't yet available to all users. Your app can have only 1 usage-based plan and no other plans. To add a usage-based plan to your app, [submit a request to add a usage-based plan](https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels).
 Method parameters:
   param name: request | type: GetChargeLimitRequest    
        - name: subscriptionId | type: string | description: GUID of the subscription for which Wix retrieves the charge limit. Equals `null` in case Wix hasn't created the subscription when retrieving an initial charge limit. To track usage and billing for apps, we recommend to use `instanceId` instead of the `subscriptionId`.  | validation: format GUID
        - name: currency | type: string | description: Supported values: `AUD`, `BRL`, `CAD`, `EUR`, `GBP`, `ILS`, `INR`, `JPY`, `MXN`, `PLN`, `RUB`, `TRY`, `USD`.  3-letter currency code in [ISO-4217 alphabetic](https://en.wikipedia.org/wiki/ISO_4217#Active_codes) format of the charge limit. Wix may add supported currencies in the future.  | validation: format CURRENCY
        - name: cycle | type: Cycle | description: Billing cycle the charge limit applies to.  
           - name: cycleType | type: CycleType | description: Payment type. + `UNKNOWN`: The payment type hasn't been set. + `ONE_TIME`: The reseller pays Wix in a single payment. + `RECURRING`: The reseller pays Wix on a recurring schedule.  
                 - enum: ONE_TIME, RECURRING
           - name: cycleDuration | type: Duration | description: Duration of the billing cycle. Available only for `RECURRING` payments.  
              - name: unit | type: DurationUnit | description: Unit of the billing cycle.  
                     - enum:
                     -     DAY: day
                     -     WEEK: week
                     -     MONTH: month
                     -     YEAR: year
              - name: count | type: integer | description: Count of units that make up the billing cycle.  | validation: minimum 0
   param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature.  Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ```  
        - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs.  
        - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.  | validation: format CURRENCY
        - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request.  
           - ONE-OF: 
              - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.  | validation: format GUID
              - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.  | validation: format GUID
              - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).  | validation: format GUID
              - name: appId | type: string | description: GUID of an app.  | validation: format GUID
        - name: languages | type: array<string> | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.  
        - name: instanceId | type: string | description: The service provider app's instance GUID.  | validation: format GUID
 Return type: PROMISE<GetChargeLimitResponse>
  - name: chargeLimit | type: string | description: Retrieved charge limit for the app instance. You can't update the charge limit after you've set an initial value. Site owners can increase the limit in their site's dashboard, currently they aren't allowed to decrease it.  | validation: format DECIMAL_VALUE, decimalValue {"gt":"0.00"}


```

### Examples

### Example of a `chargeLimit` return value
```javascript
import { customCharges } from '@wix/app-management/service-plugins';

customCharges.provideHandlers({

  getChargeLimit: async ( payload ) => {
    const {request, metadata} = payload;
        // Use the `request` and `metadata` received from Wix and
        // apply custom logic.
      return {
        // Return your response exactly as documented to integrate with Wix.
        // Return value example:
        chargeLimit: "1000.00"
      }
    }
});

```

### getChargeLimit (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 { customCharges } from '@wix/app-management/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function getChargeLimit(request,metadata) {
  const response = await myWixClient.customCharges.getChargeLimit(request,metadata);
};
```

---