# Balance

> GET /balance returns what your API key can spend.

Source: https://docs.peak.fo/docs/api/balance

`GET https://api.peak.fo/balance`

Returns your balance, or what's left on your package. It's free, so it's also the easiest way to check that a key works.

## Request [#request]

| Header      | Value         |
| ----------- | ------------- |
| `X-API-Key` | Your API key. |

```bash title="Terminal"
curl https://api.peak.fo/balance \
  -H "X-API-Key: pk_your_api_key"
```

For examples in Python, JavaScript and Go, see [Authentication](/docs/authentication#check-your-key).

## Response [#response]

The fields in `data` depend on how the key is billed.

**Pay-per-solve key.** Each successful solve is taken from your balance.

| Field          | Type     | Description                   |
| -------------- | -------- | ----------------------------- |
| `data.type`    | `string` | `pay_per_solve`               |
| `data.balance` | `number` | Your account balance, in USD. |

**Package key.** Solves come out of the package instead of your balance.

| Field                   | Type       | Description                                      |
| ----------------------- | ---------- | ------------------------------------------------ |
| `data.type`             | `string`   | `package`                                        |
| `data.package_name`     | `string`   | The package's name.                              |
| `data.remaining_solves` | `number`   | Solves left.                                     |
| `data.total_solves`     | `number`   | Solves the package started with.                 |
| `data.allowed_tasks`    | `string[]` | The `task_type` values this key can solve, or `["all"]`. A Turnstile package covers both Turnstile task types. |
| `data.expires_at`       | `string`   | When the package expires, as an ISO 8601 time.   |
| `data.days_remaining`   | `number`   | Whole days until it expires.                     |

```json tab="Pay-per-solve key"
{
  "success": true,
  "data": {
    "type": "pay_per_solve",
    "balance": 12.5
  }
}
```

```json tab="Package key"
{
  "success": true,
  "data": {
    "type": "package",
    "package_name": "Turnstile 500K",
    "remaining_solves": 342819,
    "total_solves": 500000,
    "allowed_tasks": ["turnstiletask", "turnstiletaskproxyless"],
    "expires_at": "2026-12-25T00:00:00Z",
    "days_remaining": 30
  }
}
```

```json tab="Failure"
{
  "success": false,
  "error": "invalid API key",
  "error_code": "invalid_api_key"
}
```

## Errors [#errors]

| `error_code`       | HTTP  | What to do                                                 |
| ------------------ | ----- | ---------------------------------------------------------- |
| `missing_api_key`  | `401` | Send the key in the `X-API-Key` header.                    |
| `invalid_api_key`  | `401` | Check for typos, or copy the key again from the dashboard. |
| `api_key_inactive`  | `401` | The key was turned off, or its package expired or ran out. |
| `account_suspended` | `401` | Your account is suspended. [Contact support](/docs/support). |
| `auth_error`        | `401` | We couldn't check the key. Retry.                          |
| `internal_error`   | `500` | Something went wrong on our side. Retry.                   |
