> ## 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 customer's controls

> The usage limits, usage alerts and overage controls in force, with their state.

Every entry in force for the customer, or with `entityId` for one entity (its own entries first, then the customer's), each with its `source` (`entity`, `customer` or `plan`):

* **`usageLimits`**: `used` in the current window (held reservations included), `remaining`, `windowStart` and `resetsAt`.
* **`usageAlerts`**: `firedAt`, when the alert last fired in its current window, or null.
* **`overage`**: for the credit pool and each metered feature with an overage price or an entry, whether overage is `allowed`, the `freeUnits` buffer and `freeLeft` this period, `billOverage`, and this period's `billed` and `unbilled` overage in units (credits for the pool).


## OpenAPI

````yaml openapi.json GET /v1/customers/controls
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/controls:
    get:
      tags:
        - Customers
      summary: Get a customer's usage limits, usage alerts and overage controls
      description: Add entityId to read one entity's own entries beside the customer's.
      operationId: getCustomerControls
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: Your ID for the customer, such as your user ID.
          required: true
          description: Your ID for the customer, such as your user ID.
          name: customerId
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: >-
              One of the customer's entities: its own entries, beside the
              customer's.
          required: false
          description: >-
            One of the customer's entities: its own entries, beside the
            customer's.
          name: entityId
          in: query
      responses:
        '200':
          description: The controls in force, with their state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerControls'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '401':
          description: Missing or invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: Customer or entity not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '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_customer_controls(customer_id="user_123")
        - lang: bash
          label: cURL
          source: >-
            curl --request GET
            'https://api.integrateledger.com/v1/customers/controls?customerId=user_123'
            \
              -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.getCustomerControls({ customerId: "user_123" });
components:
  schemas:
    CustomerControls:
      type: object
      properties:
        customerId:
          type: string
        entityId:
          type:
            - string
            - 'null'
        usageLimits:
          type: array
          items:
            type: object
            properties:
              featureId:
                type: string
              creditPool:
                type: boolean
                const: true
              interval:
                type: string
              anchor:
                type: string
              filter:
                type:
                  - object
                  - 'null'
                additionalProperties: {}
              limit:
                type: integer
              scope:
                type: string
                enum:
                  - customer
                  - entity
              source:
                type: string
                enum:
                  - entity
                  - customer
                  - plan
              used:
                type: integer
              remaining:
                type: integer
              windowStart:
                type: string
                format: date-time
              resetsAt:
                type: string
                format: date-time
            required:
              - interval
              - filter
              - limit
              - scope
              - source
              - used
              - remaining
              - windowStart
              - resetsAt
        usageAlerts:
          type: array
          items:
            type: object
            properties:
              featureId:
                type: string
              creditPool:
                type: boolean
                const: true
              name:
                type: string
              type:
                type: string
              threshold:
                type: number
              usageLimit:
                type: object
                properties:
                  interval:
                    type: string
                  filter:
                    type: object
                    additionalProperties: {}
                required:
                  - interval
              scope:
                type: string
                enum:
                  - customer
                  - entity
              source:
                type: string
                enum:
                  - entity
                  - customer
                  - plan
              firedAt:
                type:
                  - string
                  - 'null'
                format: date-time
                description: When it last fired in its current window; null if not yet.
            required:
              - name
              - type
              - threshold
              - scope
              - source
              - firedAt
        overage:
          type: array
          items:
            type: object
            properties:
              featureId:
                type: string
              creditPool:
                type: boolean
                const: true
              allowed:
                type: boolean
              freeUnits:
                type: integer
              billOverage:
                type: boolean
              source:
                type: string
                enum:
                  - entity
                  - customer
                  - plan
              billed:
                type: integer
                description: >-
                  Overage this period that invoices bill, in units (credits for
                  the pool).
              unbilled:
                type: integer
                description: >-
                  Overage this period no invoice bills: the free buffer and
                  record-only overage.
              freeLeft:
                type: integer
            required:
              - allowed
              - freeUnits
              - billOverage
              - source
              - billed
              - unbilled
              - freeLeft
      required:
        - customerId
        - entityId
        - usageLimits
        - usageAlerts
        - overage
    CustomerError:
      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.