Skip to content

Read a client balance

POSThttps://gptunnel.ru/api/v1/balance/get

Returns the current balance of a client account. Identify the account using exactly one of the following fields.

  • user_id selects a user’s personal account.
  • org_id selects an organization’s account.
  • user_data.phone selects a user’s personal account by phone number in the format +79XXXXXXXXX. Phone lookup must be enabled for the partner.

This read-only operation does not require an Idempotency-Key header.

Request headers

ParameterTypeDescription
Authorization*stringOrganization API key
Content-Type*stringapplication/json

Request parameters

ParameterTypeDescription
user_idstringClient user ID, 24 lowercase hexadecimal characters. Provide exactly one of user_id, org_id, and user_data.
org_idstringClient organization ID, 24 lowercase hexadecimal characters. Provide exactly one of user_id, org_id, and user_data.
user_dataobjectLook up a user by phone: {"phone":"+79XXXXXXXXX"}. This feature requires separate activation.

Set GPTUNNEL_API_KEY and replace the placeholders with values for your organization.

import json
import os
from urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")
if not key:
raise SystemExit("Set GPTUNNEL_API_KEY")
body = {
"user_id": "6ad72133269dc8d9f75a33bc"
}
request = Request(
"https://gptunnel.ru/api/v1/balance/get",
method="POST",
headers={
"Authorization": key,
"Content-Type": "application/json",
},
data=json.dumps(body).encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))

Response fields

ParameterTypeDescription
codenumber0 on success
typestringAccount type: user for a personal account, org for an organization account.
idstringID of the user or organization whose balance is returned.
balancenumberBalance in rubles. It can be negative.
bonusnumberUser’s bonus points. One point is worth 0.5 RUB. Always zero for organizations.
credit_limitnumberOnly for the organization: credit limit in rubles, 0 if not assigned
innstring | nullFor organizations only: Russian taxpayer identification number (INN)
ogrnstring | nullFor organizations only: Russian primary state registration number (OGRN)
spend_blockedbooleantrue if spending is blocked on the account. Use balance/setSpendBlocked to change this setting.
currencystringAlways RUB
{
"code": 0,
"type": "user",
"id": "6ad72133269dc8d9f75a33bc",
"balance": 412.5,
"bonus": 0,
"spend_blocked": false,
"currency": "RUB"
}
HTTP code When
400 3 The request must identify exactly one client and may contain only supported fields. An ID must contain exactly 24 characters from 0-9a-f. See details.
403 13 The key belongs to a personal account rather than an organization
403 27 Phone lookup with user_data is disabled for the organization.
403 34 This endpoint is not enabled for the organization that owns the key.
404 17 User not found, deleted or not a customer of partner
404 24 Organization not found, deleted or not a customer of partner

The API checks the key’s permissions before validating the request body. A key without access receives HTTP 403 even if the body is invalid.

See the Business API error reference for all error codes, including the 401 response for an invalid key.