Billing

Check billing consistency

Runs a read-only consistency audit across closed ledgers, frozen statement snapshots, billing events, expired billing states, and Stripe invoice snapshots. Empty Admin-bypass static principals are excluded from ordinary state/ledger checks; unexpected billing artifacts remain reportable. It reports issues only and does not repair data or consume credits.

get/admin/billing/consistency

Request

  • Base URL: https://api.crawlora.net/api/v1
  • URL: https://api.crawlora.net/api/v1/admin/billing/consistency
  • Auth: API key in header x-api-key

Query parameters

fromstring

Lower bound in RFC3339 format. Defaults to 30 days ago when from/to are omitted.

tostring

Upper bound in RFC3339 format. Defaults to now when from/to are omitted.

user_idstring

Limit checks to one user

period_keystring

Limit checks to one period in YYYY-MM format

issue_typestring

Limit results to one consistency issue type, including excluded_principal_billing_artifact

severity'error' | 'info'

Limit results to error or info issues

limitinteger

Maximum issues to return. Defaults to 100 and clamps to 500.

Headers

x-api-keystring required

Admin API key required unless an authenticated Admin JWT is already present

Response

Billing consistency report

codeinteger
msgstring

Example response

{
  "code": 200,
  "data": {
    "checked_from": "2026-04-01T00:00:00Z",
    "checked_to": "2026-04-30T23:59:59Z",
    "generated_at": "2026-05-01T00:15:00Z",
    "issues": [
      {
        "actual_credits": 990,
        "actual_overage": 90,
        "created_at": "2026-05-01T00:15:00Z",
        "detail": "closed period ledger has no frozen statement snapshot",
        "endpoint_breakdown": [
          {
            "actual_credits": 990,
            "actual_overage": 90,
            "endpoint": "google/search",
            "expected_credits": 1000,
            "expected_overage": 100
          }
        ],
        "expected_credits": 1000,
        "expected_overage": 100,
        "frozen_at": "2026-05-01T00:15:00Z",
        "issue_id": "5f6d2e4c9f7a8b01",
        "issue_type": "closed_ledger_missing_snapshot",
        "period_key": "2026-04",
        "repair_method": "POST",
        "repair_path": "/api/v1/admin/billing/users/user-1/periods/2026-04/statement/freeze",
        "request_id": "req-1",
        "severity": "error",
        "source_updated_at": "2026-05-01T02:15:00Z",
        "statement_id": "bps:user-1:2026-04:1",
        "stripe_invoice_id": "in_123",
        "suggested_action": "freeze_statement",
        "user_id": "user-1"
      }
    ]
  },
  "msg": "OK"
}

Changes

No recorded changes to this operation across all 2 revisions of this API.