{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elhub/json-schema/elhub-service-provider-product-application-response-schema.json",
  "title": "service_provider_product_application_response",
  "description": "Response schema - Relation between a service provider and a system operator, for the SP to apply for delivering the SO some of the types of product they want to buy on a flexibility market.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elhub-service-provider-product-application-api-openapi.yml#/components/schemas/service_provider_product_application_response",
  "summary": "Response - Service Provider Product Application",
  "type": "object",
  "properties": {
    "id": {
      "description": "Unique surrogate identifier.",
      "format": "bigint",
      "type": "integer",
      "readOnly": true
    },
    "service_provider_id": {
      "description": "Reference to the service provider.",
      "format": "bigint",
      "type": "integer"
    },
    "system_operator_id": {
      "description": "Reference to the system operator.",
      "format": "bigint",
      "type": "integer"
    },
    "product_type_ids": {
      "description": "References to the product types.",
      "type": "array",
      "items": {
        "format": "bigint",
        "type": "integer"
      }
    },
    "status": {
      "$ref": "#/$defs/service_provider_product_application_status",
      "default": "requested"
    },
    "qualified_at": {
      "description": "When the product application was last validated.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "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
    },
    "service_provider": {
      "description": "Embedded party",
      "oneOf": [
        {
          "$ref": "#/$defs/party_response"
        },
        {
          "type": "null"
        }
      ],
      "nullable": true
    },
    "system_operator": {
      "description": "Embedded party",
      "oneOf": [
        {
          "$ref": "#/$defs/party_response"
        },
        {
          "type": "null"
        }
      ],
      "nullable": true
    },
    "comment": {
      "description": "Embedded service_provider_product_application_comment",
      "oneOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/service_provider_product_application_comment_response"
          }
        },
        {
          "type": "null"
        }
      ],
      "nullable": true
    }
  },
  "required": [
    "id",
    "service_provider_id",
    "system_operator_id",
    "product_type_ids",
    "status",
    "recorded_at",
    "recorded_by"
  ],
  "$defs": {
    "auth_scope": {
      "description": "Authorization scopes.",
      "format": "text",
      "type": "string",
      "enum": [
        "manage:attachment",
        "manage:attachment:service_providing_group_product_application_attachment",
        "manage:auth",
        "manage:data",
        "manage:data:accounting_point_grid_location",
        "manage:data:controllable_unit",
        "manage:data:controllable_unit_service_provider",
        "manage:data:controllable_unit_suspension",
        "manage:data:controllable_unit_suspension_comment",
        "manage:data:entity",
        "manage:data:entity_client",
        "manage:data:notification",
        "manage:data:party",
        "manage:data:party_membership",
        "manage:data:service_provider_product_application",
        "manage:data:service_provider_product_application_comment",
        "manage:data:service_provider_product_suspension",
        "manage:data:service_provider_product_suspension_comment",
        "manage:data:service_providing_group",
        "manage:data:service_providing_group_grid_prequalification",
        "manage:data:service_providing_group_grid_prequalification_comment",
        "manage:data:service_providing_group_grid_suspension",
        "manage:data:service_providing_group_grid_suspension_comment",
        "manage:data:service_providing_group_membership",
        "manage:data:service_providing_group_product_application",
        "manage:data:service_providing_group_product_application_comment",
        "manage:data:service_providing_group_product_suspension",
        "manage:data:service_providing_group_product_suspension_comment",
        "manage:data:system_operator_product_type",
        "manage:data:technical_resource",
        "read:attachment",
        "read:attachment:service_providing_group_product_application_attachment",
        "read:attachment:service_providing_group_product_application_attachment_history",
        "read:auth",
        "read:data",
        "read:data:accounting_point",
        "read:data:accounting_point_balance_responsible_party",
        "read:data:accounting_point_bidding_zone",
        "read:data:accounting_point_end_user",
        "read:data:accounting_point_energy_supplier",
        "read:data:accounting_point_grid_location",
        "read:data:accounting_point_grid_location_history",
        "read:data:accounting_point_metering_grid_area",
        "read:data:controllable_unit",
        "read:data:controllable_unit_history",
        "read:data:controllable_unit_service_provider",
        "read:data:controllable_unit_service_provider_history",
        "read:data:controllable_unit_summary",
        "read:data:controllable_unit_suspension",
        "read:data:controllable_unit_suspension_comment",
        "read:data:controllable_unit_suspension_comment_history",
        "read:data:controllable_unit_suspension_history",
        "read:data:entity",
        "read:data:entity_client",
        "read:data:event",
        "read:data:identity",
        "read:data:metering_grid_area",
        "read:data:notice",
        "read:data:notification",
        "read:data:party",
        "read:data:party_history",
        "read:data:party_membership",
        "read:data:party_membership_history",
        "read:data:product_type",
        "read:data:service_provider_product_application",
        "read:data:service_provider_product_application_comment",
        "read:data:service_provider_product_application_comment_history",
        "read:data:service_provider_product_application_history",
        "read:data:service_provider_product_suspension",
        "read:data:service_provider_product_suspension_comment",
        "read:data:service_provider_product_suspension_comment_history",
        "read:data:service_provider_product_suspension_history",
        "read:data:service_providing_group",
        "read:data:service_providing_group_grid_prequalification",
        "read:data:service_providing_group_grid_prequalification_comment",
        "read:data:service_providing_group_grid_prequalification_comment_history",
        "read:data:service_providing_group_grid_prequalification_history",
        "read:data:service_providing_group_grid_suspension",
        "read:data:service_providing_group_grid_suspension_comment",
        "read:data:service_providing_group_grid_suspension_comment_history",
        "read:data:service_providing_group_grid_suspension_history",
        "read:data:service_providing_group_history",
        "read:data:service_providing_group_membership",
        "read:data:service_providing_group_membership_history",
        "read:data:service_providing_group_power_per_substation",
        "read:data:service_providing_group_product_application",
        "read:data:service_providing_group_product_application_comment",
        "read:data:service_providing_group_product_application_comment_history",
        "read:data:service_providing_group_product_application_history",
        "read:data:service_providing_group_product_suspension",
        "read:data:service_providing_group_product_suspension_comment",
        "read:data:service_providing_group_product_suspension_comment_history",
        "read:data:service_providing_group_product_suspension_history",
        "read:data:service_providing_group_summary",
        "read:data:system_operator_product_type",
        "read:data:system_operator_product_type_history",
        "read:data:technical_resource",
        "read:data:technical_resource_history",
        "read:grid",
        "read:grid:line",
        "read:grid:substation",
        "read:grid:substation_cluster",
        "use:auth",
        "use:data",
        "use:data:controllable_unit",
        "use:data:controllable_unit:lookup",
        "use:data:entity",
        "use:data:entity:lookup"
      ]
    },
    "entity_business_id_type": {
      "description": "The type of the business identifier.",
      "format": "text",
      "type": "string",
      "enum": [
        "pid",
        "org",
        "email"
      ]
    },
    "entity_client_response": {
      "summary": "Response - Entity client",
      "description": "Response schema - Client linked to an entity for client credentials and JWT grant authentication methods.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "entity_id": {
          "description": "Reference to the entity that this client is attached to.",
          "format": "bigint",
          "type": "integer"
        },
        "name": {
          "description": "Name of the client.",
          "format": "text",
          "type": [
            "string",
            "null"
          ],
          "maxLength": 256
        },
        "client_id": {
          "description": "The identifier of the entity. For use with client credentials authentication method.",
          "format": "text",
          "type": "string",
          "readOnly": true
        },
        "party_id": {
          "description": "Reference to the party this client allows to assume. A null value means the client cannot assume any party.",
          "format": "bigint",
          "type": [
            "integer",
            "null"
          ]
        },
        "scopes": {
          "description": "List of scopes granted to the user when it logs in as an entity or when it acts as the party. When assuming a party through party membership, the least privileged set of scopes will be kept.\nScopes are inspired from OAuth 2.0 and allow refinement of access control and privilege delegation mechanisms.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/auth_scope"
          },
          "nullable": false
        },
        "client_secret": {
          "description": "The secret of the entity. For use with client credentials authentication method. Input as plain text but stored encrypted.",
          "format": "text",
          "type": [
            "string",
            "null"
          ],
          "minLength": 12
        },
        "public_key": {
          "description": "The public key of the entity (X.509 SubjectPublicKeyInfo). For use with JWT grant authentication method.",
          "format": "text",
          "type": [
            "string",
            "null"
          ],
          "pattern": "^-----BEGIN PUBLIC KEY-----\\nMIIB[-A-Za-z0-9+/\\n]*={0,3}\\n-----END PUBLIC KEY-----$"
        },
        "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
        },
        "entity": {
          "description": "Embedded entity",
          "oneOf": [
            {
              "$ref": "#/$defs/entity_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "party": {
          "description": "Embedded party",
          "oneOf": [
            {
              "$ref": "#/$defs/party_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "entity_id",
        "client_id",
        "scopes",
        "recorded_at",
        "recorded_by"
      ]
    },
    "entity_response": {
      "summary": "Response - Entity",
      "description": "Response schema - Entity - Natural or legal person\n\nAn entity is a natural or legal person that can be a party in the Flexibility Information System.\n\nExample entity types:\n\n* Person\n* Organisation",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.\n\nNote:\nThis is a Primary Key.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "business_id": {
          "description": "The business identifier of the entity. Format depends on `business_id_type`.",
          "format": "text",
          "type": "string"
        },
        "business_id_type": {
          "$ref": "#/$defs/entity_business_id_type"
        },
        "name": {
          "description": "Name of the entity. Maximum 128 characters.",
          "format": "text",
          "type": "string"
        },
        "type": {
          "$ref": "#/$defs/entity_type"
        },
        "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
        },
        "client": {
          "description": "Embedded entity_client",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/entity_client_response"
              }
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "party": {
          "description": "Embedded party",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/party_response"
              }
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "party_membership": {
          "description": "Embedded party_membership",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/party_membership_response"
              }
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "identity": {
          "description": "Embedded identity",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/identity_response"
              }
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "business_id",
        "business_id_type",
        "name",
        "type",
        "recorded_at",
        "recorded_by"
      ]
    },
    "entity_type": {
      "description": "The type of the entity, e.g Person, Organisation",
      "format": "text",
      "type": "string",
      "enum": [
        "person",
        "organisation"
      ]
    },
    "identity_response": {
      "summary": "Response - Identity",
      "description": "Response schema - Resource uniquely identifying a user by linking its entity and the potentially assumed party.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "entity_id": {
          "description": "Reference to the entity using the identity.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "entity_name": {
          "description": "Name of the entity using the identity.",
          "format": "text",
          "type": "string",
          "readOnly": true
        },
        "party_id": {
          "description": "Reference to the party assumed by the entity.",
          "format": "bigint",
          "type": [
            "integer",
            "null"
          ],
          "readOnly": true
        },
        "party_name": {
          "description": "Name of the party assumed by the entity.",
          "format": "text",
          "type": [
            "string",
            "null"
          ],
          "readOnly": true
        },
        "entity": {
          "description": "Embedded entity",
          "oneOf": [
            {
              "$ref": "#/$defs/entity_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "party": {
          "description": "Embedded party",
          "oneOf": [
            {
              "$ref": "#/$defs/party_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "entity_id",
        "entity_name"
      ]
    },
    "party_business_id_type": {
      "description": "The type of the business identifier.",
      "format": "text",
      "type": "string",
      "default": "uuid",
      "enum": [
        "gln",
        "uuid",
        "eic_x",
        "org"
      ]
    },
    "party_membership_response": {
      "summary": "Response - Party Membership",
      "description": "Response schema - The relation between a party and entity.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "party_id": {
          "description": "Reference to the party that the membership links to an entity.",
          "format": "bigint",
          "type": "integer"
        },
        "entity_id": {
          "description": "Reference to the entity that the party represents.",
          "format": "bigint",
          "type": "integer"
        },
        "scopes": {
          "description": "List of scopes granted to the entity when it acts as the party. Scopes are inspired from OAuth 2.0 and allow refinement of access control and privilege delegation mechanisms.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/auth_scope"
          },
          "nullable": false
        },
        "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": {
          "description": "Embedded party",
          "oneOf": [
            {
              "$ref": "#/$defs/party_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "entity": {
          "description": "Embedded entity",
          "oneOf": [
            {
              "$ref": "#/$defs/entity_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "party_id",
        "entity_id",
        "scopes",
        "recorded_at",
        "recorded_by"
      ]
    },
    "party_response": {
      "summary": "Response - Party",
      "description": "Response schema - The body that interacts with the Flexibility Information System\n\nA party is the thing that is authorized to access or modify data in the Flexiblity Information System.\n\nExample party types:\n\n* Service Provider\n* System Operator\n* End User",
      "type": "object",
      "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
        },
        "entity": {
          "description": "Embedded entity",
          "oneOf": [
            {
              "$ref": "#/$defs/entity_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "business_id",
        "business_id_type",
        "entity_id",
        "name",
        "role",
        "type",
        "status",
        "recorded_at",
        "recorded_by"
      ]
    },
    "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"
      ]
    },
    "service_provider_product_application_comment_response": {
      "summary": "Response - Service Provider Product Application Comment",
      "description": "Response schema - Comment made by a party involved in a service provider product application.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "service_provider_product_application_id": {
          "description": "Reference to the service provider product application.",
          "format": "bigint",
          "type": "integer"
        },
        "created_by": {
          "description": "Reference to the identity that created the comment.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "created_at": {
          "description": "When the comment was added to the SPPA.",
          "format": "date-time",
          "type": "string",
          "readOnly": true
        },
        "visibility": {
          "$ref": "#/$defs/service_provider_product_application_comment_visibility",
          "default": "same_party"
        },
        "content": {
          "description": "Free text content of the comment.",
          "format": "text",
          "type": "string",
          "maxLength": 2048
        },
        "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
        },
        "service_provider_product_application": {
          "description": "Embedded service_provider_product_application",
          "oneOf": [
            {
              "$ref": "#/$defs/service_provider_product_application_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "service_provider_product_application_id",
        "created_by",
        "created_at",
        "visibility",
        "content",
        "recorded_at",
        "recorded_by"
      ]
    },
    "service_provider_product_application_comment_visibility": {
      "description": "The level of visibility of the comment.",
      "format": "text",
      "type": "string",
      "default": "same_party",
      "enum": [
        "same_party",
        "any_involved_party"
      ]
    },
    "service_provider_product_application_response": {
      "summary": "Response - Service Provider Product Application",
      "description": "Response schema - Relation between a service provider and a system operator, for the SP to apply for delivering the SO some of the types of product they want to buy on a flexibility market.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Unique surrogate identifier.",
          "format": "bigint",
          "type": "integer",
          "readOnly": true
        },
        "service_provider_id": {
          "description": "Reference to the service provider.",
          "format": "bigint",
          "type": "integer"
        },
        "system_operator_id": {
          "description": "Reference to the system operator.",
          "format": "bigint",
          "type": "integer"
        },
        "product_type_ids": {
          "description": "References to the product types.",
          "type": "array",
          "items": {
            "format": "bigint",
            "type": "integer"
          }
        },
        "status": {
          "$ref": "#/$defs/service_provider_product_application_status",
          "default": "requested"
        },
        "qualified_at": {
          "description": "When the product application was last validated.",
          "format": "date-time",
          "type": [
            "string",
            "null"
          ]
        },
        "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
        },
        "service_provider": {
          "description": "Embedded party",
          "oneOf": [
            {
              "$ref": "#/$defs/party_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "system_operator": {
          "description": "Embedded party",
          "oneOf": [
            {
              "$ref": "#/$defs/party_response"
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        },
        "comment": {
          "description": "Embedded service_provider_product_application_comment",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/service_provider_product_application_comment_response"
              }
            },
            {
              "type": "null"
            }
          ],
          "nullable": true
        }
      },
      "required": [
        "id",
        "service_provider_id",
        "system_operator_id",
        "product_type_ids",
        "status",
        "recorded_at",
        "recorded_by"
      ]
    },
    "service_provider_product_application_status": {
      "description": "The status of the application.",
      "format": "text",
      "type": "string",
      "default": "requested",
      "enum": [
        "requested",
        "in_progress",
        "communication_test",
        "not_qualified",
        "qualified"
      ]
    }
  }
}