{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/serpresult-com/json-schema/serpresult-com-billing-summary-response-schema.json",
  "title": "BillingSummaryResponse",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/serpresult-com-openapi.json#/components/schemas/BillingSummaryResponse",
  "type": "object",
  "required": [
    "plan",
    "period",
    "usage",
    "subscription",
    "credits",
    "plans",
    "custom",
    "upgrade",
    "checkout"
  ],
  "properties": {
    "plan": {
      "$ref": "#/$defs/Plan"
    },
    "period": {
      "type": "object",
      "description": "The window the usage is measured over, UTC.",
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time",
          "description": "First instant of the window, inclusive. The epoch on a lifetime quota."
        },
        "end": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "First instant of the next window, exclusive, and when the quota resets. `null` on a lifetime quota, which never rolls over."
        }
      }
    },
    "usage": {
      "$ref": "#/$defs/BillingUsage"
    },
    "subscription": {
      "oneOf": [
        {
          "$ref": "#/$defs/BillingSubscription"
        },
        {
          "type": "null"
        }
      ],
      "description": "The subscription behind the plan, or `null` on an account that has never bought one."
    },
    "credits": {
      "$ref": "#/$defs/BillingCredits"
    },
    "plans": {
      "type": "array",
      "description": "The plans on offer, cheapest first, plus the account's own when it is on one that is not offered.",
      "items": {
        "$ref": "#/$defs/Plan"
      }
    },
    "custom": {
      "type": "object",
      "description": "Where to write for volume, concurrency or contract terms above the listed plans.",
      "required": [
        "email"
      ],
      "properties": {
        "email": {
          "type": "string",
          "format": "email"
        }
      }
    },
    "upgrade": {
      "type": "object",
      "description": "How to change plan while dashboard checkout is being built.",
      "required": [
        "email",
        "rapidapi_url"
      ],
      "properties": {
        "email": {
          "type": "string",
          "format": "email"
        },
        "rapidapi_url": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "checkout": {
      "type": "object",
      "description": "Whether a purchase can be started here, and where the same plans are sold while it cannot.",
      "required": [
        "enabled",
        "rapidapi_url"
      ],
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "`false` ⇒ the two checkouts and the plan change answer `503 billing_unavailable`."
        },
        "rapidapi_url": {
          "type": "string",
          "format": "uri",
          "description": "The marketplace listing selling the same plans at the same price."
        }
      }
    }
  },
  "$defs": {
    "BillingCredits": {
      "type": "object",
      "description": "Credit packs — the balance, what is on offer and what has been bought.",
      "required": [
        "balance",
        "packs",
        "purchases"
      ],
      "properties": {
        "balance": {
          "type": "integer",
          "minimum": 0,
          "description": "Pack credits left. Account-wide: it never expires and survives the subscription that bought it, so it is present even with no subscription."
        },
        "packs": {
          "type": "array",
          "description": "The packs the account may buy right now, priced off its own plan, smallest first. Empty on the trial, which cannot buy one.",
          "items": {
            "$ref": "#/$defs/CreditPack"
          }
        },
        "purchases": {
          "type": "array",
          "description": "The last ten purchases, newest first.",
          "items": {
            "$ref": "#/$defs/BillingPurchase"
          }
        }
      }
    },
    "BillingPurchase": {
      "type": "object",
      "description": "One credit pack the account has bought.",
      "required": [
        "id",
        "plan",
        "credits",
        "amount_usd",
        "currency",
        "status",
        "paid_at",
        "refunded_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "The Polar order id."
        },
        "plan": {
          "$ref": "#/$defs/PlanId"
        },
        "credits": {
          "type": "integer",
          "description": "Credits the pack carried. They are added to the balance in full when the order is paid."
        },
        "amount_usd": {
          "type": "number"
        },
        "currency": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "paid",
            "refunded"
          ],
          "description": "`refunded` once Polar reports the order refunded, at which point the credits are taken back off the balance, clamped at 0."
        },
        "paid_at": {
          "type": "string",
          "format": "date-time"
        },
        "refunded_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "BillingSubscription": {
      "type": "object",
      "description": "The Polar subscription behind a paid plan.",
      "required": [
        "subscription_id",
        "plan",
        "status",
        "current_period_start",
        "current_period_end",
        "cancel_at_period_end",
        "ends_at"
      ],
      "properties": {
        "subscription_id": {
          "type": "string"
        },
        "plan": {
          "type": "string",
          "enum": [
            "starter",
            "growth",
            "business",
            "enterprise"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "incomplete",
            "incomplete_expired",
            "trialing",
            "active",
            "past_due",
            "canceled",
            "unpaid"
          ],
          "description": "Polar's own status. `active`, `trialing` and `past_due` still entitle the plan."
        },
        "current_period_start": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "First instant of the billing period. This is also the window the quota is measured over."
        },
        "current_period_end": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "cancel_at_period_end": {
          "type": "boolean",
          "description": "True once cancelled in the portal. Access runs to `ends_at`; the plan steps down when the subscription actually ends."
        },
        "ends_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "BillingUsage": {
      "type": "object",
      "required": [
        "credits_used",
        "quota",
        "remaining",
        "balance",
        "allowance",
        "quota_period"
      ],
      "properties": {
        "credits_used": {
          "type": "integer",
          "description": "Credits spent inside the current period."
        },
        "quota": {
          "type": "integer",
          "description": "Requests the period allows. On the trial this is what is left of the account's one-time grant — 0 for an address that already used a trial."
        },
        "remaining": {
          "type": "integer",
          "minimum": 0,
          "description": "What is left of the period's quota. Never below 0."
        },
        "balance": {
          "type": "integer",
          "minimum": 0,
          "description": "Pack credits on the account. Spent only once `remaining` is 0, and never expires."
        },
        "allowance": {
          "type": "integer",
          "minimum": 0,
          "description": "`remaining` + `balance`: everything the account may still spend before a 402."
        },
        "quota_period": {
          "$ref": "#/$defs/PlanQuotaPeriod"
        }
      }
    },
    "CreditPack": {
      "type": "object",
      "description": "One credit pack on offer, priced at the account's own plan rate.",
      "required": [
        "size",
        "price_usd"
      ],
      "properties": {
        "size": {
          "$ref": "#/$defs/CreditPackSize"
        },
        "price_usd": {
          "type": "number",
          "description": "What the pack costs, in US dollars. Polar takes the payment and issues the receipt."
        }
      }
    },
    "CreditPackSize": {
      "type": "integer",
      "description": "The credit packs on offer. The same three sizes on every plan; only the price per credit changes.",
      "enum": [
        10000,
        50000,
        100000
      ]
    },
    "Plan": {
      "type": "object",
      "description": "One plan. Prices are US dollars per month, the same bought direct or through RapidAPI.",
      "required": [
        "id",
        "name",
        "rapidapi_slot",
        "price_usd",
        "monthly_quota",
        "quota_period",
        "recharge_per_request_usd",
        "concurrency",
        "rate_limit_per_minute",
        "recommended",
        "public"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/PlanId"
        },
        "name": {
          "type": "string"
        },
        "rapidapi_slot": {
          "type": "string",
          "description": "The tier this plan is listed as on RapidAPI.",
          "enum": [
            "BASIC",
            "PRO",
            "ULTRA",
            "MEGA",
            "CUSTOM"
          ]
        },
        "price_usd": {
          "type": "number",
          "description": "US dollars per month. The same price on RapidAPI and direct."
        },
        "monthly_quota": {
          "type": "integer",
          "description": "Requests included per period — per billing cycle on a paid plan, or once for life on the trial."
        },
        "quota_period": {
          "$ref": "#/$defs/PlanQuotaPeriod"
        },
        "recharge_per_request_usd": {
          "type": [
            "number",
            "null"
          ],
          "description": "What one pack credit costs on this plan, and so what a credit pack is priced at. `null` on the trial, which cannot buy one. Quoted publicly per 1,000 — `0.0015` is $1.50 per 1,000 credits."
        },
        "concurrency": {
          "type": "integer",
          "description": "How many requests the plan runs at once, and how the limit is quoted publicly. Enforced as `concurrency × 60` requests per rolling minute."
        },
        "rate_limit_per_minute": {
          "type": "integer",
          "description": "The enforced rate for this plan's keys and MCP tokens. A dashboard session gets this or 120, whichever is higher."
        },
        "recommended": {
          "type": "boolean",
          "description": "True on the one plan the pricing page highlights."
        },
        "public": {
          "type": "boolean",
          "description": "Whether the plan is offered. False on the trial and on the plan a negotiated deal is put on, which is advertised as \"Custom\" instead."
        }
      }
    },
    "PlanId": {
      "type": "string",
      "enum": [
        "trial",
        "starter",
        "growth",
        "business",
        "enterprise"
      ],
      "default": "trial"
    },
    "PlanQuotaPeriod": {
      "type": "string",
      "description": "What the plan's quota is measured over.\n- `month` — the subscription's billing cycle, renewing monthly on the day it started. An account with no subscription cycle behind its plan falls back to the calendar month in UTC, reset at `00:00:00Z` on the 1st. `period.end` and `X-Quota-Reset` carry the exact moment either way.\n- `lifetime` — counted from the account's first search and never reset. The trial only.\n",
      "enum": [
        "lifetime",
        "month"
      ]
    }
  }
}