# Balances and organizations

Source: [Balances and organizations](<https://docs.gptunnel.ru/en/business/>)

<a id="_top"></a>
<a id="what-business-api-is"></a>
## What Business API Is

The Business API gives partners programmatic access to their organization’s balance. Agencies, distributors, and white-label platforms use it to buy GPTunneL services for their clients.

Partners can use the API to do the following.

- [Transfer funds](<https://docs.gptunnel.ru/en/business/transfer/>) from the organization’s balance to a user’s personal account or another organization’s account.
- [Create a client organization](<https://docs.gptunnel.ru/en/business/org-create/>) and assign its owner.

If your clients register on your own platform, you can also request access to the following endpoints. See [Partner clients](<https://docs.gptunnel.ru/en/business/#partner-clients>) for eligibility.

- [Check a client’s balance](<https://docs.gptunnel.ru/en/business/balance-get/>).
- [Get a spending report](<https://docs.gptunnel.ru/en/business/balance-spending/>) for a specified period.
- [Refund previously transferred funds](<https://docs.gptunnel.ru/en/business/balance-refund/>) to your organization’s balance.
- [Freeze or restore spending](<https://docs.gptunnel.ru/en/business/balance-spend-block/>) on a client account.
- [List the organizations a client owns](<https://docs.gptunnel.ru/en/business/orgs-list/>).

Funds reach the client’s account immediately. The client can see the transfer in their dashboard transaction history without having to confirm it.

> **Note: Organization API key**
>
> Send your organization’s API key in the `Authorization` header. An organization owner or administrator can create it in the **API** tab of the business profile. With a personal key, transfers return `403` with code `22`, and other methods return `403` with code `13`. See [Quick start](<https://docs.gptunnel.ru/en/>).

<a id="connectivity"></a>
## Connectivity

GPTunneL enables these APIs for each organization individually.

1. Your GPTunneL account manager enables balance transfers and, if needed, organization creation. Until organization creation is enabled, `orgs/create` returns HTTP `403` with code `32`.
2. The organization owner or an administrator enables **Transfers** in the API key settings. You can enable it for an existing key. The switch appears only after GPTunneL enables transfers for the organization in step 1. A transfer request made with **Transfers** disabled returns HTTP `403` with code `22`.
3. Fund the organization’s balance. Transfers are debited from that balance, taking any assigned credit limit into account.

> **Caution: Check key and organization permissions**
>
> The API checks the key before checking the organization. Code `22` means transfers are disabled on the key. If the switch is missing, ask your account manager to enable transfers for your organization. Code `16` means the key has transfers enabled but the organization cannot transfer funds. Its permission may have been disabled, it may have been removed, or it may be served by a distributor.

<a id="general-rules"></a>
## General rules

- Base URL: `https://gptunnel.ru/api/v1/`. All methods use `POST` with a JSON body over HTTPS.
- Operations that move funds require a unique `Idempotency-Key` per operation. Use 8–64 characters from `A-Za-z0-9_-`, or 8–60 for refunds. Retrying with the same key and body returns the original result with `replayed: true` and does not charge again. Reusing the key with a different body returns `409` with code `20`.
- User and organization IDs are 24 hexadecimal characters (`0-9a-f`). Users can use **Copy ID** in their dashboard, and organization IDs appear on the client card.
- Responses use JSON with `code: 0` on success or a [Business API error code](<https://docs.gptunnel.ru/en/business/errors/>) on failure. The HTTP status reflects the error class. A rejected API key uses a separate [HTTP 401 response format](<https://docs.gptunnel.ru/en/business/errors/#response-401>).

```json
{ "code": 0, "transaction_id": "order-2026-10-20-000153", "amount": 500 }
```

```json
{ "code": 19, "message": "Insufficient funds on the organization balance." }
```

The `Idempotency-Key` header is required for [transfers](<https://docs.gptunnel.ru/en/business/transfer/>), [refunds](<https://docs.gptunnel.ru/en/business/balance-refund/>) and [organization creation](<https://docs.gptunnel.ru/en/business/org-create/>). You can repeat balance, spending and organization-list requests without this header.

 <a id="limites"></a>
 
<a id="limits"></a>
## Limits

| Limitation | Meaning |
| --- | --- |
| Maximum transfer or refund with an explicit `amount` | 100 000 ₽ |
| Amount precision | 2 decimal places |
| `Idempotency-Key` length | 8–64 characters from `A-Za-z0-9_-` |
| `Idempotency-Key` length for refunds | 8–60 characters from `A-Za-z0-9_-` |
| Maximum spending report range | 92 days with daily grouping, 366 days with monthly grouping |
| Organization name length | 1–255 characters |

<a id="partner-clients"></a>
## Partner clients

A GPTunneL account manager can enable [`balance/get`](<https://docs.gptunnel.ru/en/business/balance-get/>), [`balance/spending`](<https://docs.gptunnel.ru/en/business/balance-spending/>), [`balance/refund`](<https://docs.gptunnel.ru/en/business/balance-refund/>), [`balance/setSpendBlocked`](<https://docs.gptunnel.ru/en/business/balance-spend-block/>), and [`orgs/list`](<https://docs.gptunnel.ru/en/business/orgs-list/>) for partners whose users register on the partner’s own domain. These endpoints cannot be enabled in the dashboard. If an endpoint is unavailable to the organization that owns the key, it returns HTTP `403` with the corresponding code (`34`, `40`, `35`, `47`, or `36`, respectively). Refunds check the Transfers permission on the key first. If it is disabled, the response is HTTP `403` with code `22`.

These methods only work with partner clients:

- **User.** The user registered on the partner’s platform. Use `user_id` to identify their personal account.
- **Organization.** The current owner must be a user registered on the partner’s platform. Use `org_id` to identify the organization. If its current owner is not your client, these endpoints cannot access it, even if you created it or transferred funds to it.

An account that belongs to another partner returns the same response as a nonexistent account: HTTP `404` with code `17` for a user or `24` for an organization.

Clients can find their `user_id` using **Copy ID** in their dashboard. To get the `org_id` of each organization a client owns, call [`orgs/list`](<https://docs.gptunnel.ru/en/business/orgs-list/>).

> **Note: Phone lookup**
>
> Partners who register client accounts by phone number can use `user_data: { "phone": "+79XXXXXXXXX" }` instead of `user_id`. If phone lookup is not enabled, the API returns HTTP `403` with code `27`. Use `user_id` instead.
