{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-account-usage-response-schema.json",
  "title": "AccountUsageResponse",
  "description": "Usage response for an authenticated account.",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-openapi.json#/components/schemas/AccountUsageResponse",
  "properties": {
    "blocked": {
      "description": "Whether the account is blocked by a configured limit.",
      "type": "boolean"
    },
    "by_project": {
      "description": "Usage breakdown by project.",
      "items": {
        "$ref": "#/$defs/ProjectUsageResponse"
      },
      "type": "array"
    },
    "by_stream": {
      "description": "Usage breakdown by telemetry stream.",
      "items": {
        "$ref": "#/$defs/StreamUsageResponse"
      },
      "type": "array"
    },
    "limit": {
      "anyOf": [
        {
          "$ref": "#/$defs/AccountUsageLimitResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "Configured limit driving the current warning or block state."
    },
    "limits": {
      "$ref": "#/$defs/AccountUsageLimitsResponse",
      "description": "Account limits for this period."
    },
    "next": {
      "description": "Display-safe next action for the current usage state.",
      "type": "string"
    },
    "next_action": {
      "$ref": "#/$defs/AccountUsageNextActionResponse",
      "description": "Stable machine-readable guidance for clients that localize usage actions."
    },
    "offer": {
      "anyOf": [
        {
          "$ref": "#/$defs/BillingOfferResponse"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Active offer whose plan allowances `limits` and `state` include; absent when none."
    },
    "percent_used": {
      "description": "Highest configured limit utilization as a percentage.",
      "format": "double",
      "type": "number"
    },
    "period_end": {
      "description": "End of the usage period.",
      "format": "date-time",
      "type": "string"
    },
    "period_start": {
      "description": "Start of the usage period.",
      "format": "date-time",
      "type": "string"
    },
    "plan": {
      "$ref": "#/$defs/AccountPlanResponse",
      "description": "Current account plan state."
    },
    "reset_at": {
      "description": "Time at which this usage period resets.",
      "format": "date-time",
      "type": "string"
    },
    "sdk_dropped_events": {
      "default": [],
      "description": "Events SDKs reported as dropped before delivery this period, by project and reason.\n\nThese events never reached `LogBrew`, so they are not billed and do not count toward\n`usage`, `by_project`, or `by_stream`.",
      "items": {
        "$ref": "#/$defs/SdkDroppedEventsResponse"
      },
      "type": "array"
    },
    "spike_protection": {
      "default": [],
      "description": "Spike protection of each project: its hourly ingest limits and the events they refused\nthis period. Refused events are never billed and do not count toward `usage`.",
      "items": {
        "$ref": "#/$defs/SpikeProtectionResponse"
      },
      "type": "array"
    },
    "state": {
      "$ref": "#/$defs/AccountUsageState",
      "description": "Backend-owned usage state."
    },
    "usage": {
      "$ref": "#/$defs/AccountUsageTotalsResponse",
      "description": "Account usage totals for this period."
    },
    "warning": {
      "description": "Whether the account is approaching a configured limit.",
      "type": "boolean"
    },
    "warning_threshold": {
      "description": "Warning threshold as a fraction of limited usage.",
      "format": "double",
      "type": "number"
    }
  },
  "required": [
    "period_start",
    "period_end",
    "reset_at",
    "plan",
    "limits",
    "usage",
    "state",
    "warning_threshold",
    "percent_used",
    "warning",
    "blocked",
    "limit",
    "next",
    "next_action",
    "by_project",
    "by_stream",
    "sdk_dropped_events",
    "offer",
    "spike_protection"
  ],
  "type": "object",
  "$defs": {
    "AccountPlanResponse": {
      "description": "Account plan status.",
      "properties": {
        "status": {
          "$ref": "#/$defs/AccountPlanStatus",
          "description": "Billing or access state for the plan."
        },
        "tier": {
          "description": "Human-readable plan tier.",
          "type": "string"
        }
      },
      "required": [
        "tier",
        "status"
      ],
      "type": "object"
    },
    "AccountPlanStatus": {
      "description": "Stable account plan status vocabulary.",
      "oneOf": [
        {
          "const": "free",
          "description": "Free account state.",
          "type": "string"
        },
        {
          "const": "trial",
          "description": "Trial account state.",
          "type": "string"
        },
        {
          "const": "active",
          "description": "Paid account in good standing.",
          "type": "string"
        },
        {
          "const": "past_due",
          "description": "Billing is past due.",
          "type": "string"
        },
        {
          "const": "disabled",
          "description": "Account access is disabled.",
          "type": "string"
        }
      ]
    },
    "AccountUsageLimitResponse": {
      "description": "Configured account usage limit that drives warning or blocked state.",
      "oneOf": [
        {
          "const": "events",
          "description": "Event limit.",
          "type": "string"
        },
        {
          "const": "bytes",
          "description": "Byte limit.",
          "type": "string"
        }
      ]
    },
    "AccountUsageLimitsResponse": {
      "description": "Account usage limits for the active period.",
      "properties": {
        "bytes": {
          "description": "Raw byte limit, or `null` when no shipped limit is enforced.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "events": {
          "description": "Event limit, or `null` when no shipped limit is enforced.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "projects": {
          "description": "Project limit, or `null` when no shipped limit is enforced.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "retention_days": {
          "description": "Retention period in days, or `null` when not enforced here.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "events",
        "bytes",
        "projects",
        "retention_days"
      ],
      "type": "object"
    },
    "AccountUsageNextActionCode": {
      "description": "Stable usage guidance code for localized clients.",
      "oneOf": [
        {
          "const": "continue_sending_telemetry",
          "description": "Keep sending telemetry.",
          "type": "string"
        },
        {
          "const": "reduce_usage_or_upgrade",
          "description": "Reduce usage volume or upgrade before a limit is reached.",
          "type": "string"
        },
        {
          "const": "wait_until_reset_or_upgrade",
          "description": "Wait for the next reset or upgrade before sending more telemetry.",
          "type": "string"
        },
        {
          "const": "check_usage_limits",
          "description": "Fallback guidance for a missing limit context. Released clients still parse it; a\nblocked state always names its limit, so the API never returns it.",
          "type": "string"
        }
      ]
    },
    "AccountUsageNextActionResponse": {
      "description": "Stable account usage guidance action.",
      "properties": {
        "code": {
          "$ref": "#/$defs/AccountUsageNextActionCode",
          "description": "Stable localization key for the recommended action."
        },
        "limit": {
          "anyOf": [
            {
              "$ref": "#/$defs/AccountUsageLimitResponse"
            },
            {
              "type": "null"
            }
          ],
          "description": "Limit that produced this action, when a specific limit applies."
        },
        "reset_at": {
          "description": "Reset timestamp clients may include in localized guidance.",
          "format": "date-time",
          "type": "string"
        },
        "state": {
          "$ref": "#/$defs/AccountUsageState",
          "description": "Usage state that produced this action."
        },
        "target": {
          "$ref": "#/$defs/AccountUsageNextActionTarget",
          "description": "Stable product surface the client should route to."
        }
      },
      "required": [
        "code",
        "target",
        "state",
        "limit",
        "reset_at"
      ],
      "type": "object"
    },
    "AccountUsageNextActionTarget": {
      "description": "Stable account usage action target.",
      "oneOf": [
        {
          "const": "telemetry_ingest",
          "description": "Continue with the telemetry ingestion surface.",
          "type": "string"
        },
        {
          "const": "account_usage",
          "description": "Review account usage and limits.",
          "type": "string"
        },
        {
          "const": "pricing",
          "description": "Open pricing and plan selection.",
          "type": "string"
        }
      ]
    },
    "AccountUsageState": {
      "description": "Backend-owned account usage state.",
      "oneOf": [
        {
          "const": "ok",
          "description": "Account is within limits.",
          "type": "string"
        },
        {
          "const": "warning",
          "description": "Account is approaching a limit.",
          "type": "string"
        },
        {
          "const": "blocked",
          "description": "Account is blocked by a limit.",
          "type": "string"
        }
      ]
    },
    "AccountUsageTotalsResponse": {
      "description": "Account usage totals for the active period.",
      "properties": {
        "bytes": {
          "description": "Number of raw log bytes seen in the period.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "events": {
          "description": "Number of telemetry events seen in the period.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "projects": {
          "description": "Number of active projects in the account.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "events",
        "bytes",
        "projects"
      ],
      "type": "object"
    },
    "BillingOfferKind": {
      "description": "Offer kinds.",
      "oneOf": [
        {
          "const": "public_beta",
          "description": "The new-account offer: Pro (`team`) allowances for 6 months from sign-up (from\n2026-10-22 for accounts that existed at launch). Sign-up no longer grants it; accounts\nthat hold it keep it until it ends, and new accounts try Pro through the checkout trial.",
          "type": "string"
        }
      ]
    },
    "BillingOfferResponse": {
      "description": "Plan allowances granted for a fixed time, apart from a paid subscription.",
      "properties": {
        "ends_at": {
          "description": "Exclusive end; the account falls back to its own plan afterwards.",
          "format": "date-time",
          "type": "string"
        },
        "kind": {
          "$ref": "#/$defs/BillingOfferKind",
          "description": "Why the allowances apply."
        },
        "starts_at": {
          "description": "Inclusive start.",
          "format": "date-time",
          "type": "string"
        },
        "tier": {
          "$ref": "#/$defs/BillingTier",
          "description": "Plan whose allowances apply while the offer lasts."
        }
      },
      "required": [
        "kind",
        "tier",
        "starts_at",
        "ends_at"
      ],
      "type": "object"
    },
    "BillingTier": {
      "description": "Canonical subscription tier.",
      "oneOf": [
        {
          "const": "developer",
          "description": "Free individual plan.",
          "type": "string"
        },
        {
          "const": "team",
          "description": "Fixed $25 monthly plan.",
          "type": "string"
        },
        {
          "const": "business",
          "description": "Fixed $80 monthly plan.",
          "type": "string"
        },
        {
          "const": "enterprise",
          "description": "Quoted contract.",
          "type": "string"
        }
      ]
    },
    "ProjectUsageResponse": {
      "description": "Usage breakdown for one project.",
      "properties": {
        "bytes": {
          "description": "Number of raw log bytes for the project.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "events": {
          "description": "Number of telemetry events for the project.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "project_id": {
          "description": "Project identifier.",
          "format": "uuid",
          "type": "string"
        }
      },
      "required": [
        "project_id",
        "events",
        "bytes"
      ],
      "type": "object"
    },
    "SdkDroppedEventsResponse": {
      "description": "Events one project's SDKs dropped for one reason.",
      "properties": {
        "events": {
          "description": "Number of dropped events.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "project_id": {
          "description": "Project identifier.",
          "format": "uuid",
          "type": "string"
        },
        "reason": {
          "description": "SDK drop reason code, such as `queue_overflow`.",
          "type": "string"
        }
      },
      "required": [
        "project_id",
        "reason",
        "events"
      ],
      "type": "object"
    },
    "SpikeDroppedEventsResponse": {
      "description": "Events spike protection refused for one reason and meter.",
      "properties": {
        "events": {
          "description": "Refused events. A client that sends a refused batch again counts again.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "last_dropped_at": {
          "description": "Last refusal.",
          "format": "date-time",
          "type": "string"
        },
        "meter": {
          "description": "Meter whose hourly limit was reached, such as `log_bytes`.",
          "type": "string"
        },
        "reason": {
          "description": "Limit that refused them: `key_limit` or `project_limit`.",
          "type": "string"
        }
      },
      "required": [
        "reason",
        "meter",
        "events",
        "last_dropped_at"
      ],
      "type": "object"
    },
    "SpikeLimitsResponse": {
      "description": "Hourly ingest limits per meter, in the meter's units; null when the meter has no limit.",
      "properties": {
        "issue_events": {
          "description": "Issue events per hour.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "log_bytes": {
          "description": "Log bytes per hour.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "metric_bytes": {
          "description": "Metric bytes per hour.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "trace_spans": {
          "description": "Trace spans per hour.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "issue_events",
        "log_bytes",
        "metric_bytes",
        "trace_spans"
      ],
      "type": "object"
    },
    "SpikeProtectionResponse": {
      "description": "Spike protection of one project: hourly ingest limits sized from the plan's monthly\nallowances, so one burst cannot use the month.",
      "properties": {
        "active": {
          "description": "Whether the limits refused events in the last hour.",
          "type": "boolean"
        },
        "dropped_events": {
          "description": "Events the limits refused this period, by reason and meter.",
          "items": {
            "$ref": "#/$defs/SpikeDroppedEventsResponse"
          },
          "type": "array"
        },
        "enabled": {
          "description": "Whether the hourly limits apply. The owner can turn them off.",
          "type": "boolean"
        },
        "key_limits": {
          "$ref": "#/$defs/SpikeLimitsResponse",
          "description": "Hourly limits for each ingest key of the project."
        },
        "multiplier": {
          "description": "How many times the default limits the owner allows, 1 to 15.",
          "format": "uint8",
          "maximum": 255,
          "minimum": 0,
          "type": "integer"
        },
        "project_id": {
          "description": "Project identifier.",
          "format": "uuid",
          "type": "string"
        },
        "project_limits": {
          "$ref": "#/$defs/SpikeLimitsResponse",
          "description": "Hourly limits for the whole project."
        }
      },
      "required": [
        "project_id",
        "enabled",
        "multiplier",
        "active",
        "project_limits",
        "key_limits",
        "dropped_events"
      ],
      "type": "object"
    },
    "StreamUsageResponse": {
      "description": "Usage breakdown for one telemetry stream.",
      "properties": {
        "bytes": {
          "description": "Number of raw log bytes attributed to this stream.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "events": {
          "description": "Number of telemetry events for this stream.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "kind": {
          "description": "Telemetry stream kind.",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "events",
        "bytes"
      ],
      "type": "object"
    }
  }
}