# Check an account balance

Source: [Check an account balance](<https://docs.gptunnel.ru/en/getting-started/balance/>)

<a id="_top"></a>
> **Note: API key access**
>
> Before your first request, [get an API key](<https://docs.gptunnel.ru/en/#get-an-api-key>).

<a id="get-balance"></a>
## Get Balance

`GET https://gptunnel.ru/v1/balance`

Returns the balance and credit limit of the selected account in rubles.

Call `GET /v1/balance` without parameters to find out which account the key belongs to.

- If `orgId` contains an organization ID, the key belongs to that organization and the response shows its balance. Add `?useWalletBalance=true` to get the key owner’s personal balance.
- If `orgId` is `null`, the key belongs to a personal account and always returns that account’s balance.

### Query parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `useWalletBalance` | `bool` | Get a personal account balance |

### Request headers

| Parameter | Type | Description |
| --- | --- | --- |
| `Authorization` (required) | `string` | API key |

 <a id="ответы"></a>
 
<a id="response"></a>
### Response

An HTTP 200 response contains all five fields.

### Response fields

| Parameter | Type | Description |
| --- | --- | --- |
| `orgId` (required) | `string \| null` | ID of the organization whose balance was returned. null for a personal balance, including when useWalletBalance=true |
| `userId` (required) | `string` | ID of the API key owner, including when the response shows an organization balance |
| `object` (required) | `string` | Object type. Always balance. |
| `balance` (required) | `number` | Balance in rubles rounded to the nearest kopeck. It can be negative and excludes bonuses and the credit limit. |
| `creditLimit` (required) | `number` | Credit limit in rubles. Always 0 for a personal account. |

<a id="tab-panel-0-0"></a>
**200 OK**

**Balance of the organization**

```json
{
  "orgId": "ddc0652cde46d307200011c4",
  "userId": "0123456789abcdef01234567",
  "object": "balance",
  "balance": -51.54,
  "creditLimit": 15000
}
```

**Personal balance of key holder**

```json
{
  "orgId": null,
  "userId": "0123456789abcdef01234567",
  "object": "balance",
  "balance": 120.5,
  "creditLimit": 0
}
```

<a id="tab-panel-0-1"></a>
**401 Unauthorized**

An example for a request without a key or with an unknown key.

```json
{
  "error": {
    "message": "Unauthorized",
    "type": "unauthorized_request_error",
    "param": null,
    "code": null
  }
}
```
