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

# List customer purchases

> Read a customer's credit-pack purchase history in the API key's environment.

Pass the exact opaque `customerId` as a URL-encoded query value. Results are ordered newest first and can be paged with `limit` and `nextCursor`. Each item shows the add-on ID, name, confirmed credit amount, status, and creation time. A `pending_checkout` purchase has not granted credits, so `creditAmount` is `null`. Once Checkout grants credits, `creditAmount` shows the immutable amount actually granted. It is also `null` for any legacy paid row with no linked grant. Multiple purchases of the same pack appear as separate items.

The API key scopes the result to its organization and Sandbox or Live environment. Use [Get a customer](https://docs.integrateledger.com/api-reference/customers/get.md) for the current balance, which can also include plan credits. Stripe invoice and Checkout payment documents are available from the dashboard's customer billing panels when the connected Stripe account can verify them.


## OpenAPI

````yaml openapi.json GET /v1/customers/purchases
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/customers/purchases:
    get:
      tags:
        - Customers
      summary: List a customer's credit-pack purchases
      operationId: listCustomerPurchases
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
          required: true
          name: customerId
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
          required: false
          name: limit
          in: query
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 2147483647
          required: false
          name: cursor
          in: query
      responses:
        '200':
          description: Customer credit-pack purchases, newest first
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerPurchasePage'
        '400':
          description: Invalid query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '401':
          description: Missing or invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '404':
          description: Customer not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl --request GET
            'https://api.integrateledger.com/v1/customers/purchases?customerId=user_123'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY"
        - 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.list_customer_purchases(customer_id="user_123")
        - 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.listCustomerPurchases({ customerId: "user_123" });
components:
  schemas:
    CustomerPurchasePage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/CustomerPurchaseItem'
        hasMore:
          type: boolean
        nextCursor:
          type: integer
          nullable: true
      required:
        - items
        - hasMore
        - nextCursor
    CustomerError:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    CustomerPurchaseItem:
      type: object
      properties:
        id:
          type: integer
        addOnId:
          type: string
        name:
          type: string
        creditAmount:
          type: integer
          nullable: true
        status:
          type: string
        createdAt:
          type: string
          format: date-time
      required:
        - id
        - addOnId
        - name
        - creditAmount
        - status
        - createdAt
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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