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

# Retrieve Credit Usage

> Retrieve the credit usage for a subscription.



## OpenAPI

````yaml get /subscriptions/{subscription_id}/credit-usage
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:
  /subscriptions/{subscription_id}/credit-usage:
    get:
      tags:
        - Subscriptions
      operationId: get_subscription_credit_usage_handler
      parameters:
        - name: subscription_id
          in: path
          description: Subscription ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionCreditUsageResponse'
      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 response = await
            client.subscriptions.retrieveCreditUsage('subscription_id');


            console.log(response.subscription_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
            )
            response = client.subscriptions.retrieve_credit_usage(
                "subscription_id",
            )
            print(response.subscription_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\tresponse, err := client.Subscriptions.GetCreditUsage(context.TODO(), \"subscription_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.SubscriptionID)\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.subscriptions.SubscriptionRetrieveCreditUsageParams;

            import
            com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse;


            public final class Main {
                private Main() {}

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

                    SubscriptionRetrieveCreditUsageResponse response = client.subscriptions().retrieveCreditUsage("subscription_id");
                }
            }
        - 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.subscriptions.SubscriptionRetrieveCreditUsageParams

            import
            com.dodopayments.api.models.subscriptions.SubscriptionRetrieveCreditUsageResponse


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

                val response: SubscriptionRetrieveCreditUsageResponse = client.subscriptions().retrieveCreditUsage("subscription_id")
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


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


            response =
            dodo_payments.subscriptions.retrieve_credit_usage("subscription_id")


            puts(response)
        - 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 {
              $response = $client->subscriptions->retrieveCreditUsage('subscription_id');

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

            using DodoPayments.Client;

            using DodoPayments.Client.Models.Subscriptions;


            DodoPaymentsClient client = new();


            SubscriptionRetrieveCreditUsageParams parameters = new()

            {
                SubscriptionID = "subscription_id"
            };


            var response = await
            client.Subscriptions.RetrieveCreditUsage(parameters);


            Console.WriteLine(response);
components:
  schemas:
    SubscriptionCreditUsageResponse:
      type: object
      description: Credit usage status for all entitlements linked to a subscription
      required:
        - subscription_id
        - items
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/CreditEntitlementUsageStatus'
        subscription_id:
          type: string
    CreditEntitlementUsageStatus:
      type: object
      description: Per-entitlement credit usage status for a subscription
      required:
        - credit_entitlement_id
        - credit_entitlement_name
        - unit
        - balance
        - overage_enabled
        - overage
        - limit_reached
      properties:
        balance:
          type: string
          description: >-
            Customer's current credit balance for this entitlement
            (customer-wide)
          example: '250.00'
        credit_entitlement_id:
          type: string
        credit_entitlement_name:
          type: string
        limit_reached:
          type: boolean
          description: |-
            True if overage has reached or exceeded the limit.
            When true, further deductions that would increase overage will fail.
        overage:
          type: string
          description: Current overage amount accrued (customer-wide)
          example: '15.50'
        overage_enabled:
          type: boolean
          description: Whether overage is enabled for this entitlement on this subscription
        overage_limit:
          type:
            - string
            - 'null'
          description: |-
            Maximum allowed overage before deductions are blocked.
            None means unlimited overage (when overage_enabled is true).
          example: '100.00'
        remaining_headroom:
          type:
            - string
            - 'null'
          description: >-
            How much more overage can accumulate before being blocked.

            None if overage is not enabled or there is no limit (unlimited).

            A value of 0 means the next deduction that increases overage will be
            blocked.
          example: '84.50'
        unit:
          type: string
          description: Unit label for the credit entitlement (e.g. "API Calls", "Tokens")
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````