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

# Check a customer's available credits

> Check available credits for one customer and feature without consuming any.

Reads the current balance for a customer and active feature without consuming credits. Send the stable `customerId` and `featureId`. The response includes `allowed`, `availableCredits`, and that feature's `creditCost`; an insufficient balance returns `200` with `allowed: false`.

A check does not reserve credits. Other usage may occur before you record this action, so [Record usage](https://docs.integrateledger.com/api-reference/usage/track.md) makes a fresh decision and may return `409 insufficient_credits` even after `allowed: true`. Call from your backend before performing the feature, then track only a successful action.

An unknown customer or archived/unknown feature returns `404 customer_not_found` or `404 feature_not_found`. See [Credits and usage](https://docs.integrateledger.com/credits.md) for balance order and concurrency behavior.


## OpenAPI

````yaml openapi.json POST /v1/check
openapi: 3.1.0
info:
  title: Ledger API
  version: 0.1.0
servers:
  - url: https://api.integrateledger.com
    description: Hosted Ledger API
security: []
paths:
  /v1/check:
    post:
      tags:
        - Usage
      summary: Check a customer's available credits
      operationId: checkCredits
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckInput'
      responses:
        '200':
          description: Current credit availability
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckResponse'
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckError'
        '401':
          description: Invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckError'
        '404':
          description: Customer or feature not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl --request POST 'https://api.integrateledger.com/v1/check' \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"customerId":"user_123","featureId":"api_call"}'
        - lang: python
          label: Python SDK (source only)
          source: |-
            import os
            from ledger_sdk import Ledger

            ledger = Ledger(api_key=os.environ["LEDGER_API_KEY"])
            ledger.check_credits(customer_id="user_123", feature_id="api_call")
        - lang: typescript
          label: TypeScript SDK (source only)
          source: >-
            import { Ledger } from "@ledger/sdk";


            const ledger = new Ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await ledger.checkCredits({ customerId: "user_123", featureId:
            "api_call" });
components:
  schemas:
    CheckInput:
      type: object
      properties:
        customerId:
          type: string
          minLength: 1
          maxLength: 255
        featureId:
          type: string
          minLength: 1
          maxLength: 100
      required:
        - customerId
        - featureId
      additionalProperties: false
    CheckResponse:
      type: object
      properties:
        allowed:
          type: boolean
        availableCredits:
          type: integer
          minimum: 0
        creditCost:
          type: integer
          exclusiveMinimum: 0
      required:
        - allowed
        - availableCredits
        - creditCost
    CheckError:
      type: object
      properties:
        error:
          type: string
      required:
        - error
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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