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

> ## Agent Instructions
> Setting up Context.dev for a user? Follow https://docs.context.dev/agent-quickstart.md. Start by signing the user up and getting an API key through https://www.context.dev/auth.md; application code reads CONTEXT_DEV_API_KEY.

# Retrieve usage history

> Retrieve credits and requests over time, bucketed by hour, day, or month. History is kept for one year.

<Badge color="blue">0 credits</Badge>

Requires [`logs:read` permission](/account/api-keys). See the [guide](/optimization/usage-and-logs) for examples and usage.


## OpenAPI

````yaml GET /org/usage/history
openapi: 3.1.0
info:
  title: Context.dev API
  description: >-
    Scrape, crawl, search, and monitor websites, and retrieve brand, people, and
    news data.
  version: 1.0.0
servers:
  - url: https://api.context.dev/v1
security: []
tags:
  - name: Webhooks
    description: Inspect and retry batch and monitor webhook deliveries.
  - name: Logs
    description: Read your organization's API request logs.
  - name: Usage
    description: Read your organization's credit balance and usage history.
  - name: Agent Feedback
    description: Report API issues and documentation mismatches.
  - name: Batches
    description: Scrape many pages or crawl a site asynchronously.
  - name: Monitors
    description: Watch websites for exact or meaningful changes.
  - name: News
    description: Search live and historical news about a company.
  - name: Answers
    description: Answer a research task from the live web in the JSON shape you ask for.
paths:
  /org/usage/history:
    get:
      tags:
        - Usage
      summary: Retrieve usage history
      description: >-
        Retrieve credits and requests over time, bucketed by hour, day, or
        month. History is kept for one year.
      operationId: getUsageHistory
      parameters:
        - schema:
            type: string
            format: date-time
            description: >-
              Start of the range, as an ISO 8601 timestamp. Defaults to 24 hours
              before `to` for `hour`, 30 days for `day`, and 366 days for
              `month`.
            example: '2026-09-01T00:00:00Z'
          required: false
          description: >-
            Start of the range, as an ISO 8601 timestamp. Defaults to 24 hours
            before `to` for `hour`, 30 days for `day`, and 366 days for `month`.
          name: from
          in: query
        - schema:
            type: string
            format: date-time
            description: End of the range, as an ISO 8601 timestamp. Defaults to now.
            example: '2026-10-01T00:00:00Z'
          required: false
          description: End of the range, as an ISO 8601 timestamp. Defaults to now.
          name: to
          in: query
        - schema:
            type: string
            enum:
              - hour
              - day
              - month
            default: day
            description: >-
              Bucket size. `hour` covers up to 7 days; `day` and `month` cover
              up to 366 days. Buckets start on UTC boundaries.
          required: false
          description: >-
            Bucket size. `hour` covers up to 7 days; `day` and `month` cover up
            to 366 days. Buckets start on UTC boundaries.
          name: interval
          in: query
        - schema:
            type: string
            enum:
              - path
              - key_id
              - status_code
            description: Split each bucket by endpoint path, API key, or HTTP status code.
          required: false
          description: Split each bucket by endpoint path, API key, or HTTP status code.
          name: group_by
          in: query
      responses:
        '200':
          description: Usage over time
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            X-RateLimit-Mode:
              $ref: '#/components/headers/RateLimitMode'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageHistoryResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          description: Rate limit exceeded (60 requests per minute per organization).
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            X-RateLimit-Mode:
              $ref: '#/components/headers/RateLimitMode'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Usage data is temporarily unavailable.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            X-RateLimit-Mode:
              $ref: '#/components/headers/RateLimitMode'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  headers:
    RequestId:
      description: Unique ID of this request; also `request_id` in JSON bodies.
      schema:
        type: string
        format: uuid
    RateLimitLimit:
      description: >-
        Maximum request units per minute, or maximum concurrent requests when
        X-RateLimit-Mode is concurrency.
      schema:
        type: integer
        minimum: 1
    RateLimitRemaining:
      description: >-
        Request units remaining in the current minute, or concurrent requests
        still available when X-RateLimit-Mode is concurrency.
      schema:
        type: integer
        minimum: 0
    RateLimitReset:
      description: >-
        Unix timestamp in seconds when the per-minute rate limit resets. Omitted
        for concurrency limits.
      schema:
        type: integer
    RateLimitMode:
      description: >-
        Set to concurrency when the organization is limited by concurrent
        requests. Omitted for per-minute limits.
      schema:
        type: string
        enum:
          - concurrency
  schemas:
    UsageHistoryResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/UsageHistoryBucket'
          description: >-
            One bucket per interval, oldest first. Intervals without usage are
            included with zero totals.
        total_credits_used:
          type: integer
          description: Credits charged across the range.
        total_request_count:
          type: integer
          description: Requests made across the range.
        interval:
          type: string
          enum:
            - hour
            - day
            - month
          description: Bucket size used.
        from:
          type: string
          format: date-time
          description: Start of the range.
        to:
          type: string
          format: date-time
          description: End of the range.
        key_metadata:
          $ref: '#/components/schemas/KeyMetadata'
        request_id:
          $ref: '#/components/schemas/RequestId'
      required:
        - data
        - total_credits_used
        - total_request_count
        - interval
        - from
        - to
        - request_id
      example:
        data:
          - start: '2026-09-29T00:00:00.000Z'
            credits_used: 1250
            request_count: 830
            groups:
              - value: /v1/web/scrape
                credits_used: 1000
                request_count: 500
              - value: /v1/brand/retrieve
                credits_used: 250
                request_count: 330
          - start: '2026-09-30T00:00:00.000Z'
            credits_used: 0
            request_count: 0
            groups: []
        total_credits_used: 1250
        total_request_count: 830
        interval: day
        from: '2026-09-29T00:00:00.000Z'
        to: '2026-09-30T23:59:59.999Z'
        key_metadata:
          credits_consumed: 0
          credits_remaining: 41250
        request_id: 3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.
        error_code:
          type: string
          enum:
            - INTERNAL_ERROR
            - VALID
            - NOT_FOUND
            - FORBIDDEN
            - USAGE_EXCEEDED
            - RATE_LIMITED
            - UNAUTHORIZED
            - DISABLED
            - PAID_PLAN_REQUIRED
            - INSUFFICIENT_PERMISSIONS
            - TIMEOUT_EXCEEDS_MAXIMUM
            - TIMEOUT_TOO_SHORT_FOR_WAIT
            - WEBSITE_ACCESS_ERROR
            - WEBSITE_BLOCKED
            - WEBSITE_NOT_FOUND
            - PDF_SKIPPED
            - PDF_IMAGES_ONLY
            - INPUT_VALIDATION_ERROR
            - ZDR_NOT_SUPPORTED
            - ZDR_NOT_ENABLED
            - FREE_EMAIL_DETECTED
            - DISPOSABLE_EMAIL_DETECTED
            - REQUEST_TIMEOUT
            - COLD_DOMAIN_TIMEOUT_TOO_LOW
            - UNSUPPORTED_CONTENT
            - CONTENT_TOO_LARGE
            - MONITOR_PAUSED
            - MONITOR_NO_WEBHOOK
            - COLLECTION_PAUSED
            - MONITOR_LIMIT_EXCEEDED
            - SEARCH_UNAVAILABLE
            - BATCH_LIMIT_EXCEEDED
            - BATCH_NOT_CANCELLABLE
            - BATCH_NOT_COMPLETED
            - IDEMPOTENCY_KEY_CONFLICT
            - DELIVERY_IN_PROGRESS
            - DELIVERY_ALREADY_DELIVERED
            - DELIVERY_EXPIRED
            - DELIVERY_CANCELLED
          description: Machine-readable error code.
        required_permission:
          type: string
          enum:
            - logs:read
            - data:execute
            - monitors:read
            - monitors:write
            - batches:read
            - batches:write
          description: >-
            Permission required for this request when error_code is
            INSUFFICIENT_PERMISSIONS. Manage (write) also grants read access to
            the same resource group.
        key_metadata:
          $ref: '#/components/schemas/KeyMetadata'
        request_id:
          $ref: '#/components/schemas/RequestId'
      required:
        - request_id
    UsageHistoryBucket:
      type: object
      properties:
        start:
          type: string
          format: date-time
          description: Start of the bucket, in UTC.
          example: '2026-09-30T00:00:00.000Z'
        credits_used:
          type: integer
          description: Credits charged.
        request_count:
          type: integer
          description: Requests made.
        groups:
          type: array
          items:
            type: object
            properties:
              value:
                type: string
                description: >-
                  The endpoint path, API key ID, or status code this group
                  covers.
                example: /v1/web/scrape
              credits_used:
                type: integer
                description: Credits charged.
              request_count:
                type: integer
                description: Requests made.
            required:
              - value
              - credits_used
              - request_count
          description: >-
            Per-group totals, highest credits first. Present only when
            `group_by` is set.
      required:
        - start
        - credits_used
        - request_count
    KeyMetadata:
      type: object
      properties:
        credits_consumed:
          type: integer
          description: Credits charged for this request.
        credits_remaining:
          type: integer
          description: Credits remaining for your organization.
      required:
        - credits_consumed
        - credits_remaining
      description: Credits this request used and your remaining balance.
    RequestId:
      type: string
      format: uuid
      description: >-
        Unique ID of this request, also in `X-Request-Id`. Include it when
        contacting support.
      example: 3f1c2a6e-8b4d-4c1e-9f0a-2d7b5e6c8a91
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
        X-RateLimit-Mode:
          $ref: '#/components/headers/RateLimitMode'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
        X-RateLimit-Limit:
          $ref: '#/components/headers/RateLimitLimit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/RateLimitRemaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/RateLimitReset'
        X-RateLimit-Mode:
          $ref: '#/components/headers/RateLimitMode'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <API_KEY>`. Keys have full access unless
        restricted to scopes.

````

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