{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-contact-group-member-page-schema.json",
  "title": "ContactGroupMemberPage",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/samva-dev-contact-groups-api-openapi.yml#/components/schemas/ContactGroupMemberPage",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "organizationId": {
            "$ref": "#/$defs/OrganizationId"
          },
          "groupId": {
            "$ref": "#/$defs/ContactGroupId"
          },
          "contactId": {
            "$ref": "#/$defs/ContactId"
          },
          "role": {
            "type": "string",
            "enum": [
              "member",
              "moderator",
              "admin"
            ]
          },
          "joinedAt": {
            "type": "string"
          },
          "joinedBy": {
            "anyOf": [
              {
                "$ref": "#/$defs/ContactId"
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contact": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "$ref": "#/$defs/ContactId"
                  },
                  "name": {
                    "type": "string"
                  },
                  "displayName": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "type": {
                    "type": "string"
                  },
                  "identities": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "$ref": "#/$defs/ContactIdentity"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "id",
                  "name",
                  "displayName",
                  "type"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "organizationId",
          "groupId",
          "contactId",
          "role",
          "joinedAt",
          "joinedBy",
          "expiresAt",
          "contact"
        ],
        "additionalProperties": false
      }
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "items",
    "nextCursor"
  ],
  "additionalProperties": false,
  "$defs": {
    "ContactConsent": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "opted_in",
            "opted_out"
          ]
        },
        "source": {
          "type": "string"
        },
        "capturedAt": {
          "type": "string"
        },
        "proof": {
          "anyOf": [
            {
              "$ref": "#/$defs/JsonObject"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "status",
        "source",
        "capturedAt",
        "proof"
      ],
      "additionalProperties": false
    },
    "ContactGroupId": {
      "type": "string",
      "pattern": "^cgrp_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ContactGroupId"
    },
    "ContactId": {
      "type": "string",
      "pattern": "^contact_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ContactId"
    },
    "ContactIdentity": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/ContactIdentityId"
        },
        "type": {
          "type": "string",
          "enum": [
            "email",
            "phone"
          ]
        },
        "identifier": {
          "type": "string"
        },
        "verified": {
          "type": "boolean"
        },
        "channels": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ContactIdentityChannel"
          }
        }
      },
      "required": [
        "id",
        "type",
        "identifier",
        "verified",
        "channels"
      ],
      "additionalProperties": false
    },
    "ContactIdentityChannel": {
      "type": "object",
      "properties": {
        "channel": {
          "type": "string",
          "enum": [
            "email"
          ]
        },
        "reachability": {
          "type": "string",
          "enum": [
            "unknown",
            "reachable",
            "unreachable"
          ]
        },
        "consent": {
          "anyOf": [
            {
              "$ref": "#/$defs/ContactConsent"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "channel",
        "reachability",
        "consent"
      ],
      "additionalProperties": false
    },
    "ContactIdentityId": {
      "type": "string",
      "pattern": "^cident_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ContactIdentityId"
    },
    "JsonObject": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      }
    },
    "JsonValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/JsonValue"
          }
        },
        {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          }
        }
      ]
    },
    "OrganizationId": {
      "type": "string",
      "pattern": "^org_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "OrganizationId"
    }
  }
}