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

# Get Customer Balance

> Gets a specific customer's balance for a credit entitlement



## OpenAPI

````yaml get /credit-entitlements/{credit_entitlement_id}/balances/{customer_id}
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.102.0
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
paths:
  /credit-entitlements/{credit_entitlement_id}/balances/{customer_id}:
    get:
      tags:
        - Credit Entitlement Balances
      summary: Gets a specific customer's balance for a credit entitlement.
      description: >-
        Returns the credit balance details for a specific customer and credit
        entitlement.


        # Authentication

        Requires an API key with `Viewer` role or higher.


        # Path Parameters

        - `credit_entitlement_id` - The unique identifier of the credit
        entitlement

        - `customer_id` - The unique identifier of the customer


        # Responses

        - `200 OK` - Returns the customer's balance

        - `404 Not Found` - Credit entitlement or customer balance not found

        - `500 Internal Server Error` - Database or server error
      operationId: get_customer_balance_handler
      parameters:
        - name: credit_entitlement_id
          in: path
          description: Credit Entitlement ID
          required: true
          schema:
            type: string
        - name: customer_id
          in: path
          description: Customer ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Customer balance details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerCreditBalanceResponse'
        '404':
          description: Credit entitlement or balance not found
        '500':
          description: Something went wrong :(
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


            const client = new DodoPayments({
              bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
            });


            const customerCreditBalance = await
            client.creditEntitlements.balances.retrieve('customer_id', {
              credit_entitlement_id: 'credit_entitlement_id',
            });


            console.log(customerCreditBalance.id);
        - lang: Python
          source: >-
            import os

            from dodopayments import DodoPayments


            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )

            customer_credit_balance =
            client.credit_entitlements.balances.retrieve(
                customer_id="customer_id",
                credit_entitlement_id="credit_entitlement_id",
            )

            print(customer_credit_balance.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tcustomerCreditBalance, err := client.CreditEntitlements.Balances.Get(\n\t\tcontext.TODO(),\n\t\t\"credit_entitlement_id\",\n\t\t\"customer_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", customerCreditBalance.ID)\n}\n"
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import
            com.dodopayments.api.models.creditentitlements.balances.BalanceRetrieveParams;

            import
            com.dodopayments.api.models.creditentitlements.balances.CustomerCreditBalance;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    BalanceRetrieveParams params = BalanceRetrieveParams.builder()
                        .creditEntitlementId("credit_entitlement_id")
                        .customerId("customer_id")
                        .build();
                    CustomerCreditBalance customerCreditBalance = client.creditEntitlements().balances().retrieve(params);
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import
            com.dodopayments.api.models.creditentitlements.balances.BalanceRetrieveParams

            import
            com.dodopayments.api.models.creditentitlements.balances.CustomerCreditBalance


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: BalanceRetrieveParams = BalanceRetrieveParams.builder()
                    .creditEntitlementId("credit_entitlement_id")
                    .customerId("customer_id")
                    .build()
                val customerCreditBalance: CustomerCreditBalance = client.creditEntitlements().balances().retrieve(params)
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )


            customer_credit_balance =
            dodo_payments.credit_entitlements.balances.retrieve(
              "customer_id",
              credit_entitlement_id: "credit_entitlement_id"
            )


            puts(customer_credit_balance)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Core\Exceptions\APIException;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $customerCreditBalance = $client->creditEntitlements->balances->retrieve(
                'customer_id', creditEntitlementID: 'credit_entitlement_id'
              );

              var_dump($customerCreditBalance);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using DodoPayments.Client;

            using DodoPayments.Client.Models.CreditEntitlements.Balances;


            DodoPaymentsClient client = new();


            BalanceRetrieveParams parameters = new()

            {
                CreditEntitlementID = "credit_entitlement_id",
                CustomerID = "customer_id",
            };


            var customerCreditBalance = await
            client.CreditEntitlements.Balances.Retrieve(parameters);


            Console.WriteLine(customerCreditBalance);
components:
  schemas:
    CustomerCreditBalanceResponse:
      type: object
      description: Response for a customer's credit balance
      required:
        - id
        - customer_id
        - credit_entitlement_id
        - balance
        - overage
        - created_at
        - updated_at
      properties:
        balance:
          type: string
        created_at:
          type: string
          format: date-time
        credit_entitlement_id:
          type: string
        customer_id:
          type: string
        id:
          type: string
        last_transaction_at:
          type:
            - string
            - 'null'
          format: date-time
        overage:
          type: string
        updated_at:
          type: string
          format: date-time
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````