> ## 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のクレジット残高と自動チャージ設定を取得します。プランのクレジットとチャージ分を合わせた1つの残高で、すべてのプロダクトの利用料を支払えます。



クレジット残高取得プロンプト
        プロンプトをクリップボードにコピー



      
      

\<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 $10,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 ja/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建ての現在の前払いクレジット残高（組織全体）と自動チャージの設定を取得します。金額は10進数の文字列のため、decimalライブラリで解析してください。
      operationId: get_billing_balance
      responses:
        '200':
          description: 現在のクレジット残高と、組織の自動チャージ設定。
          content:
            application/json:
              schema:
                type: object
                required:
                  - balance
                  - auto_refill_enabled
                properties:
                  balance:
                    type: string
                    description: >-
                      現在のプリペイドクレジット残高（USD、固定小数点の10進数文字列）。認証が請求されるにつれて減少し、チャージが確定すると増加します。
                  auto_refill_enabled:
                    type: boolean
                    description: >-
                      `true`の場合、残高が`auto_refill_threshold`を下回ると、Diditは保存済みの支払い方法に自動で請求してクレジットを追加します。Console
                      → 請求から設定します。
                  auto_refill_amount:
                    type: string
                    nullable: true
                    description: >-
                      自動チャージのたびに請求され、額面どおり残高に追加されるUSD金額。Console →
                      Billingで\$50から\$10,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キーです。Business ConsoleのDevelopers -> API
        keysで取得できます。プライマリキーはフルアクセス権を持ちます。名前付きキーにはスコープを設定できます。リソースごとのアクセス権（なし、読み取り、書き込み）、一部のワークフローまたは承認済みセッションへの限定、IPアドレスのリストへの限定、有効期限の設定です。401は、キーが誤っている、失効している、または期限切れであることを意味します。403は、キーが送信されていない、キーにこのリソースやアクションへのアクセス権がない、またはIPリスト外のアドレスからリクエストが送信されたことを意味します。セッションのルートでの404は、セッションがキーのワークフローまたはステータスの対象外であることを意味します。メディアへのアクセス権がないキーでは、画像、動画、PDFのURLがnullで返されます。セッションの書き込み権限がないキーでは、セッションのリンクとトークンがnullで返されます。詳細は次を参照してください:
        https://docs.didit.me/console/api-keys

````

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