{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pinbridge-io/json-schema/pinbridge-io-billing-status-response-schema.json",
  "title": "BillingStatusResponse",
  "description": "Plan, billing status and quota usage for the current workspace.",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pinbridge-io-openapi.json#/components/schemas/BillingStatusResponse",
  "properties": {
    "plan": {
      "$ref": "#/$defs/Plan",
      "description": "Current plan. `pro` is the Agency plan"
    },
    "billing_provider": {
      "type": "string",
      "title": "Billing Provider",
      "description": "`stripe` when billed through Stripe, `database` when the plan is set by PinBridge",
      "default": "database"
    },
    "billing_cycle": {
      "anyOf": [
        {
          "$ref": "#/$defs/BillingCycle"
        },
        {
          "type": "null"
        }
      ],
      "description": "`monthly` or `annual`; null when unknown"
    },
    "billing_status": {
      "$ref": "#/$defs/BillingStatus",
      "description": "Subscription status"
    },
    "trial_active": {
      "type": "boolean",
      "title": "Trial Active",
      "description": "Whether a free trial is running",
      "default": false
    },
    "trial_ends_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Trial Ends At",
      "description": "Set while a trial is active"
    },
    "trial_pins_limit": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Trial Pins Limit",
      "description": "Pins the running trial includes in total (50); null when no trial cap applies. Starting the paid plan lifts it"
    },
    "trial_pins_used": {
      "type": "integer",
      "title": "Trial Pins Used",
      "description": "Pins published since the trial started, plus pins on their way",
      "default": 0
    },
    "current_period_start": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Current Period Start",
      "description": "Start of the current subscription period"
    },
    "current_period_end": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Current Period End",
      "description": "End of the current subscription period (next renewal)"
    },
    "subscription_cancel_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Subscription Cancel At",
      "description": "When a scheduled cancellation takes effect"
    },
    "scheduled_change": {
      "anyOf": [
        {
          "$ref": "#/$defs/ScheduledPlanChangeResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "A lower plan or shorter billing cycle that starts at the end of the paid period"
    },
    "quota_calls_monthly": {
      "type": "integer",
      "title": "Quota Calls Monthly",
      "description": "Successful pin publishes included per month"
    },
    "calls_used": {
      "type": "integer",
      "title": "Calls Used",
      "description": "Pins published successfully this month (calendar month, UTC)"
    },
    "quota_reset_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Quota Reset At",
      "description": "When `calls_used` resets: the start of next month (UTC)"
    },
    "credits_remaining": {
      "type": "integer",
      "title": "Credits Remaining",
      "description": "Prepaid credits left, spent one per pin once the quota is used up",
      "default": 0
    },
    "credits_enabled": {
      "type": "boolean",
      "title": "Credits Enabled",
      "description": "Whether this workspace spends credits after the quota",
      "default": false
    },
    "credits_purchase_allowed": {
      "type": "boolean",
      "title": "Credits Purchase Allowed",
      "description": "Whether this workspace can buy credit packs right now",
      "default": false
    },
    "quota_exhausted": {
      "type": "boolean",
      "title": "Quota Exhausted",
      "description": "True when `calls_used` has reached `quota_calls_monthly`",
      "default": false
    },
    "plan_consumption_percent": {
      "type": "integer",
      "title": "Plan Consumption Percent",
      "description": "`calls_used` as a percentage of the monthly quota, 0-100",
      "default": 0
    },
    "storage_quota_bytes": {
      "type": "integer",
      "title": "Storage Quota Bytes",
      "description": "Asset library storage limit",
      "default": 0
    },
    "storage_used_bytes": {
      "type": "integer",
      "title": "Storage Used Bytes",
      "description": "Asset library storage in use",
      "default": 0
    },
    "storage_used_percent": {
      "type": "integer",
      "title": "Storage Used Percent",
      "description": "`storage_used_bytes` as a percentage of the storage limit",
      "default": 0
    },
    "storage_warning": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Storage Warning",
      "description": "`80`, `95` or `100` once storage use crosses that percentage"
    },
    "pinterest_accounts_limit": {
      "type": "integer",
      "title": "Pinterest Accounts Limit",
      "description": "Connected Pinterest accounts allowed"
    },
    "uploaded_media_assets": {
      "type": "boolean",
      "title": "Uploaded Media Assets",
      "description": "Whether the plan includes asset uploads"
    },
    "image_uploads_monthly": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Image Uploads Monthly",
      "description": "Images a plan without asset uploads may still upload this month (5 on Playground); null when the plan has no monthly count"
    },
    "image_uploads_used": {
      "type": "integer",
      "title": "Image Uploads Used",
      "description": "Images uploaded this month against `image_uploads_monthly`",
      "default": 0
    },
    "bulk_imports": {
      "type": "boolean",
      "title": "Bulk Imports",
      "description": "Whether the plan includes bulk JSON and CSV imports"
    },
    "plan_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Plan Name",
      "description": "The plan's display name, e.g. `Agency` for `pro`"
    },
    "pinterest_accounts_used": {
      "type": "integer",
      "title": "Pinterest Accounts Used",
      "description": "Connected Pinterest accounts in use",
      "default": 0
    },
    "api_keys_limit": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Api Keys Limit",
      "description": "API keys allowed; null means unlimited"
    },
    "api_keys_used": {
      "type": "integer",
      "title": "Api Keys Used",
      "description": "Active API keys, not counting AI assistant connections",
      "default": 0
    },
    "assistant_requests_limit": {
      "type": "integer",
      "title": "Assistant Requests Limit",
      "description": "AI assistant (MCP) requests allowed per week; 0 means unlimited",
      "default": 0
    },
    "assistant_requests_used": {
      "type": "integer",
      "title": "Assistant Requests Used",
      "description": "AI assistant (MCP) requests used this week",
      "default": 0
    },
    "assistant_requests_reset_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Assistant Requests Reset At",
      "description": "When the weekly AI assistant request count resets"
    },
    "recommended_plan": {
      "anyOf": [
        {
          "$ref": "#/$defs/Plan"
        },
        {
          "type": "null"
        }
      ],
      "description": "The next self-serve plan up; null on the top self-serve plan"
    },
    "upgrade_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Upgrade Url",
      "description": "Pricing page link highlighting `recommended_plan`, or null"
    }
  },
  "type": "object",
  "required": [
    "plan",
    "billing_status",
    "quota_calls_monthly",
    "calls_used",
    "pinterest_accounts_limit",
    "uploaded_media_assets",
    "bulk_imports"
  ],
  "$defs": {
    "BillingCycle": {
      "type": "string",
      "enum": [
        "monthly",
        "annual"
      ],
      "title": "BillingCycle",
      "description": "Subscription billing frequency."
    },
    "BillingStatus": {
      "type": "string",
      "enum": [
        "active",
        "trialing",
        "past_due",
        "canceled",
        "unpaid"
      ],
      "title": "BillingStatus",
      "description": "Billing status from Stripe."
    },
    "Plan": {
      "type": "string",
      "enum": [
        "free",
        "starter",
        "growth",
        "pro",
        "enterprise"
      ],
      "title": "Plan",
      "description": "Subscription plan tiers."
    },
    "ScheduledPlanChangeResponse": {
      "properties": {
        "plan": {
          "$ref": "#/$defs/Plan"
        },
        "plan_name": {
          "type": "string",
          "title": "Plan Name"
        },
        "billing_cycle": {
          "$ref": "#/$defs/BillingCycle"
        },
        "effective_at": {
          "type": "string",
          "format": "date-time",
          "title": "Effective At"
        }
      },
      "type": "object",
      "required": [
        "plan",
        "plan_name",
        "billing_cycle",
        "effective_at"
      ],
      "title": "ScheduledPlanChangeResponse",
      "description": "A downgrade that takes effect at the end of the paid period."
    }
  }
}