> 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

# GetBalance

# Package: aiCredits

# Namespace: CreditTransactionsService

# Method link: https://dev.wix.com/docs/api-reference/account-level/ai-credits/get-balance.md

## Permission Scopes:
Manage SEO Settings: SCOPE.PROMOTE.MANAGE-SEO

## Introduction

Retrieves an account's current AI credit balance.

The balance includes recurring (periodic) credits, one-time top-up credits, and a per-source
breakdown of the same credits. Use it to check an account's available credits before running an
AI action, or to display the balance to an account.

The data returned depends on the caller's access. With account-level access, the response covers
all of the account's credits. With site-level access, the response is scoped to the credits and
subscription of the site in context. When the caller has both, the account-level balance is returned.

---

## REST API

### Schema

```
 Method: getBalance
 Description: Retrieves an account's current AI credit balance.  The balance includes recurring (periodic) credits, one-time top-up credits, and a per-source breakdown of the same credits. Use it to check an account's available credits before running an AI action, or to display the balance to an account.  The data returned depends on the caller's access. With account-level access, the response covers all of the account's credits. With site-level access, the response is scoped to the credits and subscription of the site in context. When the caller has both, the account-level balance is returned.
 URL: https://www.wixapis.com/appmarket/credittransactions/v1/credit-transactions/balance
 Method: POST
 Return type: GetBalanceResponse
  - name: periodicCredits | type: Periodic | description: An account's recurring (periodic) credits, aggregated across all sources.  Recurring credits replenish each period, such as monthly.  Returned only when the account has recurring credits.  
     - name: balance | type: integer | description: Remaining recurring credits currently available.  Decreases as credits are consumed and replenishes each period.  | validation: minimum 0
     - name: cap | type: integer | description: Maximum recurring credits available per period.  | validation: minimum 0
  - name: topUpCredits | type: TopUp | description: An account's one-time top-up credits, aggregated across all purchases.  Top-up credits supplement recurring credits and don't reset.  Returned only when the account has top-up credits.  
     - name: balance | type: integer | description: Remaining one-time top-up credits currently available.  | validation: minimum 0
     - name: cap | type: integer | description: Maximum one-time top-up credits available.  | validation: minimum 0
  - name: creditBalanceBreakdown | type: array<CreditBalance> | description: A per-source breakdown of the account's credit balances.  Each entry covers a distinct credit allocation and its usage rules, so you can track credits from different sources separately. This is a detailed view of the same credits aggregated in `periodicCredits` and `topUpCredits`, not additional credits.  | validation: maxItems 1000
     - name: subscriptionId | type: string | description: GUID of the subscription this credit allocation belongs to.  Empty for credits that aren't tied to a subscription.  | validation: format GUID
     - name: usageRules | type: array<UsageRule> | description: Rules that define how the credits in this allocation can be consumed.  Multiple rules can apply together, such as a daily limit within a monthly allocation.  | validation: maxItems 10
        - name: period | type: FeaturePeriod | description: How often the credits under this rule replenish, such as daily or monthly.  Some credits have no period, meaning they're one-time and don't reset.  
             - enum: NO_PERIOD, MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
        - name: balance | type: integer | description: Remaining credits available under this rule.  
        - name: cap | type: integer | description: Maximum credits allowed under this rule per period.  
        - name: resetDate | type: string | description: Date and time when this rule's balance resets to `cap`.  | validation: format date-time
     - name: planTierId | type: string | description: Premium product-family id (the plan tier) backing this credit allocation.  Empty when no active premium asset matches the subscription.  | validation: format GUID
     - name: autoRenew | type: boolean | description: Whether the backing premium subscription renews automatically.  `false` when no active premium asset matches the subscription.  
     - name: planName | type: string | description: Display name of the premium plan (product name) backing this credit allocation.  Empty when no active premium asset matches the subscription.  | validation: maxLength 200
  - name: walletScope | type: WalletScope | description: Which wallet the balance was read from: the account's credits or the current site's credits.  Use it to label a site-scoped balance.  
     - enum:
     -     ACCOUNT: The balance is the account's credits.
     -     SITE: The balance is the current site's credits: the caller has site-level credits access only.


```

### Examples

### Retrieve an account's AI credit balance
Retrieves the calling account's current AI credit balance, including recurring credits, top-up credits, and a per-source breakdown.

```curl
curl -X POST \
'https://www.wixapis.com/appmarket/credittransactions/v1/credit-transactions/balance' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.aiCredits.aiCredits.getBalance()
 Description: Retrieves an account's current AI credit balance.  The balance includes recurring (periodic) credits, one-time top-up credits, and a per-source breakdown of the same credits. Use it to check an account's available credits before running an AI action, or to display the balance to an account.  The data returned depends on the caller's access. With account-level access, the response covers all of the account's credits. With site-level access, the response is scoped to the credits and subscription of the site in context. When the caller has both, the account-level balance is returned.
 Return type: PROMISE<GetBalanceResponse>
  - name: periodicCredits | type: Periodic | description: An account's recurring (periodic) credits, aggregated across all sources.  Recurring credits replenish each period, such as monthly.  Returned only when the account has recurring credits.  
     - name: balance | type: integer | description: Remaining recurring credits currently available.  Decreases as credits are consumed and replenishes each period.  | validation: minimum 0
     - name: cap | type: integer | description: Maximum recurring credits available per period.  | validation: minimum 0
  - name: topUpCredits | type: TopUp | description: An account's one-time top-up credits, aggregated across all purchases.  Top-up credits supplement recurring credits and don't reset.  Returned only when the account has top-up credits.  
     - name: balance | type: integer | description: Remaining one-time top-up credits currently available.  | validation: minimum 0
     - name: cap | type: integer | description: Maximum one-time top-up credits available.  | validation: minimum 0
  - name: creditBalanceBreakdown | type: array<CreditBalance> | description: A per-source breakdown of the account's credit balances.  Each entry covers a distinct credit allocation and its usage rules, so you can track credits from different sources separately. This is a detailed view of the same credits aggregated in `periodicCredits` and `topUpCredits`, not additional credits.  | validation: maxItems 1000
     - name: subscriptionId | type: string | description: GUID of the subscription this credit allocation belongs to.  Empty for credits that aren't tied to a subscription.  | validation: format GUID
     - name: usageRules | type: array<UsageRule> | description: Rules that define how the credits in this allocation can be consumed.  Multiple rules can apply together, such as a daily limit within a monthly allocation.  | validation: maxItems 10
        - name: period | type: FeaturePeriod | description: How often the credits under this rule replenish, such as daily or monthly.  Some credits have no period, meaning they're one-time and don't reset.  
             - enum: NO_PERIOD, MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
        - name: balance | type: integer | description: Remaining credits available under this rule.  
        - name: cap | type: integer | description: Maximum credits allowed under this rule per period.  
        - name: resetDate | type: Date | description: Date and time when this rule's balance resets to `cap`.  
     - name: planTierId | type: string | description: Premium product-family id (the plan tier) backing this credit allocation.  Empty when no active premium asset matches the subscription.  | validation: format GUID
     - name: autoRenew | type: boolean | description: Whether the backing premium subscription renews automatically.  `false` when no active premium asset matches the subscription.  
     - name: planName | type: string | description: Display name of the premium plan (product name) backing this credit allocation.  Empty when no active premium asset matches the subscription.  | validation: maxLength 200
  - name: walletScope | type: WalletScope | description: Which wallet the balance was read from: the account's credits or the current site's credits.  Use it to label a site-scoped balance.  
     - enum:
     -     ACCOUNT: The balance is the account's credits.
     -     SITE: The balance is the current site's credits: the caller has site-level credits access only.


```

### Examples

### Retrieve an account's AI credit balance
```javascript
import { aiCredits } from "@wix/ai-credits";

async function getBalance() {
  const response = await aiCredits.getBalance();

  return response;
}

/* Promise resolves to:
 * {
 *   "periodicCredits": {
 *     "balance": 850,
 *     "cap": 1000
 *   },
 *   "topUpCredits": {
 *     "balance": 200,
 *     "cap": 200
 *   },
 *   "creditBalanceBreakdown": [
 *     {
 *       "subscriptionId": "d7a341c4-196b-46e7-813c-2b0fc1847ec6",
 *       "usageRules": [
 *         {
 *           "period": "MONTH",
 *           "balance": 850,
 *           "cap": 1000,
 *           "resetDate": "2026-07-01T00:00:00.000Z"
 *         }
 *       ]
 *     },
 *     {
 *       "usageRules": [
 *         {
 *           "period": "NO_PERIOD",
 *           "balance": 200,
 *           "cap": 200
 *         }
 *       ]
 *     }
 *   ],
 *   "walletScope": "ACCOUNT"
 * }
 */

```

### getBalance (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 { aiCredits } from '@wix/ai-credits';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function getBalance() {
  const response = await myWixClient.aiCredits.getBalance();
};
```

---