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

# Usage totals

> Count a month's tracked requests by outcome and failure reason.

Counts the requests `track` recorded in one UTC month, for the whole environment or one `customerId`.

* `events` is every request; `charged`, `blocked` and `failed` split it by [outcome](https://docs.integrateledger.com/api-reference/usage/list.md). `chargedCredits` adds up what the charged ones spent, overage included.
* `reasons` counts the refused requests by reason, such as `insufficient_credits`, `overage_cap_reached` or `feature_not_found`.
* `month` is required (`YYYY-MM`). Usage is filed under the customer's time, so a customer with [Simulate time](https://docs.integrateledger.com/test/simulate-time.md) on can have usage in a later month.

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/totals \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  --data-urlencode "month=2026-11"
```

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

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

const totals = await client.getUsageTotals({ month: "2026-11" });
console.log(totals);
```

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

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

totals = client.get_usage_totals(month="2026-11")
print(totals["charged"], totals["reasons"])
```

```json 200 theme={"system"}
{
  "month": "2026-11",
  "customerId": null,
  "events": 1250,
  "charged": 1210,
  "blocked": 38,
  "failed": 2,
  "chargedCredits": 4840,
  "reasons": {
    "insufficient_credits": 35,
    "overage_cap_reached": 3,
    "feature_not_found": 2
  }
}
```


## OpenAPI

````yaml openapi.json GET /v1/usage/totals
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/totals:
    get:
      tags:
        - Usage
      summary: Get a month's usage totals
      operationId: getUsageTotals
      parameters:
        - 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: true
          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:
            type: string
            minLength: 1
            maxLength: 255
            description: Only this customer's usage.
          required: false
          description: Only this customer's usage.
          name: customerId
          in: query
      responses:
        '200':
          description: A month's usage, counted by outcome and failure reason
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageTotals'
        '400':
          description: Invalid filter
          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.get_usage_totals(month="2026-11")
        - lang: bash
          label: cURL
          source: >-
            curl --request GET
            'https://api.integrateledger.com/v1/usage/totals?month=2026-11' \
              -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.getUsageTotals({ month: "2026-11" });
components:
  schemas:
    UsageTotals:
      type: object
      properties:
        month:
          type: string
        customerId:
          type:
            - string
            - 'null'
        events:
          type: integer
          minimum: 0
        charged:
          type: integer
          minimum: 0
        blocked:
          type: integer
          minimum: 0
        failed:
          type: integer
          minimum: 0
        chargedCredits:
          type: integer
          minimum: 0
          description: Credits spent by the month's charged requests.
        reasons:
          type: object
          additionalProperties:
            type: integer
            minimum: 0
          description: >-
            How many requests weren't charged, by reason, such as
            `insufficient_credits`.
      required:
        - month
        - customerId
        - events
        - charged
        - blocked
        - failed
        - chargedCredits
        - reasons
    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
    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
  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.