{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dotsy-ai/json-schema/dotsy-ai-workspace-plan-view-schema.json",
  "title": "WorkspacePlanView",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dotsy-ai-account-api-openapi.yml#/components/schemas/WorkspacePlanView",
  "type": "object",
  "properties": {
    "workspaceId": {
      "type": "string"
    },
    "plan": {
      "type": "string",
      "enum": [
        "free",
        "core",
        "studio",
        "agency"
      ]
    },
    "freeSites": {
      "type": "object",
      "properties": {
        "used": {
          "type": "integer"
        },
        "max": {
          "type": "integer"
        },
        "base": {
          "type": "integer"
        },
        "perPaid": {
          "type": "integer"
        }
      },
      "required": [
        "used",
        "max",
        "base",
        "perPaid"
      ]
    },
    "paidSites": {
      "type": "integer",
      "description": "Sites in this workspace on the Pro plan."
    },
    "protectedSites": {
      "type": "integer",
      "description": "Sites in this workspace whose access is password."
    },
    "freeWorkspaces": {
      "type": "object",
      "properties": {
        "owned": {
          "type": "integer",
          "description": "Free workspaces this person owns. Invited memberships are not counted."
        },
        "limit": {
          "type": "integer"
        }
      },
      "required": [
        "owned",
        "limit"
      ]
    },
    "usage": {
      "type": "object",
      "properties": {
        "sites": {
          "$ref": "#/$defs/UsageMeter"
        },
        "domains": {
          "allOf": [
            {
              "$ref": "#/$defs/UsageMeter"
            },
            {
              "description": "Custom domains (a domain with its www counts once)."
            }
          ]
        },
        "abSites": {
          "allOf": [
            {
              "$ref": "#/$defs/UsageMeter"
            },
            {
              "description": "Sites running an A/B test without their own A/B add-on."
            }
          ]
        },
        "storage": {
          "allOf": [
            {
              "$ref": "#/$defs/UsageMeter"
            },
            {
              "description": "Bytes stored across the workspace's sites."
            }
          ]
        },
        "views": {
          "$ref": "#/$defs/WorkspaceViewsUsage"
        }
      },
      "required": [
        "sites",
        "domains",
        "abSites",
        "storage",
        "views"
      ],
      "description": "Pooled workspace usage. Present once workspace plans are switched on."
    },
    "warnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/WorkspaceUsageWarning"
      },
      "description": "One entry per pooled limit at 80 % or more (`plan_limit_reached` at 100 %)."
    },
    "addOns": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "siteDb",
              "abTest"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "admin",
              "stripe"
            ],
            "description": "`admin`: included by dotsy. `stripe`: paid."
          },
          "siteId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The site it is on. Null: a dotsy credit not placed on a site yet."
          }
        },
        "required": [
          "id",
          "kind",
          "source",
          "siteId"
        ]
      },
      "description": "Active site add-ons in the workspace. Present once workspace plans are switched on."
    }
  },
  "required": [
    "workspaceId",
    "plan",
    "freeSites",
    "paidSites",
    "protectedSites",
    "freeWorkspaces"
  ],
  "$defs": {
    "UsageMeter": {
      "type": "object",
      "properties": {
        "used": {
          "type": "integer"
        },
        "max": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The workspace's cap; null = no cap."
        },
        "pct": {
          "type": "integer",
          "description": "Whole percent of `max` (0 when there is no cap)."
        }
      },
      "required": [
        "used",
        "max",
        "pct"
      ],
      "description": "Every site in the workspace, drafts included."
    },
    "WorkspaceUsageWarning": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "plan_limit_near",
            "plan_limit_reached"
          ]
        },
        "limit": {
          "type": "string",
          "enum": [
            "sites",
            "domains",
            "abSites",
            "storage",
            "views"
          ]
        },
        "used": {
          "type": "integer"
        },
        "max": {
          "type": "integer"
        },
        "pct": {
          "type": "integer"
        }
      },
      "required": [
        "code",
        "limit",
        "used",
        "max",
        "pct"
      ]
    },
    "WorkspaceViewsUsage": {
      "type": "object",
      "properties": {
        "used": {
          "type": "integer",
          "description": "Human page views this month (UTC), from the nightly frozen analytics."
        },
        "max": {
          "type": [
            "integer",
            "null"
          ]
        },
        "pct": {
          "type": "integer"
        },
        "state": {
          "type": "string",
          "enum": [
            "ok",
            "near",
            "over"
          ],
          "description": "`near` from 80 %, `over` from 100 %. A soft limit: sites keep serving either way."
        },
        "periodStart": {
          "type": "string",
          "description": "First day of the month the count covers (YYYY-MM-DD)."
        },
        "overSince": {
          "type": [
            "string",
            "null"
          ],
          "description": "When this month's count first passed 100 %."
        },
        "spendLimit": {
          "type": "string",
          "enum": [
            "ask",
            "badge"
          ],
          "description": "`ask` (default): extra views on a paid plan are billed. `badge`: extra views are not billed and the sites show the dotsy badge until next month, an upgrade, or the limit is turned off."
        },
        "badge": {
          "type": "boolean",
          "description": "The spend limit is hit and the dotsy badge is on for every site."
        }
      },
      "required": [
        "used",
        "max",
        "pct",
        "state",
        "periodStart",
        "overSince",
        "spendLimit",
        "badge"
      ]
    }
  }
}