> ## 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 the usage log

> Read every tracked request, charged or refused, with filters.

Returns the requests `track` recorded for the key's environment, newest first: the dashboard's Usage page. Use it to answer "why was this customer blocked?" or to reconcile what was charged. Retries of a request ID that was already charged (`"idempotent": true`) aren't listed again.

* Filter by `customerId`, `status` (`success` for charged requests, `failed` for refused ones, `all` by default) and `month` (`YYYY-MM`, in UTC). `order=oldest` reverses the order.
* `outcome` is `charged`, `blocked` (out of credits or at the overage cap) or `failed` (any other refusal, such as an unknown feature). `reason` says why a request wasn't charged.
* `chargedCredits` is the feature's full cost; `overageCredits` is the part of it recorded as overage.
* `occurredAt` is the customer's time: with [Simulate time](https://docs.integrateledger.com/test/simulate-time.md) on, the simulated time. The log is ordered and filtered by it.
* Pages hold `limit` items (1–100, default 25). When `hasMore` is `true`, pass `nextCursor` as `cursor`, with the same filters, for the next page. A cursor from another workspace or environment returns `400 invalid_cursor`.

For one request's grants and overage, see [Get a usage event](https://docs.integrateledger.com/api-reference/usage/event.md). For counts over a month, see [Usage totals](https://docs.integrateledger.com/api-reference/usage/totals.md).

Needs the **Customers** permission at Read. List reads have their own [rate limit](https://docs.integrateledger.com/limits.md#rate-limits) of 10 a second.

```bash cURL theme={"system"}
curl -G https://api.integrateledger.com/v1/usage \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  --data-urlencode "customerId=user_123" \
  --data-urlencode "status=failed"
```

```typescript TypeScript theme={"system"}
import ledger from "integrateledger";

const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? "" });

const page = await client.listUsage({ customerId: "user_123", status: "failed" });
console.log(page.items);
```

```python Python theme={"system"}
import os
from integrateledger import ledger

client = ledger(api_key=os.environ["LEDGER_API_KEY"])

page = client.list_usage(customer_id="user_123", status="failed")
for event in page["items"]:
    print(event["occurredAt"], event["featureId"], event["reason"])
```

```json 200 theme={"system"}
{
  "items": [
    {
      "id": 9182,
      "customerId": "user_123",
      "featureId": "api_call",
      "requestId": "operation_123",
      "status": "failed",
      "reason": "insufficient_credits",
      "outcome": "blocked",
      "chargedCredits": 0,
      "overageCredits": 0,
      "occurredAt": "2026-11-18T09:12:44.120Z",
      "createdAt": "2026-11-18T09:12:44.120Z"
    }
  ],
  "hasMore": false,
  "nextCursor": null
}
```


## OpenAPI

````yaml openapi.json GET /v1/usage
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/usage:
    get:
      tags:
        - Usage
      summary: List the usage log
      operationId: listUsage
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: Only this customer's usage.
          required: false
          description: Only this customer's usage.
          name: customerId
          in: query
        - schema:
            $ref: '#/components/schemas/UsageStatusFilter'
          required: false
          description: >-
            `success`: charged requests. `failed`: requests that weren't
            charged. Defaults to `all`.
          name: status
          in: query
        - schema:
            type: string
            pattern: ^(19[7-9]\d|2\d{3})-(0[1-9]|1[0-2])$
            description: >-
              A UTC month as `YYYY-MM`. Usage is filed under the customer's
              time, which Simulate time can move ahead.
            example: 2026-11
          required: false
          description: >-
            A UTC month as `YYYY-MM`. Usage is filed under the customer's time,
            which Simulate time can move ahead.
          name: month
          in: query
        - schema:
            $ref: '#/components/schemas/UsageOrder'
          required: false
          description: '`recent` (the default) or `oldest` first.'
          name: order
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            description: Items per page, 1–100. Defaults to 25.
          required: false
          description: Items per page, 1–100. Defaults to 25.
          name: limit
          in: query
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 2147483647
            description: >-
              The previous page's `nextCursor`. Omit for the first page. Pass
              the same filters with it.
          required: false
          description: >-
            The previous page's `nextCursor`. Omit for the first page. Pass the
            same filters with it.
          name: cursor
          in: query
      responses:
        '200':
          description: Tracked requests, newest first unless order=oldest
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsagePage'
        '400':
          description: Invalid filter or cursor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageError'
        '401':
          description: Missing or invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '429':
          $ref: '#/components/responses/RateLimited'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: |-
            import os
            from integrateledger import ledger

            client = ledger(api_key=os.environ["LEDGER_API_KEY"])
            client.list_usage(customer_id="user_123", status="failed")
        - lang: bash
          label: cURL
          source: >-
            curl --request GET
            'https://api.integrateledger.com/v1/usage?customerId=user_123&status=failed'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY"
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


            const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await client.listUsage({ customerId: "user_123", status: "failed"
            });
components:
  schemas:
    UsageStatusFilter:
      type: string
      enum:
        - all
        - success
        - failed
      description: >-
        `success`: charged requests. `failed`: requests that weren't charged.
        Defaults to `all`.
    UsageOrder:
      type: string
      enum:
        - recent
        - oldest
      description: '`recent` (the default) or `oldest` first.'
    UsagePage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/UsageEvent'
        hasMore:
          type: boolean
        nextCursor:
          type:
            - integer
            - 'null'
      required:
        - items
        - hasMore
        - nextCursor
    UsageError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        issues:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
              - path
              - message
          description: >-
            With `invalid_request`: each field that failed validation and why.
            `path` is empty for the body itself, such as an unknown field.
      required:
        - error
    UsageEvent:
      type: object
      properties:
        id:
          type: integer
        customerId:
          type: string
        featureId:
          type: string
        requestId:
          type: string
        status:
          type: string
          enum:
            - success
            - failed
        reason:
          type:
            - string
            - 'null'
          description: >-
            Why a failed request wasn't charged, such as `insufficient_credits`.
            Null when charged.
        outcome:
          $ref: '#/components/schemas/UsageOutcome'
        chargedCredits:
          type: integer
          minimum: 0
          description: Credits the request spent, overage included.
        overageCredits:
          type: integer
          minimum: 0
          description: The part of `chargedCredits` that went into overage.
        occurredAt:
          type: string
          format: date-time
          description: >-
            The customer's time of the request: Simulate time's time when it's
            on, else `createdAt`.
        createdAt:
          type: string
          format: date-time
        ai:
          allOf:
            - $ref: '#/components/schemas/AiCharge'
            - type: object
              properties:
                pricedCredits:
                  type: integer
                  minimum: 0
                chargedCredits:
                  type: integer
                  minimum: 0
                uncoveredCredits:
                  type: integer
                  minimum: 0
              required:
                - pricedCredits
                - chargedCredits
                - uncoveredCredits
          description: >-
            An AI call's pricing: model, tokens, costs, markup and price
            version, and the credits it was priced at, charged and left
            uncovered.
      required:
        - id
        - customerId
        - featureId
        - requestId
        - status
        - reason
        - outcome
        - chargedCredits
        - overageCredits
        - occurredAt
        - createdAt
    InsufficientPermissionsError:
      type: object
      properties:
        error:
          type: string
          example: insufficient_permissions
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        requiredScope:
          type: string
          example: customers:read
      required:
        - error
        - requiredScope
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    UsageOutcome:
      type: string
      enum:
        - charged
        - blocked
        - failed
      description: >-
        `charged`: credits were spent. `blocked`: the customer was out of
        credits or at their overage cap. `failed`: any other refusal, such as an
        unknown feature.
    AiCharge:
      type: object
      properties:
        model:
          type: string
        tokens:
          $ref: '#/components/schemas/AiTokens'
        baseCostUsd:
          type: string
          description: What the model's provider charges for the call, in dollars.
        markupPercent:
          type: number
        markupSource:
          type: string
          enum:
            - model
            - provider
            - feature
            - none
        costUsd:
          type: string
          description: The call's price after markup, in dollars.
        priceVersion:
          type: string
          description: >-
            The model price table's version used, or `org` for a price from your
            catalog's models.
      required:
        - model
        - baseCostUsd
        - markupPercent
        - markupSource
        - costUsd
        - priceVersion
      description: 'With model and tokens: how the estimate was priced.'
    AiTokens:
      type: object
      properties:
        input:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Input tokens, cache reads and writes excluded.
        output:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Output tokens, reasoning tokens excluded.
        cacheRead:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Tokens read from the prompt cache.
        cacheWrite:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Tokens written to the prompt cache.
        reasoning:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Reasoning (thinking) tokens.
        audioInput:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Audio input tokens.
        audioOutput:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: Audio output tokens.
      required:
        - input
        - output
      additionalProperties: false
      description: >-
        ai_tokens features: the call's tokens by pool, each counted once (input
        excludes cached tokens, output excludes reasoning tokens), priced at the
        model's rates plus your markup. On track, the call to charge, or the
        real tokens a reservation settles at; on check, an estimate (prompt
        tokens and max output), and with reserve the hold.
  responses:
    InsufficientPermissions:
      description: >-
        The API key works but lacks the permission this endpoint needs, named in
        requiredScope. See the API keys guide.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientPermissionsError'
    RateLimited:
      description: >-
        Too many requests. Wait Retry-After seconds, then retry. See the rate
        limits guide.
      headers:
        Retry-After:
          description: Seconds until a request is allowed again
          schema:
            type: integer
        RateLimit-Limit:
          description: 'The burst: requests allowed at once'
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests left right now
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the full burst is back
          schema:
            type: integer
        RateLimit-Policy:
          description: >-
            The sustained rate per second and the burst, such as
            200;w=1;burst=1000
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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