> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Получение баланса кредитов через API: биллинг KYC

> Получите баланс кредитов Didit и настройки автопополнения. Один баланс оплачивает все продукты: кредиты тарифа и пополнения.



Промпт для получения баланса кредитов
        Скопировать промпт в буфер обмена



      
      

\<pre>

\`Goal: Read the organization's current pre-paid credit balance (USD) plus its auto-refill configuration.

Endpoint: GET https://verification.didit.me/v3/billing/balance/
Auth header: x-api-key: <DIDIT_API_KEY>

curl:
curl -X GET 'https://verification.didit.me/v3/billing/balance/' \
-H 'x-api-key: YOUR_API_KEY'

Response 200:
\{
"balance": "1234.5600",                  // USD, FIXED-POINT DECIMAL STRING — parse with Decimal/BigDecimal, not float.
"auto_refill_enabled": true,             // boolean
"auto_refill_amount": "500.00",          // USD string or null
"auto_refill_threshold": "100.00"        // USD string or null — auto-refill fires when balance falls below this
}

Notes:
\- Balance is ORGANIZATION-WIDE — shared across every application under the same org.
\- Decreases as verifications are billed; increases when a top-up settles via Stripe webhook.
\- Currency is always USD.
\- Configure auto-refill in Console → Billing; requires a saved Stripe payment method (card, SEPA, or US ACH). The auto-refill amount is $50 to $20,000, added at face value, the same range as a manual top-up.
\- Poll at a low cadence (every few minutes max) — balance only changes when usage is billed or a top-up settles.

Common patterns:
\- Gate session creation in production — stop opening new sessions if balance drops below your operational floor.
\- Power internal dashboards / low-balance alerts.
\- Detect misconfigured auto-refill: auto_refill_enabled=true with null auto_refill_amount/threshold means it's effectively off (or no eligible payment method on file).

Failure modes (envelope {"detail": "..."}):
\- 401 — missing/malformed x-api-key.
\- 403 — key valid but bound application not allowed to read billing.
\- 429 — rate-limited.

See /getting-started/pricing for the credit consumption model and POST /v3/billing/top-up/ to add funds programmatically.

For end-to-end Didit integration, paste in the full prompt at /integration/integration-prompt.`

\</pre>



      
      

Вставьте в



## OpenAPI

````yaml ru/openapi-25.json GET /v3/billing/balance/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: >-
    API верификации личности. Аутентификация выполняется с помощью заголовка
    x-api-key.
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/billing/balance/:
    get:
      tags:
        - Billing
      summary: Получить кредитный баланс
      description: >-
        Получить текущий баланс предоплаченных кредитов в USD (на уровне
        организации), а также конфигурацию автопополнения. Суммы указаны в виде
        десятичных строк — разбирайте их с помощью библиотеки для работы с
        десятичными числами.
      operationId: get_billing_balance
      responses:
        '200':
          description: Текущий кредитный баланс и конфигурация автопополнения организации.
          content:
            application/json:
              schema:
                type: object
                required:
                  - balance
                  - auto_refill_enabled
                properties:
                  balance:
                    type: string
                    description: >-
                      Текущий баланс предоплаченных кредитов в USD в виде строки
                      с десятичным числом в формате с фиксированной точкой.
                      Уменьшается по мере списания средств за верификации и
                      увеличивается после проведения пополнения баланса.
                  auto_refill_enabled:
                    type: boolean
                    description: >-
                      Когда `true`, Didit автоматически списывает средства с
                      сохраненного способа оплаты для добавления кредитов, как
                      только баланс пересекает `auto_refill_threshold`.
                      Настраивается в разделе Console → Billing.
                  auto_refill_amount:
                    type: string
                    nullable: true
                    description: >-
                      Сумма в USD, которая будет списана и зачислена на баланс
                      при каждом автопополнении по номиналу. Настраивается от
                      \$50 до \$20,000 в разделе Консоль → Биллинг. `null`, если
                      автопополнение отключено или не настроено.
                  auto_refill_threshold:
                    type: string
                    nullable: true
                    description: >-
                      Порог срабатывания в USD. Автопополнение срабатывает,
                      когда `balance` опускается ниже этого значения. `null`,
                      если автопополнение отключено или не настроено.
              examples:
                Healthy balance with auto-refill:
                  value:
                    balance: '1234.5600'
                    auto_refill_enabled: true
                    auto_refill_amount: '500.00'
                    auto_refill_threshold: '100.00'
                Low balance, manual top-up only:
                  value:
                    balance: '12.0000'
                    auto_refill_enabled: false
                    auto_refill_amount: null
                    auto_refill_threshold: null
        '403':
          description: >-
            Отсутствующий, недействительный или отозванный API-ключ, либо у
            ключа нет прав на чтение данных биллинга для этой организации. При
            отсутствии ключа возвращается `403`; при неверном, отозванном или
            истекшем ключе возвращается `401`.
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    detail: You do not have permission to perform this action.
        '429':
          description: >-
            Лимит запросов превышен; снизьте частоту запросов и повторите
            попытку через интервал, указанный в `Retry-After`.
          content:
            application/json:
              examples:
                Throttled:
                  value:
                    detail: Request was throttled. Expected available in 30 seconds.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X GET 'https://verification.didit.me/v3/billing/balance/' \
              -H 'x-api-key: YOUR_API_KEY'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.billing.retrieve_balance()
            print(result)
        - lang: javascript
          label: Node.js
          source: |-
            import Didit from "@didit-protocol/sdk-node";

            // Reads DIDIT_API_KEY.
            const didit = new Didit();

            const result = await didit.billing.retrieveBalance();
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Billing.RetrieveBalance(ctx)\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: |-
            import me.didit.Didit;

            // Reads DIDIT_API_KEY.
            Didit client = new Didit();

            var result = client.billing().retrieveBalance();
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;

            // Reads DIDIT_API_KEY.
            $didit = new DiditClient();

            $result = $didit->billing->retrieveBalance();
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # Reads DIDIT_API_KEY.
            didit = Didit::Client.new

            result = didit.billing.retrieve_balance
            puts result.to_h
        - lang: csharp
          label: .NET
          source: |-
            using System;
            using System.Text.Json;
            using Didit;

            // Reads DIDIT_API_KEY.
            using var client = new DiditClient();

            var result = await client.Billing.RetrieveBalanceAsync();
            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API-ключ вашего приложения из раздела «Разработчикам» -> «API-ключи» в
        Business Console. Основной ключ имеет полный доступ. Именованный ключ
        может иметь ограниченную область действия: без доступа, чтение или
        запись для каждого ресурса, ограничение определенными сценариями или
        одобренными сессиями, списком IP-адресов и сроком действия. 401
        означает, что ключ неверен, отозван или его срок действия истек; 403
        означает, что ключ не был передан, у ключа нет доступа к этому ресурсу
        или действию, либо запрос поступил с адреса вне его списка IP-адресов;
        404 на маршруте сессии означает, что сессия не входит в сценарии или
        статусы ключа. Ключ без доступа к медиа получает URL изображений, видео
        и PDF как null, а ключ без прав на запись сессий получает ссылки на
        сессии и токены как null. См. https://docs.didit.me/console/api-keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.