> ## 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.

# Get Credit Balance

> Get current pre-paid credit balance in USD (organization-wide) plus auto-refill config. Amounts are decimal strings — parse with a decimal library.

export const AgentPromptAccordion = ({prompt, title = "AI Agent Integration Prompt"}) => {
  const [copied, setCopied] = React.useState(false);
  const handleCopy = e => {
    e.stopPropagation();
    if (!prompt) return;
    navigator.clipboard.writeText(prompt.trim()).then(() => {
      setCopied(true);
      setTimeout(() => setCopied(false), 2000);
    });
  };
  const agents = ["Claude Code", "Codex", "Cursor", "Devin", "Windsurf", "GitHub Copilot"];
  return <div className="didit-agent-card">
      {}
      <div className="didit-agent-titlebar">
        <div className="didit-agent-dots" aria-hidden="true">
          <span className="didit-agent-dot didit-agent-dot-red"></span>
          <span className="didit-agent-dot didit-agent-dot-yellow"></span>
          <span className="didit-agent-dot didit-agent-dot-green"></span>
        </div>
        <span className="didit-agent-filename">{title}</span>
        <button type="button" className={`didit-agent-copy ${copied ? "didit-agent-copy-copied" : ""}`} onClick={handleCopy} title="Copy prompt to clipboard" aria-label={copied ? "Copied!" : "Copy prompt to clipboard"}>
          {copied ? <>
              <svg width="13" height="13" viewBox="0 0 16 16" fill="none">
                <path d="M3 8.5l3.5 3.5L13 4" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
              </svg>
              <span>Copied</span>
            </> : <>
              <svg width="13" height="13" viewBox="0 0 16 16" fill="none">
                <rect x="5" y="5" width="9" height="9" rx="1.5" stroke="currentColor" strokeWidth="1.5" />
                <path d="M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5" stroke="currentColor" strokeWidth="1.5" />
              </svg>
              <span>Copy</span>
            </>}
        </button>
      </div>

      {}
      <pre className="didit-agent-body"><code>{prompt.trim()}</code></pre>

      {}
      <div className="didit-agent-footer">
        <span className="didit-agent-footer-label">Paste into</span>
        <div className="didit-agent-chips">
          {agents.map(name => <span key={name} className="didit-agent-chip">{name}</span>)}
        </div>
      </div>
    </div>;
};

<AgentPromptAccordion
  title="Get Credit Balance Prompt"
  prompt={`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).
- 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.`}
/>


## OpenAPI

````yaml GET /v3/billing/balance/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: Identity verification API. Authenticate with x-api-key header.
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/billing/balance/:
    get:
      tags:
        - Billing
      summary: Get credit balance
      description: >-
        Get current pre-paid credit balance in USD (organization-wide) plus
        auto-refill config. Amounts are decimal strings — parse with a decimal
        library.
      operationId: get_billing_balance
      responses:
        '200':
          description: >-
            Current credit balance plus the organization's auto-refill
            configuration.
          content:
            application/json:
              schema:
                type: object
                required:
                  - balance
                  - auto_refill_enabled
                properties:
                  balance:
                    type: string
                    description: >-
                      Current pre-paid credit balance in USD, as a fixed-point
                      decimal string. Decreases as verifications are billed and
                      increases when a top-up settles.
                  auto_refill_enabled:
                    type: boolean
                    description: >-
                      When `true`, Didit will automatically charge the saved
                      Stripe payment method to add credits once the balance
                      crosses `auto_refill_threshold`. Configured from Console →
                      Billing.
                  auto_refill_amount:
                    type: string
                    nullable: true
                    description: >-
                      USD amount that will be charged on each auto-refill.
                      `null` when auto-refill is disabled or unset.
                  auto_refill_threshold:
                    type: string
                    nullable: true
                    description: >-
                      Trigger threshold in USD. Auto-refill fires when `balance`
                      falls below this value. `null` when auto-refill is
                      disabled or unset.
              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: >-
            Missing, invalid, or revoked API key, or the key cannot read billing
            data for this organization. This endpoint returns `403` (never
            `401`) for authentication failures, including requests with no
            credentials at all.
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    detail: You do not have permission to perform this action.
        '429':
          description: >-
            Rate limit exceeded; back off and retry after the interval indicated
            in `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: |-
            import os
            from decimal import Decimal

            import requests

            resp = requests.get(
                'https://verification.didit.me/v3/billing/balance/',
                headers={'x-api-key': os.environ['DIDIT_API_KEY']},
                timeout=10,
            )
            resp.raise_for_status()
            data = resp.json()
            balance = Decimal(data['balance'])
            if balance < Decimal('50'):
                print(f'Low balance: ${balance} - top up before launching new sessions.')
            else:
                print(f'Balance OK: ${balance}')
        - lang: javascript
          label: JavaScript
          source: >-
            const resp = await
            fetch('https://verification.didit.me/v3/billing/balance/', {
              headers: { 'x-api-key': process.env.DIDIT_API_KEY },
            });

            if (!resp.ok) throw new Error(`Billing balance failed:
            ${resp.status}`);

            const { balance, auto_refill_enabled, auto_refill_threshold } =
            await resp.json();

            console.log({ balance, auto_refill_enabled, auto_refill_threshold
            });
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````