{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elhub/json-schema/elhub-party-history-response-schema.json",
  "title": "party_history_response",
  "description": "Party - history",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elhub-party-api-openapi.yml#/components/schemas/party_history_response",
  "summary": "Party - history",
  "properties": {
    "id": {
      "description": "Unique surrogate identifier.",
      "format": "bigint",
      "type": "integer",
      "readOnly": true
    },
    "business_id": {
      "description": "The business identifier of the party. Format depends on `business_id_type`.",
      "format": "text",
      "type": "string"
    },
    "business_id_type": {
      "$ref": "#/$defs/party_business_id_type",
      "default": "uuid"
    },
    "entity_id": {
      "description": "Reference to the entity that is the parent of the party.",
      "format": "bigint",
      "type": "integer"
    },
    "name": {
      "description": "Name of the party. Maximum 128 characters.",
      "format": "text",
      "type": "string"
    },
    "role": {
      "$ref": "#/$defs/party_role"
    },
    "type": {
      "$ref": "#/$defs/party_type"
    },
    "status": {
      "$ref": "#/$defs/party_status",
      "default": "new"
    },
    "recorded_at": {
      "description": "When the resource was recorded (created or updated) in the system.",
      "format": "date-time",
      "type": "string",
      "readOnly": true
    },
    "recorded_by": {
      "description": "The identity that recorded the resource.",
      "format": "bigint",
      "type": "integer",
      "readOnly": true
    },
    "party_id": {
      "description": "Reference to the resource that was updated.",
      "format": "bigint",
      "type": "integer"
    },
    "replaced_by": {
      "description": "The identity that updated the resource when it was replaced.",
      "format": "bigint",
      "type": [
        "integer",
        "null"
      ]
    },
    "replaced_at": {
      "description": "When the resource was replaced in the system.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "business_id",
    "business_id_type",
    "entity_id",
    "name",
    "role",
    "type",
    "status",
    "recorded_at",
    "recorded_by",
    "party_id"
  ],
  "$defs": {
    "party_business_id_type": {
      "description": "The type of the business identifier.",
      "format": "text",
      "type": "string",
      "default": "uuid",
      "enum": [
        "gln",
        "uuid",
        "eic_x",
        "org"
      ]
    },
    "party_role": {
      "description": "The role of the party. Currently maps to 1:1 to `type`. E.g. system_operator, service_provider.",
      "format": "text",
      "type": "string",
      "enum": [
        "flex_balance_responsible_party",
        "flex_end_user",
        "flex_energy_supplier",
        "flex_flexibility_information_system_operator",
        "flex_market_operator",
        "flex_organisation",
        "flex_service_provider",
        "flex_system_operator",
        "flex_third_party"
      ]
    },
    "party_status": {
      "description": "The status of the party.",
      "format": "text",
      "type": "string",
      "default": "new",
      "enum": [
        "new",
        "active",
        "inactive",
        "suspended",
        "terminated"
      ]
    },
    "party_type": {
      "description": "The type of the party, e.g SystemOperator, ServiceProvider",
      "format": "text",
      "type": "string",
      "enum": [
        "balance_responsible_party",
        "end_user",
        "energy_supplier",
        "flexibility_information_system_operator",
        "market_operator",
        "organisation",
        "service_provider",
        "system_operator",
        "third_party"
      ]
    }
  }
}