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

# Credit Ledger

Retrieves the credit transaction ledger for a customer, showing all credits and debits.

## Query

<CodeGroup>
  ```graphql Query theme={null}
  query GetCreditLedger($input: CreditLedgerInput!) {
    creditsLedger(input: $input) {
      edges {
        node {
          id
          amount
          type
          description
          createdAt
          balanceAfter
        }
        cursor
      }
      pageInfo {
        hasNextPage
        endCursor
      }
      totalCount
    }
  }
  ```

  ```json Variables theme={null}
  {
    "input": {
      "customerId": "customer-123",
      "paging": {
        "first": 50
      }
    }
  }
  ```

  ```json Response theme={null}
  {
    "data": {
      "creditsLedger": {
        "edges": [
          {
            "node": {
              "id": "ledger-001",
              "amount": 1000,
              "type": "CREDIT",
              "description": "Initial credit grant",
              "createdAt": "2024-01-01T00:00:00Z",
              "balanceAfter": 1000
            },
            "cursor": "abc123"
          },
          {
            "node": {
              "id": "ledger-002",
              "amount": -50,
              "type": "DEBIT",
              "description": "API usage: 50 calls",
              "createdAt": "2024-01-15T10:30:00Z",
              "balanceAfter": 950
            },
            "cursor": "def456"
          }
        ],
        "pageInfo": {
          "hasNextPage": true,
          "endCursor": "def456"
        },
        "totalCount": 125
      }
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="input" type="CreditLedgerInput" required>
  Input parameters for credit ledger query

  <Expandable title="properties">
    <ParamField body="customerId" type="String" required>
      The customer's reference ID
    </ParamField>

    <ParamField body="resourceId" type="String">
      Resource ID for multi-resource customers
    </ParamField>

    <ParamField body="paging" type="CursorPaging">
      Pagination options
    </ParamField>

    <ParamField body="environmentId" type="UUID">
      Environment ID
    </ParamField>
  </Expandable>
</ParamField>

## Return Type

Returns a `CreditLedgerConnection` with ledger entries.

## Ledger Entry Fields

| Field          | Type     | Description               |
| -------------- | -------- | ------------------------- |
| `id`           | UUID     | Entry ID                  |
| `amount`       | Float    | Transaction amount (+/-)  |
| `type`         | String   | CREDIT or DEBIT           |
| `description`  | String   | Transaction description   |
| `createdAt`    | DateTime | Transaction time          |
| `balanceAfter` | Float    | Balance after transaction |

## Overdraft settlement event types

The credit ledger includes the following event types related to overdraft settlement:

| Event Type                            | Description                                                                                                                                            |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CREDITS_CONSUMPTION_TRANSFER_SOURCE` | Recorded on the overdraft grant when consumed credits are transferred out during settlement. Shows a negative quantity (reduction in consumed amount). |
| `CREDITS_CONSUMPTION_TRANSFER_TARGET` | Recorded on the new grant when consumed credits are transferred in during settlement. Shows a positive quantity (increase in consumed amount).         |

These events always appear in pairs — one on the source (overdraft) grant and one on the target (new) grant — with matching quantities.

## Common Use Cases

<AccordionGroup>
  <Accordion title="Transaction history">
    Show detailed credit transaction history to customers.
  </Accordion>

  <Accordion title="Audit trail">
    Maintain audit trail of all credit movements.
  </Accordion>

  <Accordion title="Usage analysis">
    Analyze credit consumption patterns.
  </Accordion>
</AccordionGroup>

## Related Operations

* [Credit Balance](/api-and-sdks/api-reference/queries/credit-balance) - Current balance
* [Credit Grants](/api-and-sdks/api-reference/queries/credit-grants) - List grants
