# getBalance

> POST /getBalance returns what your key can spend, in USD.

Source: https://docs.peak.fo/docs/compat/get-balance

`POST https://api.peak.fo/getBalance`

Returns what your key can spend, in USD. It's free.

## Request [#request]

| Field       | Type     | Required | Description   |
| ----------- | -------- | -------- | ------------- |
| `clientKey` | `string` | Yes      | Your API key. |

```bash title="Terminal"
curl https://api.peak.fo/getBalance \
  -H "Content-Type: application/json" \
  -d '{"clientKey": "pk_your_api_key"}'
```

## Response [#response]

| Field      | Type     | Description                                    |
| ---------- | -------- | ---------------------------------------------- |
| `errorId`  | `number` | `0` if the request worked.                     |
| `balance`  | `number` | What the key can spend, in USD.                |
| `packages` | `array`  | Always empty. It's there for CapSolver code.   |

```json tab="Success"
{
  "errorId": 0,
  "balance": 12.5,
  "packages": []
}
```

```json tab="Error"
{
  "errorId": 1,
  "errorCode": "ERROR_KEY_DOES_NOT_EXIST",
  "errorDescription": "invalid API key"
}
```

## Package keys [#package-keys]

A [package](/docs/pricing#packages) key has solves, not dollars. So `balance` is what the solves left are worth: the solves left × the package's price per solve, rounded down to 4 decimals.

For example, a package of 500,000 solves bought for $250 is worth $0.0005 a solve. With 342,819 solves left, `balance` is `171.4095`.

When the package is used up or expires, `balance` is `0`, so code that stops at a zero balance stops at the right time. For the exact number of solves left and the expiry date, use the native [`GET /balance`](/docs/api/balance).
