{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/2x/json-schema/2x-portfolio-detail-response-schema.json",
  "title": "PortfolioDetailResponse",
  "description": "Detailed portfolio response with clients and health metrics.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/2x-portfolios-api-openapi.yml#/components/schemas/PortfolioDetailResponse",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id"
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "color": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Color"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description"
    },
    "customerId": {
      "type": "string",
      "title": "Customerid"
    },
    "clientCount": {
      "type": "integer",
      "title": "Clientcount",
      "description": "Number of clients in portfolio"
    },
    "userIds": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Userids",
      "description": "User IDs with access"
    },
    "isSystem": {
      "type": "boolean",
      "title": "Issystem",
      "description": "Whether this is a system portfolio",
      "default": false
    },
    "createdAt": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Createdat"
    },
    "updatedAt": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Updatedat"
    },
    "clients": {
      "items": {
        "$ref": "#/$defs/ClientResponse"
      },
      "type": "array",
      "title": "Clients"
    },
    "users": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/PortfolioUser"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Users"
    },
    "health": {
      "anyOf": [
        {
          "$ref": "#/$defs/PortfolioHealthResponse"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "id",
    "name",
    "customerId",
    "clientCount",
    "clients"
  ],
  "$defs": {
    "ClientMetadata": {
      "properties": {
        "accountOwner": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Accountowner"
        },
        "annualRevenue": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Annualrevenue"
        },
        "industry": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Industry"
        },
        "location": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Location"
        },
        "active": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Active"
        },
        "accountStatus": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Accountstatus"
        },
        "domain": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Domain"
        },
        "clientType": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Clienttype"
        },
        "revenueTTM": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Revenuettm"
        },
        "revenueF12M": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Revenuef12M"
        }
      },
      "type": "object",
      "title": "ClientMetadata",
      "description": "Client metadata."
    },
    "ClientResponse": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "customerId": {
          "type": "string",
          "title": "Customerid"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "score": {
          "type": "integer",
          "title": "Score"
        },
        "scoreSource": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Scoresource",
          "description": "Score data source: chr1 or chr2"
        },
        "scoreChanges": {
          "anyOf": [
            {
              "$ref": "#/$defs/ScoreChanges"
            },
            {
              "type": "null"
            }
          ],
          "description": "Score changes over time"
        },
        "lastContactDate": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Lastcontactdate"
        },
        "lastUpdatedAt": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Lastupdatedat"
        },
        "hasInsufficientData": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Hasinsufficientdata"
        },
        "metadata": {
          "anyOf": [
            {
              "$ref": "#/$defs/ClientMetadata"
            },
            {
              "type": "null"
            }
          ]
        },
        "extraColumns": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Extracolumns",
          "description": "Custom column values"
        },
        "historicalData": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Historicaldata"
        },
        "archived": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Archived"
        }
      },
      "type": "object",
      "required": [
        "id",
        "customerId",
        "name",
        "score"
      ],
      "title": "ClientResponse",
      "description": "Response model for client data."
    },
    "PortfolioHealthResponse": {
      "properties": {
        "score": {
          "type": "integer",
          "title": "Score"
        },
        "breakdown": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Breakdown"
        },
        "distribution": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Distribution"
        },
        "customerId": {
          "type": "string",
          "title": "Customerid"
        },
        "chr2CutoverDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Chr2Cutoverdate",
          "description": "CHR 2.0 cutover date if enabled"
        }
      },
      "type": "object",
      "required": [
        "score",
        "breakdown",
        "distribution",
        "customerId"
      ],
      "title": "PortfolioHealthResponse",
      "description": "Portfolio health metrics."
    },
    "PortfolioUser": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "displayName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Displayname"
        },
        "email": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Email"
        }
      },
      "type": "object",
      "required": [
        "id"
      ],
      "title": "PortfolioUser",
      "description": "User information for portfolio access."
    },
    "ScoreChange": {
      "properties": {
        "change": {
          "type": "number",
          "title": "Change",
          "description": "Absolute change in score"
        },
        "percentage": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Percentage",
          "description": "Percentage change"
        },
        "previousScore": {
          "type": "number",
          "title": "Previousscore",
          "description": "Score at start of period"
        }
      },
      "type": "object",
      "required": [
        "change",
        "previousScore"
      ],
      "title": "ScoreChange",
      "description": "Score change over a time period."
    },
    "ScoreChanges": {
      "properties": {
        "7day": {
          "anyOf": [
            {
              "$ref": "#/$defs/ScoreChange"
            },
            {
              "type": "null"
            }
          ],
          "description": "7-day change"
        },
        "30day": {
          "anyOf": [
            {
              "$ref": "#/$defs/ScoreChange"
            },
            {
              "type": "null"
            }
          ],
          "description": "30-day change"
        }
      },
      "type": "object",
      "title": "ScoreChanges",
      "description": "Score changes over different time periods."
    }
  }
}