> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reygrid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get usage

> Returns your credit balance and API usage over the last N days
(UTC calendar days, today included): totals, a daily series and the
busiest agents.




## OpenAPI

````yaml /openapi.yaml get /usage
openapi: 3.0.3
info:
  title: ReyGrid API
  version: 1.0.3
  description: |
    ReyGrid API

    ## Persistent user conversations

    If you want to build a separate conversation system for each user,
    build a wrapper layer around the ReyGrid API.

    The wrapper should manage the application's own user IDs and map them
    to ReyGrid conversations.

    The wrapper is responsible for:
    - Managing and identifying users.
    - Storing the relationship between the application's userId and
      ReyGrid conversationId.
    - Persisting conversation IDs in the application's own database.
    - Reusing the stored conversationId when the same user continues
      a conversation.
    - Verifying that conversation IDs belong to the expected user before
      using them.

    ReyGrid's userId can also be used as a stable identifier for persistent
    conversations. However, if the application requires its own user and
    conversation management, it should maintain this mapping in its own
    database.
servers:
  - url: https://reygrid.com/api/v1
security: []
paths:
  /usage:
    get:
      summary: Get usage
      description: |
        Returns your credit balance and API usage over the last N days
        (UTC calendar days, today included): totals, a daily series and the
        busiest agents.
      operationId: getUsage
      parameters:
        - name: days
          in: query
          required: false
          description: Number of days to report, today included.
          schema:
            type: integer
            minimum: 1
            maximum: 90
            default: 30
      responses:
        '200':
          description: Usage
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
              example:
                success: true
                balance:
                  credits: 212.55
                  plan: Pro
                  renewsAt: '2026-11-01T00:00:00.000Z'
                period:
                  days: 7
                  from: '2026-09-29T00:00:00.000Z'
                  to: '2026-10-05T10:21:34.120Z'
                totals:
                  requests: 28
                  failed: 3
                  credits: 15.75
                daily:
                  - date: '2026-09-29T00:00:00.000Z'
                    requests: 2
                    failed: 0
                    credits: 1
                  - date: '2026-09-30T00:00:00.000Z'
                    requests: 0
                    failed: 0
                    credits: 0
                  - date: '2026-10-01T00:00:00.000Z'
                    requests: 5
                    failed: 1
                    credits: 2.5
                  - date: '2026-10-02T00:00:00.000Z'
                    requests: 9
                    failed: 1
                    credits: 4.75
                  - date: '2026-10-03T00:00:00.000Z'
                    requests: 4
                    failed: 0
                    credits: 2.5
                  - date: '2026-10-04T00:00:00.000Z'
                    requests: 3
                    failed: 1
                    credits: 1.5
                  - date: '2026-10-05T00:00:00.000Z'
                    requests: 5
                    failed: 0
                    credits: 3.5
                agents:
                  - id:
                      AgentId: null
                    name: Support
                    requests: 21
                    credits: 11.2
                  - id: 7MDhZpEPGy
                    name: null
                    requests: 7
                    credits: 4.55
        '400':
          $ref: '#/components/responses/InvalidBody'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - apiKeyAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl "https://reygrid.com/api/v1/usage?days=7" \
              -H "Authorization: Bearer $REYGRID_API_KEY"
        - lang: python
          label: Python SDK
          source: |-
            from reygrid import ReyGrid

            client = ReyGrid(api_key="YOUR_API_KEY")

            report = client.get_usage_report(days=7)
            print(report.balance.credits, report.totals.requests)
            for day in report.daily:
                print(day.date, day.requests, day.credits)
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { ReyGrid } from "reygrid";


            const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });


            const report = await client.getUsageReport({ days: 7 });

            console.log(report.balance.credits, report.totals.requests);

            for (const day of report.daily) console.log(day.date, day.requests,
            day.credits);
components:
  schemas:
    UsageResponse:
      type: object
      properties:
        success:
          type: boolean
        balance:
          type: object
          properties:
            credits:
              type: number
              description: Credits available now, extra credits included.
            plan:
              type: string
            renewsAt:
              type: string
              format: date-time
              nullable: true
        period:
          type: object
          properties:
            days:
              type: integer
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        totals:
          $ref: '#/components/schemas/UsageTotals'
        daily:
          type: array
          items:
            allOf:
              - type: object
                properties:
                  date:
                    type: string
                    format: date
              - $ref: '#/components/schemas/UsageTotals'
        agents:
          type: array
          description: The 20 busiest agents of the period.
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
                nullable: true
                description: null when the agent was deleted.
              requests:
                type: integer
              credits:
                type: number
    UsageTotals:
      type: object
      properties:
        requests:
          type: integer
        failed:
          type: integer
        credits:
          type: number
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
        output:
          type: object
          additionalProperties: true
        error:
          $ref: '#/components/schemas/Error'
        usage:
          $ref: '#/components/schemas/ChatUsage'
    AuthErrorResponse:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
          example: Unauthorized
        code:
          type: string
          example: AUTH_REQUIRED
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        list:
          type: array
          description: |
            Validation error details.
            Present when error.code is INVALID_BODY.
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
    ChatUsage:
      type: object
      required:
        - credits
      properties:
        credits:
          type: number
    ValidationErrorItem:
      type: object
      additionalProperties: true
  responses:
    InvalidBody:
      description: Invalid body or query (INVALID_BODY)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error:
              code: INVALID_BODY
              message: Invalid body
              list:
                title:
                  - Title too short
    Unauthorized:
      description: API key is missing or invalid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthErrorResponse'
          example:
            error: Unauthorized
            code: AUTH_REQUIRED
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API-Key
      description: ReyGrid API key sent as a Bearer token.

````

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