{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/nudg3-ai/json-schema/nudg3-ai-workspace-detail-response-schema.json",
  "title": "WorkspaceDetailResponse",
  "description": "Detailed workspace response with all related entities.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nudg3-ai-openapi.json#/components/schemas/WorkspaceDetailResponse",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "company_id": {
      "type": "string",
      "format": "uuid",
      "title": "Company Id"
    },
    "company_name": {
      "type": "string",
      "title": "Company Name"
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "brand_name": {
      "type": "string",
      "title": "Brand Name"
    },
    "brand_domain": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Brand Domain"
    },
    "brand_keywords": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Brand Keywords"
    },
    "primary_brand_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Primary Brand Id",
      "description": "Foreign key to primary brand in brands table"
    },
    "onboarded": {
      "type": "boolean",
      "title": "Onboarded",
      "description": "Whether workspace has completed onboarding",
      "default": false
    },
    "onboarded_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Onboarded At",
      "description": "When onboarding was completed"
    },
    "is_active": {
      "type": "boolean",
      "title": "Is Active"
    },
    "provider_configs": {
      "additionalProperties": true,
      "type": "object",
      "title": "Provider Configs",
      "description": "Provider configuration settings"
    },
    "max_prompts": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Prompts",
      "description": "DEPRECATED: Use unified quota system",
      "deprecated": true
    },
    "settings": {
      "additionalProperties": true,
      "type": "object",
      "title": "Settings",
      "description": "Workspace settings"
    },
    "default_location_country": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Default Location Country"
    },
    "default_location_city": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Default Location City"
    },
    "default_location_region": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Default Location Region"
    },
    "agency_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agency Id"
    },
    "agency_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agency Name"
    },
    "brands_count": {
      "type": "integer",
      "title": "Brands Count",
      "description": "Number of brands/competitors tracked",
      "default": 0
    },
    "competitors_count": {
      "type": "integer",
      "title": "Competitors Count",
      "description": "Alias for brands_count for frontend consistency",
      "default": 0
    },
    "collection_runs_count": {
      "type": "integer",
      "title": "Collection Runs Count",
      "description": "Total collection runs for this workspace",
      "default": 0
    },
    "recent_collections_count": {
      "type": "integer",
      "title": "Recent Collections Count",
      "description": "Collection runs in last 30 days",
      "default": 0
    },
    "last_collection_run": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Collection Run"
    },
    "prompts_in_use": {
      "type": "integer",
      "title": "Prompts In Use",
      "description": "Number of active prompts in this workspace",
      "default": 0
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At"
    },
    "brands": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Brands",
      "description": "Brands/competitors in this workspace"
    },
    "users_with_access": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Users With Access",
      "description": "Users with access to this workspace"
    },
    "recent_collection_runs": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Recent Collection Runs",
      "description": "Recent collection runs"
    },
    "cost_metrics": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cost Metrics",
      "description": "Cost metrics for this workspace"
    }
  },
  "type": "object",
  "required": [
    "id",
    "company_id",
    "company_name",
    "name",
    "brand_name",
    "is_active",
    "created_at",
    "updated_at"
  ]
}