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

# List Customer Grants

> Lists credit grants for a customer under a specific credit entitlement



## OpenAPI

````yaml get /credit-entitlements/{credit_entitlement_id}/balances/{customer_id}/grants
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}/grants:
    get:
      tags:
        - Credit Entitlement Balances
      summary: Lists credit grants for a customer under a specific credit entitlement.
      description: >-
        Returns a paginated list of credit grants with optional filtering by
        status.


        # 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


        # Query Parameters

        - `page_size` - Number of items per page (default: 10, max: 100)

        - `page_number` - Zero-based page number (default: 0)

        - `status` - Filter by status: active, expired, depleted


        # Responses

        - `200 OK` - Returns list of grants

        - `404 Not Found` - Credit entitlement not found

        - `500 Internal Server Error` - Database or server error
      operationId: list_customer_grants_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
        - name: page_size
          in: query
          description: Page size default is 10 max is 100
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
          style: form
        - name: page_number
          in: query
          description: Page number default is 0
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
          style: form
        - name: status
          in: query
          description: 'Filter by grant status: active, expired, depleted'
          required: false
          schema:
            $ref: '#/components/schemas/GrantStatusFilter'
          style: form
      responses:
        '200':
          description: List of customer grants
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListGrantsResponse'
        '404':
          description: Credit entitlement 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
            });


            // Automatically fetches more pages as needed.

            for await (const balanceListGrantsResponse of
            client.creditEntitlements.balances.listGrants(
              'customer_id',
              { credit_entitlement_id: 'credit_entitlement_id' },
            )) {
              console.log(balanceListGrantsResponse.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
            )
            page = client.credit_entitlements.balances.list_grants(
                customer_id="customer_id",
                credit_entitlement_id="credit_entitlement_id",
            )
            page = page.items[0]
            print(page.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\tpage, err := client.CreditEntitlements.Balances.ListGrants(\n\t\tcontext.TODO(),\n\t\t\"credit_entitlement_id\",\n\t\t\"customer_id\",\n\t\tdodopayments.CreditEntitlementBalanceListGrantsParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\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.BalanceListGrantsPage;

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


            public final class Main {
                private Main() {}

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

                    BalanceListGrantsParams params = BalanceListGrantsParams.builder()
                        .creditEntitlementId("credit_entitlement_id")
                        .customerId("customer_id")
                        .build();
                    BalanceListGrantsPage page = client.creditEntitlements().balances().listGrants(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.BalanceListGrantsPage

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


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

                val params: BalanceListGrantsParams = BalanceListGrantsParams.builder()
                    .creditEntitlementId("credit_entitlement_id")
                    .customerId("customer_id")
                    .build()
                val page: BalanceListGrantsPage = client.creditEntitlements().balances().listGrants(params)
            }
        - lang: Ruby
          source: |-
            require "dodopayments"

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

            page = dodo_payments.credit_entitlements.balances.list_grants(
              "customer_id",
              credit_entitlement_id: "credit_entitlement_id"
            )

            puts(page)
        - 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 {
              $page = $client->creditEntitlements->balances->listGrants(
                'customer_id',
                creditEntitlementID: 'credit_entitlement_id',
                pageNumber: 0,
                pageSize: 0,
                status: 'active',
              );

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

            using DodoPayments.Client;

            using DodoPayments.Client.Models.CreditEntitlements.Balances;


            DodoPaymentsClient client = new();


            BalanceListGrantsParams parameters = new()

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


            var page = await
            client.CreditEntitlements.Balances.ListGrants(parameters);

            await foreach (var item in page.Paginate())

            {
                Console.WriteLine(item);
            }
components:
  schemas:
    GrantStatusFilter:
      type: string
      enum:
        - active
        - expired
        - depleted
    ListGrantsResponse:
      type: object
      required:
        - items
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/CreditGrantResponse'
    CreditGrantResponse:
      type: object
      description: Response for a credit grant
      required:
        - id
        - credit_entitlement_id
        - customer_id
        - source_type
        - initial_amount
        - remaining_amount
        - rollover_count
        - is_expired
        - is_rolled_over
        - created_at
        - updated_at
      properties:
        created_at:
          type: string
          format: date-time
        credit_entitlement_id:
          type: string
        customer_id:
          type: string
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        id:
          type: string
        initial_amount:
          type: string
        is_expired:
          type: boolean
        is_rolled_over:
          type: boolean
        metadata:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Metadata'
        parent_grant_id:
          type:
            - string
            - 'null'
        remaining_amount:
          type: string
        rollover_count:
          type: integer
          format: int32
        source_id:
          type:
            - string
            - 'null'
        source_type:
          $ref: '#/components/schemas/CbbGrantSourceType'
        updated_at:
          type: string
          format: date-time
    Metadata:
      type: object
      additionalProperties:
        type: string
      propertyNames:
        type: string
    CbbGrantSourceType:
      type: string
      enum:
        - subscription
        - one_time
        - addon
        - api
        - rollover
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````