> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omocaptcha.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kiểm tra số dư

> Kiểm tra số dư tài khoản hiện tại

Lấy nhanh số dư hiện tại của tài khoản, gồm cả số dư khuyến mại.

## Request

```http theme={null}
POST https://api.omocaptcha.com/v2/getBalance
Content-Type: application/json
```

### Body Parameters

| Tham số | Kiểu | Bắt buộc | Mô tả |
| - | - | :-: | - |
| `clientKey` | `String` | ✅ | API key của tài khoản |

```json theme={null}
{
  "clientKey": "OMO_API_KEY"
}
```

## Response

```json Thành công theme={null}
{
  "errorId": 0,
  "errorCode": "",
  "errorDescription": "",
  "balance": "50.00000",
  "voucherBalance": "40.60000"
}
```

```json Thành công (tokenPackage) theme={null}
{
  "errorId": 0,
  "errorCode": "",
  "errorDescription": "",
  "balance": "50.00000",
  "voucherBalance": "40.60000",
  "quantity": "1006190"
}
```

```json Thất bại theme={null}
{
  "errorId": 1,
  "errorCode": "ERROR_KEY_DOES_NOT_EXIST",
  "errorDescription": "API key does not exist"
}
```

### Giải thích các trường

| Trường | Kiểu | Mô tả |
| - | - | - |
| `errorId` | integer | `0` = thành công, `1` = lỗi nghiệp vụ |
| `errorCode` | `String` | Mã lỗi (rỗng nếu thành công) |
| `errorDescription` | `String` | Mô tả chi tiết lỗi |
| `balance` | `String` | Số dư chính (USD, kiểu chuỗi để giữ độ chính xác thập phân) |
| `voucherBalance` | `String` | Số dư khuyến mại. Khi `balance` không đủ, hệ thống sẽ tự động dùng số dư này |
| `quantity` | `String` | **Chỉ xuất hiện khi `clientKey` là tokenPackage dạng `PKG_...`** — số lượt giải còn lại của gói |

> [!TIP]
>
> Xem **Bảng mã lỗi** để biết danh sách đầy đủ các `errorCode`.

## Ví dụ sử dụng

```bash cURL theme={null}
curl -X POST https://api.omocaptcha.com/v2/getBalance \
  -H "Content-Type: application/json" \
  -d '{"clientKey": "OMO_API_KEY"}'
```

```javascript Node.js theme={null}
const res = await fetch("https://api.omocaptcha.com/v2/getBalance", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ clientKey: "OMO_API_KEY" })
});
const data = await res.json();
console.log(data);
```

```python Python theme={null}
import requests

res = requests.post(
    "https://api.omocaptcha.com/v2/getBalance",
    json={"clientKey": "OMO_API_KEY"}
)
print(res.json())
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.