{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "Shurah Multi-Tenant Deliberation & Knowledge API",
    "version": "2026.11.10",
    "summary": "100% PostgreSQL Row-Level Security (RLS) REST & RPC API for shurah.org and demo.shurah.org.",
    "description": "Autogenerated OpenAPI 3.1.0 specification for Shurah's isolated PostgreSQL tenant schemas (`shurah` for production https://shurah.org and `demo` for https://demo.shurah.org). Supports scoped `shurah_pat_...` Personal & Bot API tokens (`x-shurah-token`), browser/pairing sessions (`x-shurah-session`), and FIDO2/TOTP AAL2 step-up enforcement directly inside PostgreSQL RLS."
  },
  "servers": [
    {
      "url": "https://edokahtgjajicrnmnoar.supabase.co/rest/v1",
      "description": "Supabase EU-North-1 (Stockholm) PostgREST Gateway"
    }
  ],
  "tags": [
    {
      "name": "RPC",
      "description": "Typed PostgreSQL RPC functions (`/rest/v1/rpc/*`)."
    },
    {
      "name": "Tables",
      "description": "RLS-protected tenant tables (`/rest/v1/*`)."
    },
    {
      "name": "Views",
      "description": "Security-invoker tenant views (`WITH (security_invoker = true)`)."
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "ApiKeyAuth": [],
      "ShurahPatAuth": []
    },
    {
      "ApiKeyAuth": [],
      "ShurahSessionAuth": []
    },
    {
      "ApiKeyAuth": [],
      "BearerJwtAuth": []
    }
  ],
  "paths": {
    "/organizations": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_organizations",
        "summary": "Query organizations",
        "description": "Community organizations inside a Shurah tenant.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `organizations` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Organizations"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_organizations",
        "summary": "Insert into organizations",
        "description": "Insert one or more rows into `organizations` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Organizations"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `organizations` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Organizations"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_organizations",
        "summary": "Update organizations",
        "description": "Update matching rows in `organizations` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Organizations"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `organizations` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Organizations"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/organization_members": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_organization_members",
        "summary": "Query organization_members",
        "description": "Organization membership roles, approval status, and topic privileges.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `organization_members` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationMembers"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_organization_members",
        "summary": "Insert into organization_members",
        "description": "Insert one or more rows into `organization_members` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationMembers"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `organization_members` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationMembers"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_organization_members",
        "summary": "Update organization_members",
        "description": "Update matching rows in `organization_members` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationMembers"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `organization_members` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrganizationMembers"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/org_join_messages": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_org_join_messages",
        "summary": "Query org_join_messages",
        "description": "Applicant-to-admin onboarding conversation messages.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `org_join_messages` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrgJoinMessages"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_org_join_messages",
        "summary": "Insert into org_join_messages",
        "description": "Insert one or more rows into `org_join_messages` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrgJoinMessages"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `org_join_messages` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrgJoinMessages"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/members": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_members",
        "summary": "Query members",
        "description": "Tenant member profiles (strictly column-restricted; zero PII or password hashes exposed).",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `members` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Members"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_members",
        "summary": "Update members",
        "description": "Update matching rows in `members` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Members"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `members` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Members"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/channels": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_channels",
        "summary": "Query channels",
        "description": "Deliberation channels with public_read, welcome_open, active_members, board_only, or private access.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `channels` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Channels"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_channels",
        "summary": "Insert into channels",
        "description": "Insert one or more rows into `channels` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Channels"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `channels` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Channels"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_channels",
        "summary": "Update channels",
        "description": "Update matching rows in `channels` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Channels"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `channels` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Channels"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_channels",
        "summary": "Delete from channels",
        "description": "Delete matching rows from `channels` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/channel_members": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_channel_members",
        "summary": "Query channel_members",
        "description": "Explicit channel memberships for open and private channels.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `channel_members` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChannelMembers"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_channel_members",
        "summary": "Insert into channel_members",
        "description": "Insert one or more rows into `channel_members` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChannelMembers"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `channel_members` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChannelMembers"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/channel_managers": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_channel_managers",
        "summary": "Query channel_managers",
        "description": "Designated channel stewards authorized to reorganize topics and curate Wiki articles.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `channel_managers` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChannelManagers"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_channel_managers",
        "summary": "Insert into channel_managers",
        "description": "Insert one or more rows into `channel_managers` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChannelManagers"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `channel_managers` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChannelManagers"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_channel_managers",
        "summary": "Delete from channel_managers",
        "description": "Delete matching rows from `channel_managers` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/topics": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_topics",
        "summary": "Query topics",
        "description": "Structured discussion threads, live chat streams, and synthesized Wiki articles.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `topics` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Topics"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_topics",
        "summary": "Insert into topics",
        "description": "Insert one or more rows into `topics` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Topics"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `topics` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Topics"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_topics",
        "summary": "Update topics",
        "description": "Update matching rows in `topics` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Topics"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `topics` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Topics"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_topics",
        "summary": "Delete from topics",
        "description": "Delete matching rows from `topics` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/messages": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_messages",
        "summary": "Query messages",
        "description": "Deliberation messages and automated bot messages within a topic.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `messages` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Messages"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_messages",
        "summary": "Insert into messages",
        "description": "Insert one or more rows into `messages` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Messages"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `messages` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Messages"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_messages",
        "summary": "Update messages",
        "description": "Update matching rows in `messages` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Messages"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `messages` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Messages"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_messages",
        "summary": "Delete from messages",
        "description": "Delete matching rows from `messages` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/wiki_revisions": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_wiki_revisions",
        "summary": "Query wiki_revisions",
        "description": "Versioned revisions of living knowledge-base Wiki articles.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `wiki_revisions` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WikiRevisions"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_wiki_revisions",
        "summary": "Insert into wiki_revisions",
        "description": "Insert one or more rows into `wiki_revisions` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WikiRevisions"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `wiki_revisions` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WikiRevisions"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/wiki_sources": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_wiki_sources",
        "summary": "Query wiki_sources",
        "description": "Provenance links connecting synthesized Wiki articles to source channel messages.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `wiki_sources` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WikiSources"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/polls": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_polls",
        "summary": "Query polls",
        "description": "Structured community polls attached to channels.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `polls` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Polls"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_polls",
        "summary": "Insert into polls",
        "description": "Insert one or more rows into `polls` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Polls"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `polls` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Polls"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/poll_votes": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_poll_votes",
        "summary": "Query poll_votes",
        "description": "One-member-one-vote poll ballot records enforced in PostgreSQL.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `poll_votes` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PollVotes"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_poll_votes",
        "summary": "Insert into poll_votes",
        "description": "Insert one or more rows into `poll_votes` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PollVotes"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `poll_votes` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PollVotes"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dm_threads": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_dm_threads",
        "summary": "Query dm_threads",
        "description": "1:1 Direct Message threads visible strictly to participants.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `dm_threads` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DmThreads"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dm_participants": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_dm_participants",
        "summary": "Query dm_participants",
        "description": "Participant bindings for 1:1 Direct Message threads.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `dm_participants` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DmParticipants"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/dm_messages": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_dm_messages",
        "summary": "Query dm_messages",
        "description": "Participant-isolated 1:1 Direct Messages.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `dm_messages` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DmMessages"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_dm_messages",
        "summary": "Insert into dm_messages",
        "description": "Insert one or more rows into `dm_messages` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DmMessages"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `dm_messages` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DmMessages"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/member_blocks": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_member_blocks",
        "summary": "Query member_blocks",
        "description": "Personal member block list filtering channel and DM visibility.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `member_blocks` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MemberBlocks"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_member_blocks",
        "summary": "Insert into member_blocks",
        "description": "Insert one or more rows into `member_blocks` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberBlocks"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `member_blocks` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MemberBlocks"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_member_blocks",
        "summary": "Delete from member_blocks",
        "description": "Delete matching rows from `member_blocks` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/moderation_reports": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_moderation_reports",
        "summary": "Query moderation_reports",
        "description": "Moderation and ban reports reviewed by organization moderators and admins.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `moderation_reports` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ModerationReports"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_moderation_reports",
        "summary": "Insert into moderation_reports",
        "description": "Insert one or more rows into `moderation_reports` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModerationReports"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `moderation_reports` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ModerationReports"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_moderation_reports",
        "summary": "Update moderation_reports",
        "description": "Update matching rows in `moderation_reports` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ModerationReports"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `moderation_reports` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ModerationReports"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/message_attachments": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_message_attachments",
        "summary": "Query message_attachments",
        "description": "Client-side AES-256-GCM encrypted attachment metadata linked to Supabase Storage.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `message_attachments` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessageAttachments"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_message_attachments",
        "summary": "Insert into message_attachments",
        "description": "Insert one or more rows into `message_attachments` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageAttachments"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `message_attachments` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessageAttachments"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_message_attachments",
        "summary": "Delete from message_attachments",
        "description": "Delete matching rows from `message_attachments` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/topic_read_state": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_topic_read_state",
        "summary": "Query topic_read_state",
        "description": "Per-member read watermarks powering the Siden sist activity view.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `topic_read_state` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TopicReadState"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_topic_read_state",
        "summary": "Insert into topic_read_state",
        "description": "Insert one or more rows into `topic_read_state` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopicReadState"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `topic_read_state` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TopicReadState"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_topic_read_state",
        "summary": "Update topic_read_state",
        "description": "Update matching rows in `topic_read_state` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopicReadState"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `topic_read_state` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TopicReadState"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/topic_moves": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_topic_moves",
        "summary": "Query topic_moves",
        "description": "Audit log of topic and message reorganizations across threads and channels.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `topic_moves` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TopicMoves"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/member_passkeys": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_member_passkeys",
        "summary": "Query member_passkeys",
        "description": "Enrolled FIDO2/WebAuthn passkey public credentials for the authenticated member.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `member_passkeys` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MemberPasskeys"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_member_passkeys",
        "summary": "Insert into member_passkeys",
        "description": "Insert one or more rows into `member_passkeys` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberPasskeys"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `member_passkeys` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MemberPasskeys"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Tables"
        ],
        "operationId": "delete_member_passkeys",
        "summary": "Delete from member_passkeys",
        "description": "Delete matching rows from `member_passkeys` (subject to RLS `USING` policy).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted matching rows."
          }
        }
      }
    },
    "/embed_hosts": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_embed_hosts",
        "summary": "Query embed_hosts",
        "description": "Allowlisted blog origins permitted to embed Shurah comment threads.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `embed_hosts` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmbedHosts"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_embed_hosts",
        "summary": "Insert into embed_hosts",
        "description": "Insert one or more rows into `embed_hosts` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbedHosts"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `embed_hosts` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmbedHosts"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_embed_hosts",
        "summary": "Update embed_hosts",
        "description": "Update matching rows in `embed_hosts` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbedHosts"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `embed_hosts` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmbedHosts"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tenant_domain_rules": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_tenant_domain_rules",
        "summary": "Query tenant_domain_rules",
        "description": "Tenant-level email domain auto-approval rules evaluated after mailbox verification.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `tenant_domain_rules` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TenantDomainRules"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/org_domain_rules": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_org_domain_rules",
        "summary": "Query org_domain_rules",
        "description": "Organization-level email domain auto-approval rules evaluated after mailbox verification.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `org_domain_rules` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OrgDomainRules"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v_poll_results": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Views"
        ],
        "operationId": "list_v_poll_results",
        "summary": "Query v_poll_results",
        "description": "Aggregated poll vote counts (security_invoker = true).",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `v_poll_results` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/VPollResults"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v_siden_sist": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Views"
        ],
        "operationId": "list_v_siden_sist",
        "summary": "Query v_siden_sist",
        "description": "Unread topic activity summary per member (security_invoker = true).",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `v_siden_sist` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/VSidenSist"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/message_references": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_message_references",
        "summary": "Query message_references",
        "description": "Transitive sub-thread reply DAG closure (message_id -> ancestor_message_id with depth) maintained automatically by trigger.",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `message_references` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MessageReferences"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/encrypted_blobs": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Tables"
        ],
        "operationId": "list_encrypted_blobs",
        "summary": "Query encrypted_blobs",
        "description": "Content-addressable AES-256-GCM ciphertext blob metadata deduplicated per (channel_id, key_epoch, ciphertext_sha256).",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `encrypted_blobs` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EncryptedBlobs"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Tables"
        ],
        "operationId": "insert_encrypted_blobs",
        "summary": "Insert into encrypted_blobs",
        "description": "Insert one or more rows into `encrypted_blobs` (subject to RLS `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EncryptedBlobs"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inserted `encrypted_blobs` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EncryptedBlobs"
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Tables"
        ],
        "operationId": "update_encrypted_blobs",
        "summary": "Update encrypted_blobs",
        "description": "Update matching rows in `encrypted_blobs` (subject to RLS `USING` and `WITH CHECK` policies).",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EncryptedBlobs"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated `encrypted_blobs` row(s).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EncryptedBlobs"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v_topic_envelopes": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AcceptProfile"
        }
      ],
      "get": {
        "tags": [
          "Views"
        ],
        "operationId": "list_v_topic_envelopes",
        "summary": "Query v_topic_envelopes",
        "description": "Lightweight header-summary view aggregating topic message, participant, and attachment counts (security_invoker = true).",
        "parameters": [
          {
            "name": "select",
            "in": "query",
            "required": false,
            "description": "PostgREST column projection (default `*`).",
            "schema": {
              "type": "string",
              "default": "*"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "PostgREST ordering expression, e.g. `created_at.asc`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of `v_topic_envelopes` rows visible under PostgreSQL RLS.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/VTopicEnvelopes"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rpc/admin_provision_member": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_admin_provision_member",
        "summary": "RPC admin_provision_member",
        "description": "Provision an active member account with username and bcrypt password directly without requiring an email address.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_username": {
                    "type": "string"
                  },
                  "p_display_name": {
                    "type": "string"
                  },
                  "p_temp_password": {
                    "type": "string"
                  },
                  "p_role": {
                    "type": "string",
                    "enum": [
                      "inactive",
                      "active_member",
                      "board",
                      "admin"
                    ]
                  },
                  "p_org_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_username",
                  "p_display_name",
                  "p_temp_password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `admin_provision_member` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/approve_pending_member": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_approve_pending_member",
        "summary": "RPC approve_pending_member",
        "description": "Invoke tenant PostgreSQL RPC `approve_pending_member` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_member_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_member_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `approve_pending_member` (`BOOLEAN`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/bulk_approve_pending_members": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_bulk_approve_pending_members",
        "summary": "RPC bulk_approve_pending_members",
        "description": "Invoke tenant PostgreSQL RPC `bulk_approve_pending_members` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_member_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_member_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `bulk_approve_pending_members` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/bulk_review_org_members": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_bulk_review_org_members",
        "summary": "RPC bulk_review_org_members",
        "description": "Invoke tenant PostgreSQL RPC `bulk_review_org_members` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_member_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "p_status": {
                    "type": "string"
                  },
                  "p_role": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_member_ids",
                  "p_status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `bulk_review_org_members` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/check_email_outbox": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_check_email_outbox",
        "summary": "RPC check_email_outbox",
        "description": "Invoke tenant PostgreSQL RPC `check_email_outbox` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_pairing_secret": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_pairing_secret"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `check_email_outbox` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/claim_email_outbox_batch": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_claim_email_outbox_batch",
        "summary": "RPC claim_email_outbox_batch",
        "description": "Invoke tenant PostgreSQL RPC `claim_email_outbox_batch` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_limit": {
                    "type": "integer"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `claim_email_outbox_batch` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/configure_embed_host": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_configure_embed_host",
        "summary": "RPC configure_embed_host",
        "description": "Invoke tenant PostgreSQL RPC `configure_embed_host` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_allowed_origin": {
                    "type": "string"
                  },
                  "p_auto_create_topic": {
                    "type": "boolean"
                  },
                  "p_public_read": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_channel_id",
                  "p_allowed_origin"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `configure_embed_host` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/confirm_totp_enrollment": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_confirm_totp_enrollment",
        "summary": "RPC confirm_totp_enrollment",
        "description": "Verify a 6-digit RFC 6238 TOTP code from the user's authenticator app to activate TOTP 2FA.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_totp_code": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_totp_code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `confirm_totp_enrollment` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/confirm_totp_for_username": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_confirm_totp_for_username",
        "summary": "RPC confirm_totp_for_username",
        "description": "Confirm initial RFC 6238 TOTP enrollment using username, password, and 6-digit TOTP code.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_username": {
                    "type": "string"
                  },
                  "p_password": {
                    "type": "string"
                  },
                  "p_totp_code": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_username",
                  "p_password",
                  "p_totp_code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `confirm_totp_for_username` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/convert_topic_to_wiki": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_convert_topic_to_wiki",
        "summary": "RPC convert_topic_to_wiki",
        "description": "Invoke tenant PostgreSQL RPC `convert_topic_to_wiki` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_title": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_body": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_summary": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `convert_topic_to_wiki` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/create_api_token": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_create_api_token",
        "summary": "RPC create_api_token",
        "description": "Mint a scoped personal or bot API token (shurah_pat_...); returns the plaintext token exactly once.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_name": {
                    "type": "string"
                  },
                  "p_scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "p_expires_in_days": {
                    "type": "integer"
                  },
                  "p_is_bot": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `create_api_token` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/create_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_create_channel",
        "summary": "RPC create_channel",
        "description": "Create or update a channel (including public_read, active_members, board_only, or private) and its default topic inside an organization.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_slug": {
                    "type": "string"
                  },
                  "p_title": {
                    "type": "string"
                  },
                  "p_description": {
                    "type": "string"
                  },
                  "p_access_level": {
                    "type": "string",
                    "enum": [
                      "public_read",
                      "welcome_open",
                      "active_members",
                      "board_only"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_slug",
                  "p_title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `create_channel` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/create_managed_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_create_managed_channel",
        "summary": "RPC create_managed_channel",
        "description": "Invoke tenant PostgreSQL RPC `create_managed_channel` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_slug": {
                    "type": "string"
                  },
                  "p_title": {
                    "type": "string"
                  },
                  "p_description": {
                    "type": "string"
                  },
                  "p_access_level": {
                    "type": "string",
                    "enum": [
                      "public_read",
                      "welcome_open",
                      "active_members",
                      "board_only"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_slug",
                  "p_title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `create_managed_channel` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/create_or_get_dm_thread": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_create_or_get_dm_thread",
        "summary": "RPC create_or_get_dm_thread",
        "description": "Invoke tenant PostgreSQL RPC `create_or_get_dm_thread` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_target_member_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_target_member_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `create_or_get_dm_thread` (`UUID`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/create_organization": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_create_organization",
        "summary": "RPC create_organization",
        "description": "Invoke tenant PostgreSQL RPC `create_organization` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_slug": {
                    "type": "string"
                  },
                  "p_name": {
                    "type": "string"
                  },
                  "p_description": {
                    "type": "string"
                  },
                  "p_is_public": {
                    "type": "boolean"
                  },
                  "p_invite_code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_slug",
                  "p_name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `create_organization` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/delete_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_delete_channel",
        "summary": "RPC delete_channel",
        "description": "Invoke tenant PostgreSQL RPC `delete_channel` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `delete_channel` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/delete_message": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_delete_message",
        "summary": "RPC delete_message",
        "description": "Invoke tenant PostgreSQL RPC `delete_message` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_message_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_message_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `delete_message` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/delete_org_domain_rule": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_delete_org_domain_rule",
        "summary": "RPC delete_org_domain_rule",
        "description": "Remove an organization-level email domain auto-approval rule.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_domain": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_domain"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `delete_org_domain_rule` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/delete_tenant_domain_rule": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_delete_tenant_domain_rule",
        "summary": "RPC delete_tenant_domain_rule",
        "description": "Remove a tenant-level email domain auto-approval rule.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_domain": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_domain"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `delete_tenant_domain_rule` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/delete_topic": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_delete_topic",
        "summary": "RPC delete_topic",
        "description": "Invoke tenant PostgreSQL RPC `delete_topic` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `delete_topic` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/edit_message": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_edit_message",
        "summary": "RPC edit_message",
        "description": "Invoke tenant PostgreSQL RPC `edit_message` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_message_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_body": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_message_id",
                  "p_body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `edit_message` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/edit_wiki_article": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_edit_wiki_article",
        "summary": "RPC edit_wiki_article",
        "description": "Invoke tenant PostgreSQL RPC `edit_wiki_article` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_title": {
                    "type": "string"
                  },
                  "p_body": {
                    "type": "string"
                  },
                  "p_summary": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id",
                  "p_title",
                  "p_body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `edit_wiki_article` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/enroll_totp_secret": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_enroll_totp_secret",
        "summary": "RPC enroll_totp_secret",
        "description": "Generate and store an encrypted RFC 6238 TOTP shared secret for the authenticated member, returning the Base32 secret and otpauth:// URI.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_label": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `enroll_totp_secret` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/enroll_totp_secret_for_username": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_enroll_totp_secret_for_username",
        "summary": "RPC enroll_totp_secret_for_username",
        "description": "First-time RFC 6238 TOTP secret enrollment for an unverified provisioned username+password account without requiring email.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_username": {
                    "type": "string"
                  },
                  "p_password": {
                    "type": "string"
                  },
                  "p_label": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_username",
                  "p_password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `enroll_totp_secret_for_username` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/get_community_bootstrap": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_get_community_bootstrap",
        "summary": "RPC get_community_bootstrap",
        "description": "Single-RPC RLS-enforced demo community bootstrap snapshot excluding tsvector columns for fast initial page load.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `get_community_bootstrap` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/grant_topic_privilege": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_grant_topic_privilege",
        "summary": "RPC grant_topic_privilege",
        "description": "Invoke tenant PostgreSQL RPC `grant_topic_privilege` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_member_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_granted": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_member_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `grant_topic_privilege` (`BOOLEAN`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/import_demo_corpus": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_import_demo_corpus",
        "summary": "RPC import_demo_corpus",
        "description": "Invoke tenant PostgreSQL RPC `import_demo_corpus` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_slug": {
                    "type": "string"
                  },
                  "p_org_name": {
                    "type": "string"
                  },
                  "p_datasets": {
                    "type": [
                      "object",
                      "array",
                      "string",
                      "number",
                      "boolean",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `import_demo_corpus` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/import_facebook_group_archive": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_import_facebook_group_archive",
        "summary": "RPC import_facebook_group_archive",
        "description": "Invoke tenant PostgreSQL RPC `import_facebook_group_archive` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_slug": {
                    "type": "string"
                  },
                  "p_channel_slug": {
                    "type": "string"
                  },
                  "p_archive": {
                    "type": [
                      "object",
                      "array",
                      "string",
                      "number",
                      "boolean",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_slug",
                  "p_channel_slug",
                  "p_archive"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `import_facebook_group_archive` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/issue_passkey_challenge": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_issue_passkey_challenge",
        "summary": "RPC issue_passkey_challenge",
        "description": "Issue a single-use cryptographic WebAuthn challenge (Base64URL) and server-resolved rp_id (demo.shurah.org) in demo tenant.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_purpose": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `issue_passkey_challenge` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/issue_passkey_login_challenge": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_issue_passkey_login_challenge",
        "summary": "RPC issue_passkey_login_challenge",
        "description": "Issue a single-use unauthenticated WebAuthn login challenge (Base64URL) and server-resolved rp_id (demo.shurah.org) in demo tenant.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `issue_passkey_login_challenge` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/join_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_join_channel",
        "summary": "RPC join_channel",
        "description": "Invoke tenant PostgreSQL RPC `join_channel` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `join_channel` (`BOOLEAN`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/list_my_api_tokens": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_list_my_api_tokens",
        "summary": "RPC list_my_api_tokens",
        "description": "List metadata (prefix, scopes, expiration, revocation status) for the authenticated member's API tokens without exposing token hashes.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `list_my_api_tokens` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/list_org_domain_rules": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_list_org_domain_rules",
        "summary": "RPC list_org_domain_rules",
        "description": "List organization-level email domain auto-approval rules for organizations administered by the caller.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `list_org_domain_rules` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/list_tenant_domain_rules": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_list_tenant_domain_rules",
        "summary": "RPC list_tenant_domain_rules",
        "description": "List all tenant-level email domain auto-approval rules (tenant admin only; never exposed to unauthenticated visitors).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `list_tenant_domain_rules` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/login_password_totp": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_login_password_totp",
        "summary": "RPC login_password_totp",
        "description": "Authenticate with username, bcrypt password, and replay-protected 6-digit RFC 6238 TOTP code, minting an AAL2 shurah_pat_... API token.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_username": {
                    "type": "string"
                  },
                  "p_password": {
                    "type": "string"
                  },
                  "p_totp_code": {
                    "type": "string"
                  },
                  "p_token_name": {
                    "type": "string"
                  },
                  "p_scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "p_expires_in_days": {
                    "type": "integer"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_username",
                  "p_password",
                  "p_totp_code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `login_password_totp` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/manage_channel_access": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_manage_channel_access",
        "summary": "RPC manage_channel_access",
        "description": "Invoke tenant PostgreSQL RPC `manage_channel_access` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_member_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_grant": {
                    "type": "boolean"
                  },
                  "p_can_manage": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id",
                  "p_member_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `manage_channel_access` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/mark_email_outbox_dispatched": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_mark_email_outbox_dispatched",
        "summary": "RPC mark_email_outbox_dispatched",
        "description": "Invoke tenant PostgreSQL RPC `mark_email_outbox_dispatched` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_pairing_secret": {
                    "type": "string"
                  },
                  "p_message_id": {
                    "type": "string"
                  },
                  "p_error": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_pairing_secret"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `mark_email_outbox_dispatched` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/move_messages": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_move_messages",
        "summary": "RPC move_messages",
        "description": "Invoke tenant PostgreSQL RPC `move_messages` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_message_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "p_target_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_reason": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_message_ids",
                  "p_target_topic_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `move_messages` (`INT`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/move_topic_to_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_move_topic_to_channel",
        "summary": "RPC move_topic_to_channel",
        "description": "Invoke tenant PostgreSQL RPC `move_topic_to_channel` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_target_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id",
                  "p_target_channel_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `move_topic_to_channel` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/post_bot_message": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_post_bot_message",
        "summary": "RPC post_bot_message",
        "description": "Idempotently post an automated/bot message to a topic using client_msg_id deduplication without requiring content:read.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_body": {
                    "type": "string"
                  },
                  "p_client_msg_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id",
                  "p_body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `post_bot_message` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/post_embed_comment": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_post_embed_comment",
        "summary": "RPC post_embed_comment",
        "description": "Invoke tenant PostgreSQL RPC `post_embed_comment` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_body": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id",
                  "p_body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `post_embed_comment` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/promote_subthread_to_topic": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_promote_subthread_to_topic",
        "summary": "RPC promote_subthread_to_topic",
        "description": "Atomically extract a reply sub-thread (root message plus all transitive DAG descendants in message_references) into a new topic within the same demo channel.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_root_message_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_new_topic_title": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_root_message_id",
                  "p_new_topic_title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `promote_subthread_to_topic` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/promote_to_wiki": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_promote_to_wiki",
        "summary": "RPC promote_to_wiki",
        "description": "Invoke tenant PostgreSQL RPC `promote_to_wiki` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_title": {
                    "type": "string"
                  },
                  "p_body": {
                    "type": "string"
                  },
                  "p_summary": {
                    "type": "string"
                  },
                  "p_source_message_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id",
                  "p_title",
                  "p_body",
                  "p_summary",
                  "p_source_message_ids"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `promote_to_wiki` (`UUID`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/reorganize_channel_topics": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_reorganize_channel_topics",
        "summary": "RPC reorganize_channel_topics",
        "description": "Invoke tenant PostgreSQL RPC `reorganize_channel_topics` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_topic1_title": {
                    "type": "string"
                  },
                  "p_topic2_title": {
                    "type": "string"
                  },
                  "p_topic2_message_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id",
                  "p_topic1_title",
                  "p_topic2_title"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `reorganize_channel_topics` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/request_join_organization": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_request_join_organization",
        "summary": "RPC request_join_organization",
        "description": "Invoke tenant PostgreSQL RPC `request_join_organization` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_slug": {
                    "type": "string"
                  },
                  "p_intro_message": {
                    "type": "string"
                  },
                  "p_invite_code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_slug"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `request_join_organization` (`UUID`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/resolve_moderation_report": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_resolve_moderation_report",
        "summary": "RPC resolve_moderation_report",
        "description": "Invoke tenant PostgreSQL RPC `resolve_moderation_report` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_report_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_status": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_report_id",
                  "p_status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `resolve_moderation_report` (`BOOLEAN`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/resolve_or_create_embed_topic": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_resolve_or_create_embed_topic",
        "summary": "RPC resolve_or_create_embed_topic",
        "description": "Invoke tenant PostgreSQL RPC `resolve_or_create_embed_topic` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_slug": {
                    "type": "string"
                  },
                  "p_channel_slug": {
                    "type": "string"
                  },
                  "p_external_url": {
                    "type": "string"
                  },
                  "p_title": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_excerpt": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_slug",
                  "p_channel_slug",
                  "p_external_url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `resolve_or_create_embed_topic` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/review_org_member": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_review_org_member",
        "summary": "RPC review_org_member",
        "description": "Invoke tenant PostgreSQL RPC `review_org_member` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_member_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_status": {
                    "type": "string"
                  },
                  "p_role": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_member_id",
                  "p_status"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `review_org_member` (`BOOLEAN`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/rpc/revoke_api_token": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_revoke_api_token",
        "summary": "RPC revoke_api_token",
        "description": "Immediately revoke an API token in PostgreSQL (0ms revocation enforcement across REST, CLI, and MCP).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_token_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_token_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `revoke_api_token` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/search_all": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_search_all",
        "summary": "RPC search_all",
        "description": "Unified Norwegian + infix full-text search across RLS-visible demo entities returning exact thread and message coordinates.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query_text": {
                    "type": "string"
                  },
                  "public": {
                    "type": "string"
                  },
                  "q": {
                    "type": "string"
                  },
                  "latest_wiki": {
                    "type": "string"
                  },
                  "combined": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "public"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `search_all` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/set_member_credentials": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_set_member_credentials",
        "summary": "RPC set_member_credentials",
        "description": "Configure or rotate the authenticated member's username and bcrypt password for CLI and TOTP login.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_username": {
                    "type": "string"
                  },
                  "p_password": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_username",
                  "p_password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `set_member_credentials` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/set_member_org_role": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_set_member_org_role",
        "summary": "RPC set_member_org_role",
        "description": "Invoke tenant PostgreSQL RPC `set_member_org_role` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_member_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_role": {
                    "type": "string"
                  },
                  "p_topic_privilege": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_member_id",
                  "p_role"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `set_member_org_role` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/set_org_visibility": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_set_org_visibility",
        "summary": "RPC set_org_visibility",
        "description": "Invoke tenant PostgreSQL RPC `set_org_visibility` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_is_public": {
                    "type": "boolean"
                  },
                  "p_invite_code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_is_public"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `set_org_visibility` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/set_topic_public_visibility": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_set_topic_public_visibility",
        "summary": "RPC set_topic_public_visibility",
        "description": "Toggle whether an individual discussion or wiki topic is publicly readable by unauthenticated visitors.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_topic_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_is_public": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_topic_id",
                  "p_is_public"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `set_topic_public_visibility` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/start_demo_guest_session": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_start_demo_guest_session",
        "summary": "RPC start_demo_guest_session",
        "description": "Mint a rate-limited 12-hour demo sandbox member session on demo.shurah.org for interactive thread commenting and replies.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_display_name": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `start_demo_guest_session` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/start_email_verification": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_start_email_verification",
        "summary": "RPC start_email_verification",
        "description": "Invoke tenant PostgreSQL RPC `start_email_verification` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_email": {
                    "type": "string"
                  },
                  "p_display_name": {
                    "type": "string"
                  },
                  "p_org_slug": {
                    "type": "string"
                  },
                  "p_intro_message": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `start_email_verification` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/sync_my_member_profile": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_sync_my_member_profile",
        "summary": "RPC sync_my_member_profile",
        "description": "Invoke tenant PostgreSQL RPC `sync_my_member_profile` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_display_name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `sync_my_member_profile` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/update_channel": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_update_channel",
        "summary": "RPC update_channel",
        "description": "Invoke tenant PostgreSQL RPC `update_channel` (enforced by Row-Level Security and `Accept-Profile`/`Content-Profile` tenant isolation).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_channel_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_slug": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_title": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_access_level": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "enum": [
                      "public_read",
                      "welcome_open",
                      "active_members",
                      "board_only"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_channel_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `update_channel` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/upsert_org_domain_rule": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_upsert_org_domain_rule",
        "summary": "RPC upsert_org_domain_rule",
        "description": "Configure an organization-level email domain auto-approval rule (applied strictly after magic-link or OTP email verification).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_org_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_domain": {
                    "type": "string"
                  },
                  "p_auto_role": {
                    "type": "string"
                  },
                  "p_auto_topic_privilege": {
                    "type": "boolean"
                  },
                  "p_auto_approve": {
                    "type": "boolean"
                  },
                  "p_notes": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_org_id",
                  "p_domain"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `upsert_org_domain_rule` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/upsert_tenant_domain_rule": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_upsert_tenant_domain_rule",
        "summary": "RPC upsert_tenant_domain_rule",
        "description": "Configure a tenant-wide email domain auto-approval rule (applied strictly after magic-link or OTP email verification).",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_domain": {
                    "type": "string"
                  },
                  "p_auto_role": {
                    "type": "string",
                    "enum": [
                      "inactive",
                      "active_member",
                      "board",
                      "admin"
                    ]
                  },
                  "p_auto_approve": {
                    "type": "boolean"
                  },
                  "p_notes": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_domain"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `upsert_tenant_domain_rule` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/verify_email_token_or_otp": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_verify_email_token_or_otp",
        "summary": "RPC verify_email_token_or_otp",
        "description": "Verify mailbox ownership via magic-link token or 6-digit email code, logging the user in and evaluating tenant/org domain auto-approval rules.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_pairing_secret": {
                    "type": "string"
                  },
                  "p_code_or_token": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_pairing_secret",
                  "p_code_or_token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `verify_email_token_or_otp` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/rpc/verify_passkey_login": {
      "post": {
        "tags": [
          "RPC"
        ],
        "operationId": "rpc_verify_passkey_login",
        "summary": "RPC verify_passkey_login",
        "description": "Cryptographically verify a WebAuthn NIST P-256 (ES256) assertion in demo tenant and mint an AAL2 session.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AcceptProfile"
          },
          {
            "$ref": "#/components/parameters/ContentProfile"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_challenge_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "p_credential_id": {
                    "type": "string"
                  },
                  "p_new_sign_count": {
                    "type": "integer"
                  },
                  "p_signature_b64": {
                    "type": "string"
                  },
                  "p_authenticator_data_b64": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "p_client_data_json_b64": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "additionalProperties": false,
                "required": [
                  "p_challenge_id",
                  "p_credential_id",
                  "p_new_sign_count",
                  "p_signature_b64"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of `verify_passkey_login` (`JSONB`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "object",
                    "array",
                    "string",
                    "number",
                    "boolean",
                    "null"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "apikey",
        "description": "Supabase publishable anonymous API key (`sb_publishable_...`). Always required by the PostgREST gateway."
      },
      "ShurahPatAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-shurah-token",
        "description": "Scoped Shurah Personal or Bot Access Token (`shurah_pat_...`) minted via `login_password_totp` or `create_api_token`."
      },
      "ShurahSessionAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-shurah-session",
        "description": "Verified magic-link/OTP or passkey browser session secret."
      },
      "BearerJwtAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Supabase `Authorization: Bearer <publishable_key_or_jwt>` header."
      }
    },
    "parameters": {
      "AcceptProfile": {
        "name": "Accept-Profile",
        "in": "header",
        "required": false,
        "description": "Target PostgreSQL tenant schema for `GET`/`HEAD` queries (`shurah` for production, `demo` for demo.shurah.org).",
        "schema": {
          "type": "string",
          "enum": [
            "shurah",
            "demo"
          ],
          "default": "shurah"
        }
      },
      "ContentProfile": {
        "name": "Content-Profile",
        "in": "header",
        "required": false,
        "description": "Target PostgreSQL tenant schema for `POST`/`PATCH`/`PUT`/`DELETE` mutations and RPC calls (`shurah` or `demo`).",
        "schema": {
          "type": "string",
          "enum": [
            "shurah",
            "demo"
          ],
          "default": "shurah"
        }
      }
    },
    "schemas": {
      "Organizations": {
        "type": "object",
        "description": "Community organizations inside a Shurah tenant.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_public": {
            "type": "boolean"
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OrganizationMembers": {
        "type": "object",
        "description": "Organization membership roles, approval status, and topic privileges.",
        "properties": {
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "role": {
            "type": "string",
            "enum": [
              "member",
              "moderator",
              "org_admin"
            ]
          },
          "approval_status": {
            "type": "string",
            "enum": [
              "pending_approval",
              "active",
              "rejected"
            ]
          },
          "topic_privilege": {
            "type": "boolean"
          },
          "intro_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OrgJoinMessages": {
        "type": "object",
        "description": "Applicant-to-admin onboarding conversation messages.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "applicant_id": {
            "type": "string",
            "format": "uuid"
          },
          "sender_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Members": {
        "type": "object",
        "description": "Tenant member profiles (strictly column-restricted; zero PII or password hashes exposed).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "username": {
            "type": [
              "string",
              "null"
            ]
          },
          "display_name": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "inactive",
              "active_member",
              "board",
              "admin"
            ]
          },
          "approval_status": {
            "type": "string",
            "enum": [
              "pending_approval",
              "active",
              "rejected"
            ]
          },
          "font_scale": {
            "type": "integer"
          },
          "is_locked": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Channels": {
        "type": "object",
        "description": "Deliberation channels with public_read, welcome_open, active_members, board_only, or private access.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "org_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "access_level": {
            "type": "string",
            "enum": [
              "public_read",
              "welcome_open",
              "active_members",
              "board_only"
            ]
          },
          "is_private": {
            "type": "boolean"
          },
          "provenance_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "attribution": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ChannelMembers": {
        "type": "object",
        "description": "Explicit channel memberships for open and private channels.",
        "properties": {
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ChannelManagers": {
        "type": "object",
        "description": "Designated channel stewards authorized to reorganize topics and curate Wiki articles.",
        "properties": {
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Topics": {
        "type": "object",
        "description": "Structured discussion threads, live chat streams, and synthesized Wiki articles.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "chat",
              "discussion",
              "wiki",
              "announcement"
            ]
          },
          "title": {
            "type": "string"
          },
          "wiki_body": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_pinned": {
            "type": "boolean"
          },
          "is_public": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "external_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Messages": {
        "type": "object",
        "description": "Deliberation messages and automated bot messages within a topic.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "author_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string"
          },
          "is_bot_message": {
            "type": "boolean"
          },
          "client_msg_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "reply_to_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "root_message_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WikiRevisions": {
        "type": "object",
        "description": "Versioned revisions of living knowledge-base Wiki articles.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "revision_no": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "edited_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WikiSources": {
        "type": "object",
        "description": "Provenance links connecting synthesized Wiki articles to source channel messages.",
        "properties": {
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Polls": {
        "type": "object",
        "description": "Structured community polls attached to channels.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "question": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allow_multi": {
            "type": "boolean"
          },
          "closes_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PollVotes": {
        "type": "object",
        "description": "One-member-one-vote poll ballot records enforced in PostgreSQL.",
        "properties": {
          "poll_id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "option_indexes": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DmThreads": {
        "type": "object",
        "description": "1:1 Direct Message threads visible strictly to participants.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DmParticipants": {
        "type": "object",
        "description": "Participant bindings for 1:1 Direct Message threads.",
        "properties": {
          "thread_id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DmMessages": {
        "type": "object",
        "description": "Participant-isolated 1:1 Direct Messages.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "thread_id": {
            "type": "string",
            "format": "uuid"
          },
          "sender_id": {
            "type": "string",
            "format": "uuid"
          },
          "body": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MemberBlocks": {
        "type": "object",
        "description": "Personal member block list filtering channel and DM visibility.",
        "properties": {
          "blocker_id": {
            "type": "string",
            "format": "uuid"
          },
          "blocked_id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ModerationReports": {
        "type": "object",
        "description": "Moderation and ban reports reviewed by organization moderators and admins.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "reporter_id": {
            "type": "string",
            "format": "uuid"
          },
          "reported_member_id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "resolved_ban",
              "dismissed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MessageAttachments": {
        "type": "object",
        "description": "Client-side AES-256-GCM encrypted attachment metadata linked to Supabase Storage.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "dm_message_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "uploader_id": {
            "type": "string",
            "format": "uuid"
          },
          "file_name": {
            "type": "string"
          },
          "mime_type": {
            "type": "string"
          },
          "byte_size": {
            "type": "integer"
          },
          "is_inline": {
            "type": "boolean"
          },
          "storage_path": {
            "type": "string"
          },
          "encryption_iv": {
            "type": "string"
          },
          "ciphertext_b64": {
            "type": [
              "string",
              "null"
            ]
          },
          "blob_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TopicReadState": {
        "type": "object",
        "description": "Per-member read watermarks powering the Siden sist activity view.",
        "properties": {
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "last_read_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TopicMoves": {
        "type": "object",
        "description": "Audit log of topic and message reorganizations across threads and channels.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "from_topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "to_topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "moved_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MemberPasskeys": {
        "type": "object",
        "description": "Enrolled FIDO2/WebAuthn passkey public credentials for the authenticated member.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "member_id": {
            "type": "string",
            "format": "uuid"
          },
          "credential_id": {
            "type": "string"
          },
          "public_key_spki": {
            "type": "string"
          },
          "device_kind": {
            "type": "string"
          },
          "device_label": {
            "type": "string"
          },
          "sign_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EmbedHosts": {
        "type": "object",
        "description": "Allowlisted blog origins permitted to embed Shurah comment threads.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "allowed_origin": {
            "type": "string"
          },
          "auto_create_topic": {
            "type": "boolean"
          },
          "public_read": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantDomainRules": {
        "type": "object",
        "description": "Tenant-level email domain auto-approval rules evaluated after mailbox verification.",
        "properties": {
          "domain": {
            "type": "string"
          },
          "auto_role": {
            "type": "string",
            "enum": [
              "active_member",
              "board",
              "admin"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "note": {
            "type": "string"
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OrgDomainRules": {
        "type": "object",
        "description": "Organization-level email domain auto-approval rules evaluated after mailbox verification.",
        "properties": {
          "org_id": {
            "type": "string",
            "format": "uuid"
          },
          "domain": {
            "type": "string"
          },
          "auto_role": {
            "type": "string",
            "enum": [
              "member",
              "moderator",
              "org_admin"
            ]
          },
          "auto_topic_privilege": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "note": {
            "type": "string"
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VPollResults": {
        "type": "object",
        "description": "Aggregated poll vote counts (security_invoker = true).",
        "properties": {
          "poll_id": {
            "type": "string",
            "format": "uuid"
          },
          "option_index": {
            "type": "integer"
          },
          "vote_count": {
            "type": "integer"
          }
        }
      },
      "VSidenSist": {
        "type": "object",
        "description": "Unread topic activity summary per member (security_invoker = true).",
        "properties": {
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "topic_ext_id": {
            "type": "string"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "unread_count": {
            "type": "integer"
          },
          "latest_message_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MessageReferences": {
        "type": "object",
        "description": "Transitive sub-thread reply DAG closure (message_id -> ancestor_message_id with depth) maintained automatically by trigger.",
        "properties": {
          "message_id": {
            "type": "string",
            "format": "uuid"
          },
          "ancestor_message_id": {
            "type": "string",
            "format": "uuid"
          },
          "depth": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EncryptedBlobs": {
        "type": "object",
        "description": "Content-addressable AES-256-GCM ciphertext blob metadata deduplicated per (channel_id, key_epoch, ciphertext_sha256).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "key_epoch": {
            "type": "integer"
          },
          "ciphertext_sha256": {
            "type": "string"
          },
          "storage_path": {
            "type": "string"
          },
          "encryption_iv": {
            "type": "string"
          },
          "byte_size": {
            "type": "integer"
          },
          "mime_type": {
            "type": "string"
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "VTopicEnvelopes": {
        "type": "object",
        "description": "Lightweight header-summary view aggregating topic message, participant, and attachment counts (security_invoker = true).",
        "properties": {
          "topic_id": {
            "type": "string",
            "format": "uuid"
          },
          "ext_id": {
            "type": "string"
          },
          "channel_id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "chat",
              "discussion",
              "wiki",
              "announcement"
            ]
          },
          "title": {
            "type": "string"
          },
          "is_pinned": {
            "type": "boolean"
          },
          "is_public": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "created_by": {
            "type": "string",
            "format": "uuid"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "message_count": {
            "type": "integer"
          },
          "participant_count": {
            "type": "integer"
          },
          "attachment_count": {
            "type": "integer"
          },
          "last_posted_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_author_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      }
    }
  }
}
