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

# Get a usage event

> One tracked request, and the grants and overage it was charged from.

Returns one request from the [usage log](https://docs.integrateledger.com/api-reference/usage/list.md) by its `id`, with where its credits came from.

* `charges` lists each grant the request drew from: its plan or add-on (`sourceType`, `sourceId`, `sourceName`), when it was granted and expires, and the `credits` taken. Grants that expire soonest are spent first.
* `overage` is the part recorded as overage: its credits, the rate it was priced at (`plan`, or a customer's `override`), this request's `costCents`, and whether it has been `billed` on an invoice. `null` when the request stayed within its grants.
* A refused request has no `charges` and `overage` is `null`.
* An event from another workspace or environment returns `404 usage_event_not_found`.

Needs the **Customers** permission at Read.

```bash cURL theme={"system"}
curl https://api.integrateledger.com/v1/usage/42 \
  -H "Authorization: Bearer $LEDGER_API_KEY"
```

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

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

const detail = await client.getUsageEvent({ id: 42 });
console.log(detail.charges, detail.overage);
```

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

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

detail = client.get_usage_event(42)
print(detail["charges"], detail["overage"])
```

```json 200 theme={"system"}
{
  "event": {
    "id": 42,
    "customerId": "user_123",
    "featureId": "enrich",
    "requestId": "operation_123",
    "status": "success",
    "reason": null,
    "outcome": "charged",
    "chargedCredits": 4,
    "overageCredits": 2,
    "occurredAt": "2026-11-18T09:12:44.120Z",
    "createdAt": "2026-11-18T09:12:44.120Z",
    "featureName": "Enrich data",
    "creditCost": 4
  },
  "charges": [
    {
      "creditAllocationId": 311,
      "sourceType": "plan",
      "sourceId": "growth",
      "sourceName": "Growth",
      "grantedAt": "2026-11-01T00:00:00.000Z",
      "expiresAt": "2026-12-01T00:00:00.000Z",
      "credits": 2
    }
  ],
  "overage": {
    "credits": 2,
    "unitAmountCents": 100,
    "billingUnits": 1,
    "rateSource": "plan",
    "planName": "Growth",
    "costCents": 200,
    "billed": false,
    "periodStart": "2026-11-01T00:00:00.000Z",
    "periodEnd": "2026-12-01T00:00:00.000Z"
  }
}
```

```json 404 theme={"system"}
{
  "error": "usage_event_not_found",
  "message": "No usage event with this id exists in this environment. Take the id from GET /v1/usage with a key for the same environment."
}
```


## OpenAPI

````yaml openapi.json GET /v1/usage/{id}
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/{id}:
    get:
      tags:
        - Usage
      summary: Get one usage event and what it was charged from
      operationId: getUsageEvent
      parameters:
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 2147483647
            description: The usage event's `id` from the usage log.
          required: true
          description: The usage event's `id` from the usage log.
          name: id
          in: path
      responses:
        '200':
          description: One tracked request and the grants and overage it was charged from
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageEventDetail'
        '400':
          description: Invalid usage event ID
          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'
        '404':
          description: Usage event not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageError'
        '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_event(42)
        - lang: bash
          label: cURL
          source: |-
            curl --request GET 'https://api.integrateledger.com/v1/usage/42' \
              -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.getUsageEvent({ id: 42 });
components:
  schemas:
    UsageEventDetail:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/UsageEventWithFeature'
        charges:
          type: array
          items:
            $ref: '#/components/schemas/UsageCharge'
          description: >-
            The grants a charged request drew from, one per grant. Empty when it
            wasn't charged.
        overage:
          $ref: '#/components/schemas/UsageOverage'
      required:
        - event
        - charges
        - overage
    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
    UsageEventWithFeature:
      allOf:
        - $ref: '#/components/schemas/UsageEvent'
        - type: object
          properties:
            featureName:
              type:
                - string
                - 'null'
            creditCost:
              type:
                - integer
                - 'null'
          required:
            - featureName
            - creditCost
    UsageCharge:
      type: object
      properties:
        creditAllocationId:
          type: integer
        sourceType:
          $ref: '#/components/schemas/UsageChargeSourceType'
        sourceId:
          type:
            - string
            - 'null'
          description: The plan or add-on ID the grant came from.
        sourceName:
          type:
            - string
            - 'null'
        grantedAt:
          type: string
          format: date-time
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
        credits:
          type: integer
          exclusiveMinimum: 0
      required:
        - creditAllocationId
        - sourceType
        - sourceId
        - sourceName
        - grantedAt
        - expiresAt
        - credits
    UsageOverage:
      type:
        - object
        - 'null'
      properties:
        credits:
          type: integer
          exclusiveMinimum: 0
        unitAmountCents:
          type: integer
          exclusiveMinimum: 0
        billingUnits:
          type: integer
          exclusiveMinimum: 0
        rateSource:
          $ref: '#/components/schemas/UsageOverageRateSource'
        planName:
          type: string
        costCents:
          type: number
          minimum: 0
          description: >-
            This request's share at its rate. The invoice rounds each rate up to
            whole billing units.
        billed:
          type: boolean
        periodStart:
          type: string
          format: date-time
        periodEnd:
          type: string
          format: date-time
      required:
        - credits
        - unitAmountCents
        - billingUnits
        - rateSource
        - planName
        - costCents
        - billed
        - periodStart
        - periodEnd
      description: >-
        The overage a charged request recorded. Null when it stayed within its
        grants.
    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
    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
    UsageChargeSourceType:
      type: string
      enum:
        - plan
        - add_on
        - adjustment
        - entity
        - rollover
        - top_up
        - reward
      description: >-
        Where the grant came from: a plan period, a credit pack, a balance
        adjustment, an entity's allowance, a plan grant's rollover, a top-up, or
        a reward code.
    UsageOverageRateSource:
      type: string
      enum:
        - plan
        - override
    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.