{
  "components": {
    "schemas": {
      "ApiError": {
        "additionalProperties": false,
        "description": "Canonical error payload. `code` enumerates the known error types; rare framework-level errors (CSRF, upstream plugin failures) may pass through with their own code strings — clients keying on `code` should treat unknown codes as equivalent to the HTTP status class. `details.reason` carries sub-code context for some families; known values include `idempotency_key_mismatch` on 422s from the idempotency plugin.",
        "properties": {
          "code": {
            "enum": [
              "BAD_REQUEST",
              "MEDIA_FORMAT_MISMATCH",
              "UNSAFE_REGEX",
              "INVALID_EXTERNAL_ID",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "CAPABILITY_ESCALATION",
              "EDIT_WINDOW_EXPIRED",
              "DISCUSSION_LOCKED",
              "IDENTITY_VERIFICATION_REQUIRED",
              "IDENTITY_PROVIDER_UNAVAILABLE",
              "NOT_FOUND",
              "CONFLICT",
              "GONE",
              "UNPROCESSABLE_ENTITY",
              "RATE_LIMITED",
              "INTERNAL_ERROR",
              "SERVICE_UNAVAILABLE",
              "VALIDATION_ERROR",
              "FOREIGN_KEY_VIOLATION",
              "NOT_NULL_VIOLATION",
              "PAYLOAD_TOO_LARGE",
              "IDEMPOTENCY_IN_PROGRESS"
            ],
            "type": "string"
          },
          "details": {
            "additionalProperties": true,
            "nullable": true,
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object"
      },
      "ApiErrorResponse": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "object"
          },
          "error": {
            "$ref": "#/components/schemas/ApiError"
          },
          "meta": {
            "enum": [
              null
            ],
            "nullable": true,
            "type": "object"
          },
          "success": {
            "enum": [
              false
            ],
            "type": "boolean"
          }
        },
        "required": [
          "success",
          "data",
          "error",
          "meta"
        ],
        "type": "object"
      },
      "ApiMeta": {
        "additionalProperties": false,
        "properties": {
          "cursor": {
            "nullable": true,
            "type": "string"
          },
          "hasMore": {
            "type": "boolean"
          },
          "sweepJobId": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SseEvent": {
        "description": "Union of all SSE event `data` payload shapes. The discriminating `event` field is carried on the SSE frame itself (not inside the payload). Mapping: comment_created → SseEventCommentCreated, comment_edited → SseEventCommentEdited, comment_deleted → SseEventCommentDeleted, comment_approved → SseEventCommentApproved, comment_rejected → SseEventCommentRejected, reaction_toggled → SseEventReactionToggled, discussion_reaction_toggled → SseEventDiscussionReactionToggled, discussion_locked / _unlocked / _archived → SseEventDiscussionStateChange, notification_reply → SseEventNotificationReply.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/SseEventCommentCreated"
          },
          {
            "$ref": "#/components/schemas/SseEventCommentEdited"
          },
          {
            "$ref": "#/components/schemas/SseEventCommentDeleted"
          },
          {
            "$ref": "#/components/schemas/SseEventCommentApproved"
          },
          {
            "$ref": "#/components/schemas/SseEventCommentRejected"
          },
          {
            "$ref": "#/components/schemas/SseEventReactionToggled"
          },
          {
            "$ref": "#/components/schemas/SseEventDiscussionReactionToggled"
          },
          {
            "$ref": "#/components/schemas/SseEventDiscussionStateChange"
          },
          {
            "$ref": "#/components/schemas/SseEventNotificationReply"
          }
        ]
      },
      "SseEventCommentApproved": {
        "additionalProperties": true,
        "properties": {
          "body": {
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "depth": {
            "type": "integer"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          },
          "parentId": {
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "published"
            ],
            "type": "string"
          },
          "userId": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "discussionId",
          "userId",
          "depth",
          "status",
          "createdAt"
        ],
        "type": "object"
      },
      "SseEventCommentCreated": {
        "additionalProperties": true,
        "properties": {
          "author": {
            "additionalProperties": false,
            "properties": {
              "displayName": {
                "type": "string"
              },
              "externalId": {
                "type": "string"
              }
            },
            "required": [
              "externalId",
              "displayName"
            ],
            "type": "object"
          },
          "body": {
            "type": "string"
          },
          "bodyTruncated": {
            "description": "true when the NOTIFY 8 KB cap was exceeded and `body` was dropped. Clients should re-fetch the comment by id to obtain the full body.",
            "type": "boolean"
          },
          "createdAt": {
            "format": "date-time",
            "type": "string"
          },
          "depth": {
            "type": "integer"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          },
          "parentId": {
            "format": "uuid",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "published",
              "pending",
              "hidden"
            ],
            "type": "string"
          },
          "userId": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "discussionId",
          "userId",
          "depth",
          "status",
          "createdAt"
        ],
        "type": "object"
      },
      "SseEventCommentDeleted": {
        "additionalProperties": true,
        "properties": {
          "deletedBy": {
            "enum": [
              "user",
              "admin"
            ],
            "type": "string"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "discussionId",
          "deletedBy"
        ],
        "type": "object"
      },
      "SseEventCommentEdited": {
        "additionalProperties": true,
        "properties": {
          "author": {
            "additionalProperties": false,
            "properties": {
              "displayName": {
                "type": "string"
              },
              "externalId": {
                "type": "string"
              }
            },
            "required": [
              "externalId",
              "displayName"
            ],
            "type": "object"
          },
          "body": {
            "type": "string"
          },
          "bodyTruncated": {
            "description": "true when the NOTIFY 8 KB cap was exceeded and `body` was dropped.",
            "type": "boolean"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "editedAt": {
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "discussionId",
          "editedAt"
        ],
        "type": "object"
      },
      "SseEventCommentRejected": {
        "additionalProperties": true,
        "properties": {
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          }
        },
        "required": [
          "id",
          "discussionId"
        ],
        "type": "object"
      },
      "SseEventDiscussionReactionToggled": {
        "additionalProperties": true,
        "properties": {
          "action": {
            "enum": [
              "added",
              "removed"
            ],
            "type": "string"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          },
          "reactionType": {
            "type": "string"
          },
          "userId": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "discussionId",
          "userId",
          "reactionType",
          "action"
        ],
        "type": "object"
      },
      "SseEventDiscussionStateChange": {
        "additionalProperties": true,
        "properties": {
          "actor": {
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "role": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "role"
            ],
            "type": "object"
          },
          "at": {
            "format": "date-time",
            "type": "string"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "discussionId",
          "at"
        ],
        "type": "object"
      },
      "SseEventNotificationReply": {
        "additionalProperties": true,
        "properties": {
          "authorUserId": {
            "format": "uuid",
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "bodyTruncated": {
            "type": "boolean"
          },
          "commentId": {
            "format": "uuid",
            "type": "string"
          },
          "discussionId": {
            "format": "uuid",
            "type": "string"
          },
          "parentCommentId": {
            "format": "uuid",
            "type": "string"
          },
          "recipientUserId": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "commentId",
          "parentCommentId",
          "recipientUserId",
          "authorUserId",
          "discussionId"
        ],
        "type": "object"
      },
      "SseEventReactionToggled": {
        "additionalProperties": true,
        "properties": {
          "action": {
            "enum": [
              "added",
              "removed"
            ],
            "type": "string"
          },
          "commentId": {
            "format": "uuid",
            "type": "string"
          },
          "externalUserId": {
            "type": "string"
          },
          "originatedBy": {
            "additionalProperties": false,
            "properties": {
              "userId": {
                "format": "uuid",
                "nullable": true,
                "type": "string"
              }
            },
            "required": [
              "userId"
            ],
            "type": "object"
          },
          "reactionType": {
            "type": "string"
          },
          "userId": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "commentId",
          "userId",
          "reactionType",
          "action"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "adminJwt": {
        "bearerFormat": "JWT",
        "description": "Admin panel JWT (issued by POST /api/v1/admin/auth/login)",
        "scheme": "bearer",
        "type": "http"
      },
      "apiKey": {
        "description": "Tenant API key for authentication",
        "in": "header",
        "name": "X-API-Key",
        "type": "apiKey"
      },
      "identityAssertion": {
        "description": "base64url identity assertion vouching for the acting end-user (signed by the publisher backend; see the identity-signing guide).",
        "in": "header",
        "name": "X-RSMG-Engage-Identity",
        "type": "apiKey"
      },
      "identitySignature": {
        "description": "HMAC-SHA256 signature over the assertion: `t=<unix>,v1=<hex>,kid=<8hex>`. Required whenever X-RSMG-Engage-Identity is sent. An OIDC ID token in `Authorization: Bearer` is the alternative proof (ADR-0054).",
        "in": "header",
        "name": "X-RSMG-Engage-Identity-Signature",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "description": "Multi-tenant engagement API for publishers: comments, discussions, reactions, moderation, real-time streaming (SSE), and webhooks.",
    "title": "RSMG Engage — User Engagement Platform API",
    "version": "1.0.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/api/v1/comments/{commentId}": {
      "delete": {
        "description": "Authors soft-delete their own comment; the row is retained (status `deleted`) so reply threads stay coherent. Emits a `comment_deleted` SSE event.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Soft-delete own comment",
        "tags": [
          "Comments"
        ]
      },
      "patch": {
        "description": "Authors edit their own comment body within the tenant-configured edit window. Fails with 422 if the window has closed. Emits a `comment_edited` SSE event on success.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "body": {
                    "maxLength": 20000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "body"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Edit own comment within edit window",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/comments/{commentId}/approve": {
      "post": {
        "description": "Marks a pending comment as published. Dual-auth: on the API-key path `moderator_id` (external user id) is required and resolves to the internal tenant user recorded on the moderation log; on the admin-JWT path the body field is ignored and the moderation log records `moderatorId: null` (admins are not tenant-scoped users). Both auth paths require the `moderate_content` capability.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "moderator_id": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Approve a pending comment",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/comments/{commentId}/hide": {
      "post": {
        "description": "Marks a published comment as hidden. Closes the moderation gap for reported comments that matched no word filter — gives moderators a direct path to hide any published comment regardless of its filter history. Same dual-auth semantics as approve/reject — API-key callers must supply `moderator_id`, admin-JWT callers do not. Optional `reason` is persisted on the moderation log. Emits `comment_rejected` SSE so connected clients remove the comment immediately.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "moderator_id": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "reason": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Hide a published comment",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/comments/{commentId}/pin": {
      "delete": {
        "description": "Clears the `is_pinned` flag. Requires admin API key or admin JWT with the `moderate_content` capability. Emits a `comment_unpinned` SSE event on the discussion channel.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Unpin a comment",
        "tags": [
          "Comments"
        ]
      },
      "post": {
        "description": "Moderator action — pins the comment so it sorts first within its discussion. Unlimited pins per discussion. Requires admin API key or an admin JWT with the `moderate_content` capability. Emits a `comment_pinned` SSE event on the discussion channel.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Pin a comment to the top of its thread",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/comments/{commentId}/reactions": {
      "get": {
        "description": "Returns aggregate counts grouped by `reaction_type` for a single comment. Read-only; safe for unauthenticated widget calls behind the API key.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "count": {
                            "type": "integer"
                          },
                          "reactionType": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "reactionType",
                          "count"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Get reaction counts for a comment",
        "tags": [
          "Reactions"
        ]
      },
      "post": {
        "description": "End-user toggles a reaction type on a comment. Re-posting the same `reaction_type` removes the prior reaction; a different type is added alongside (a user can hold several reaction types on one comment). Allowed types default to like|love|laugh|surprise|sad|angry, tenant- tunable via the `allowedReactions` setting. Emits a `reaction_toggled` SSE event.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "reaction_type": {
                    "maxLength": 30,
                    "minLength": 1,
                    "type": "string"
                  },
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "reaction_type"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "action": {
                          "enum": [
                            "added",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "reaction": {
                          "additionalProperties": true,
                          "nullable": true,
                          "type": "object"
                        }
                      },
                      "required": [
                        "action"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Toggle a reaction on a comment",
        "tags": [
          "Reactions"
        ]
      }
    },
    "/api/v1/comments/{commentId}/reject": {
      "post": {
        "description": "Marks a pending comment as rejected. Same dual-auth semantics as approve — API-key callers must supply `moderator_id`, admin-JWT callers do not. Optional `reason` is persisted on the moderation log.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "moderator_id": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "reason": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Reject a pending comment",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/comments/{commentId}/remove": {
      "post": {
        "description": "Moderator removal — requires an admin API key or admin JWT. The comment status moves to `deleted` and is recorded as a moderation action. Dual-auth mounted at `/api/v1/comments/:id/remove` and `/api/v1/admin/comments/:id/remove`.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Admin-delete a comment (hard moderation)",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/comments/{commentId}/report": {
      "post": {
        "description": "End-users flag a comment for moderator review. One report per (reporter, comment) pair is enforced; duplicates fail with 422.",
        "parameters": [
          {
            "in": "path",
            "name": "commentId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "reason": {
                    "enum": [
                      "spam",
                      "harassment",
                      "hate_speech",
                      "misinformation",
                      "other"
                    ],
                    "type": "string"
                  },
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "reason"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "description": {
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "reason": {
                          "enum": [
                            "spam",
                            "harassment",
                            "hate_speech",
                            "misinformation",
                            "other"
                          ],
                          "type": "string"
                        },
                        "reporterUserId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "resolvedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "pending",
                            "resolved",
                            "dismissed"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "commentId",
                        "reporterUserId",
                        "reason",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Report a comment for moderation",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/discussions": {
      "get": {
        "description": "Cursor-paginated discussion list. Rows carry the caller's own reaction when the GET sends a valid identity assertion; `viewer_id` is honoured only in trust mode (dev/test) and ignored in verify mode. Dual-auth: `/api/v1/discussions` (API-key) and `/api/v1/admin/discussions` (admin JWT).",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "viewer_id",
            "required": false,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "commentCount": {
                            "type": "integer"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "status": {
                            "enum": [
                              "open",
                              "locked",
                              "archived"
                            ],
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "externalId",
                          "title",
                          "status",
                          "commentCount",
                          "createdAt",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List discussions (paginated)",
        "tags": [
          "Discussions"
        ]
      },
      "post": {
        "deprecated": true,
        "description": "Seeds a discussion title before any comment arrives. On subsequent calls with the same `external_id` the title is **not** updated — use this only to pre-seed a title before first comment. For the common \"comment on first visitor\" flow, prefer `POST /api/v1/discussions/by-external/{externalId}/comments` — it materialises the discussion lazily so the widget avoids a write on every article view.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "external_id": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "title": {
                    "maxLength": 500,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "external_id",
                  "title"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentCount": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "title",
                        "status",
                        "commentCount",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Upsert a discussion (deprecated — prefer by-external comment create)",
        "tags": [
          "Discussions"
        ]
      }
    },
    "/api/v1/discussions/by-external/{externalId}/comments": {
      "get": {
        "description": "Same payload as the UUID route but keyed on the tenant-scoped `external_id` (publisher article/page identifier). Returns 404 when no discussion exists for that external id — the widget renders its empty state without Edgar ever having written. Dual-auth: available under `/api/v1/discussions/by-external/...` (API-key) and `/api/v1/admin/discussions/by-external/...` (admin JWT).",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "parent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "viewer_id",
            "required": false,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "include_deleted",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "path",
            "name": "externalId",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "body": {
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "depth": {
                            "type": "integer"
                          },
                          "descendantCount": {
                            "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "discussionCreated": {
                            "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                            "type": "boolean"
                          },
                          "discussionId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "editWindowClosesAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "editedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isPinned": {
                            "type": "boolean"
                          },
                          "parentId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "replyCount": {
                            "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "status": {
                            "enum": [
                              "published",
                              "pending",
                              "deleted",
                              "hidden",
                              "removed"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "discussionId",
                          "userId",
                          "depth",
                          "body",
                          "status",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List comments by publisher external id",
        "tags": [
          "Comments"
        ]
      },
      "post": {
        "description": "Creates a comment against the discussion identified by the tenant-scoped `external_id`. If no discussion exists for that id, one is materialised in the same request. Supply the optional `title` field to give the discussion a human-readable name — when omitted the title defaults to the `external_id`. Existing discussions are unaffected (title is only stored on first creation). Emits `comment_created` SSE. Idempotent — pass `Idempotency-Key: <uuid>` to safely retry.",
        "parameters": [
          {
            "in": "path",
            "name": "externalId",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "body": {
                    "maxLength": 20000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "parent_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "title": {
                    "description": "Optional title for the discussion. Used only when this request materialises a new discussion — existing discussions are unaffected. When omitted, the discussion title defaults to the `externalId`. Must contain at least one non-whitespace character.",
                    "maxLength": 500,
                    "minLength": 1,
                    "pattern": "\\S",
                    "type": "string"
                  },
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured — the acting user then comes from the identity proof.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "body"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Create a comment keyed on publisher external id (lazy-creates discussion)",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/discussions/{discussionId}/archive": {
      "post": {
        "description": "Marks the discussion `archived` — hides it from default listings but preserves comments for audit. Admin-only. Emits a `discussion_archived` SSE event with `actor`, `at`, and (when supplied via the optional `{ reason }` body) `reason`.",
        "parameters": [
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentCount": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "title",
                        "status",
                        "commentCount",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Archive a discussion (soft retire)",
        "tags": [
          "Discussions"
        ]
      }
    },
    "/api/v1/discussions/{discussionId}/comments": {
      "get": {
        "description": "Returns comments in cursor-paginated order. Supports filtering by `parent_id` (pass `null` for top-level only) and `sort`. Rows carry the viewer's own reactions and pending comments when the GET sends a valid identity assertion; `viewer_id` is honoured only in trust mode (dev/test) and ignored in verify mode. Dual-auth: available under `/api/v1/discussions/...` (API-key) and `/api/v1/admin/discussions/...` (admin JWT).",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "parent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "viewer_id",
            "required": false,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "include_deleted",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "body": {
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "depth": {
                            "type": "integer"
                          },
                          "descendantCount": {
                            "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "discussionCreated": {
                            "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                            "type": "boolean"
                          },
                          "discussionId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "editWindowClosesAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "editedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isPinned": {
                            "type": "boolean"
                          },
                          "parentId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "replyCount": {
                            "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "status": {
                            "enum": [
                              "published",
                              "pending",
                              "deleted",
                              "hidden",
                              "removed"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "discussionId",
                          "userId",
                          "depth",
                          "body",
                          "status",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List comments for a discussion (paginated)",
        "tags": [
          "Comments"
        ]
      },
      "post": {
        "description": "Publisher end-users create a comment against a discussion. Replies set `parent_id`. `user_id` is the external SDK identity, resolved to the tenant-scoped internal user. Emits a `comment_created` SSE event. Idempotent — pass `Idempotency-Key: <uuid>` to safely retry.",
        "parameters": [
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "body": {
                    "maxLength": 20000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "parent_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured — the acting user then comes from the identity proof.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "body"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "body": {
                          "type": "string"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "depth": {
                          "type": "integer"
                        },
                        "descendantCount": {
                          "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "discussionCreated": {
                          "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                          "type": "boolean"
                        },
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "editWindowClosesAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "editedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isPinned": {
                          "type": "boolean"
                        },
                        "parentId": {
                          "format": "uuid",
                          "nullable": true,
                          "type": "string"
                        },
                        "replyCount": {
                          "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                          "minimum": 0,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "published",
                            "pending",
                            "deleted",
                            "hidden",
                            "removed"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "userId": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "discussionId",
                        "userId",
                        "depth",
                        "body",
                        "status",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "security": [
          {
            "apiKey": [],
            "identityAssertion": [],
            "identitySignature": []
          }
        ],
        "summary": "Create a top-level or reply comment",
        "tags": [
          "Comments"
        ]
      }
    },
    "/api/v1/discussions/{discussionId}/lock": {
      "delete": {
        "description": "Reverses a prior lock. Requires admin API key or an admin JWT with the `moderate_discussion` capability. Emits a `discussion_unlocked` SSE event with `actor` and `at`.",
        "parameters": [
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentCount": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "title",
                        "status",
                        "commentCount",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Unlock a discussion",
        "tags": [
          "Discussions"
        ]
      },
      "post": {
        "description": "Locks new comments on a discussion. Requires admin API key or an admin JWT with the `moderate_discussion` capability. Emits a `discussion_locked` SSE event with `actor`, `at`, and (when supplied via the optional `{ reason }` body) `reason`.",
        "parameters": [
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentCount": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "title",
                        "status",
                        "commentCount",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Lock a discussion (admin moderation)",
        "tags": [
          "Discussions"
        ]
      }
    },
    "/api/v1/discussions/{discussionId}/reactions": {
      "get": {
        "description": "Aggregated reaction counts grouped by `reaction_type`. Read-only; dual-auth available to both widgets and the admin panel.",
        "parameters": [
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "count": {
                            "type": "integer"
                          },
                          "reactionType": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "reactionType",
                          "count"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Get reaction counts for a discussion",
        "tags": [
          "Discussions"
        ]
      }
    },
    "/api/v1/discussions/{externalId}": {
      "get": {
        "description": "Looks up a discussion by the tenant-scoped publisher `external_id`. Dual-auth: available under both the API-key and admin-JWT mounts.",
        "parameters": [
          {
            "in": "path",
            "name": "externalId",
            "required": true,
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "commentCount": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "title",
                        "status",
                        "commentCount",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Fetch a discussion by publisher external id",
        "tags": [
          "Discussions"
        ]
      }
    },
    "/api/v1/identity/config": {
      "get": {
        "description": "Returns whether the tenant is in trust or verify mode plus the active secret kid, previous-secret overlap expiry, and last-rotated timestamp. Never returns the secret. Any admin principal may read; rotation requires `manage_settings`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "kid": {
                          "nullable": true,
                          "type": "string"
                        },
                        "mode": {
                          "enum": [
                            "trust",
                            "verify"
                          ],
                          "type": "string"
                        },
                        "oidcIssuerCount": {
                          "type": "integer"
                        },
                        "previousSecretExpiresAt": {
                          "nullable": true,
                          "type": "string"
                        },
                        "rotatedAt": {
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "mode",
                        "kid",
                        "previousSecretExpiresAt",
                        "rotatedAt",
                        "oidcIssuerCount"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Read identity-verification mode and signing-secret metadata",
        "tags": [
          "Identity"
        ]
      }
    },
    "/api/v1/identity/issuers": {
      "get": {
        "description": "Returns the configured OIDC issuer rows (secret-free public config). Any admin principal may read; mutations require `manage_settings`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "audience": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "displayNameClaim": {
                            "nullable": true,
                            "type": "string"
                          },
                          "externalIdClaim": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "issuer": {
                            "type": "string"
                          },
                          "jwksUri": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "issuer",
                          "audience",
                          "jwksUri",
                          "externalIdClaim",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List the tenant’s OIDC trusted-identity issuers",
        "tags": [
          "Identity"
        ]
      },
      "post": {
        "description": "Takes an issuer URL as a *discovery locator*, fetches its `/.well-known/openid-configuration`, derives and test-fetches the JWKS (SSRF-guarded), and stores the **canonical** discovery `issuer` + derived `jwks_uri`. Fails 422 if discovery/test-fetch fails (no row written); 409 on a duplicate `(issuer, audience)`. Requires `manage_settings`.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "audience": {
                    "maxLength": 512,
                    "minLength": 1,
                    "type": "string"
                  },
                  "displayNameClaim": {
                    "maxLength": 128,
                    "minLength": 1,
                    "type": "string"
                  },
                  "externalIdClaim": {
                    "maxLength": 128,
                    "minLength": 1,
                    "type": "string"
                  },
                  "issuer": {
                    "maxLength": 512,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "issuer",
                  "audience"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "audience": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "displayNameClaim": {
                          "nullable": true,
                          "type": "string"
                        },
                        "externalIdClaim": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        },
                        "issuer": {
                          "type": "string"
                        },
                        "jwksUri": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "issuer",
                        "audience",
                        "jwksUri",
                        "externalIdClaim",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Add an OIDC trusted-identity issuer (discovery + test-fetch before save)",
        "tags": [
          "Identity"
        ]
      }
    },
    "/api/v1/identity/issuers/{id}": {
      "delete": {
        "description": "Deletes the issuer row. Requires `manage_settings`.",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "deletedAt": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "deletedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Remove an OIDC trusted-identity issuer",
        "tags": [
          "Identity"
        ]
      }
    },
    "/api/v1/identity/rotate-secret": {
      "post": {
        "description": "Generates a new HMAC signing secret for verify-mode identity assertions and returns it in the response body (only time it is shown). The first call flips the tenant from trust mode to verify mode; subsequent calls rotate, keeping the prior secret valid for a 24 h overlap (`previousSecretExpiresAt`). The secret is never written to the audit log. Dual-auth: both paths require `manage_settings`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "kid": {
                          "type": "string"
                        },
                        "previousSecretExpiresAt": {
                          "nullable": true,
                          "type": "string"
                        },
                        "secret": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "secret",
                        "kid",
                        "previousSecretExpiresAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Mint or rotate the tenant identity-verification signing secret",
        "tags": [
          "Identity"
        ]
      }
    },
    "/api/v1/keys": {
      "get": {
        "description": "Returns all non-revoked API keys for the current tenant. Raw token values are never included — only metadata (id, label, prefix, role).",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "capabilities": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expiresAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isAdmin": {
                            "type": "boolean"
                          },
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "label",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List API keys for the current tenant",
        "tags": [
          "API Keys"
        ]
      },
      "post": {
        "description": "Generates a new scoped API key and returns it once in plaintext. The raw token is unrecoverable after this response — store it securely. The `capabilities` set governs what the key may do; an empty set mints a publisher/widget key. `expiresAt` is optional (omit for no expiry).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "capabilities": {
                    "items": {
                      "enum": [
                        "manage_admins",
                        "change_admin_role",
                        "moderate_content",
                        "ban_users",
                        "anonymize_users",
                        "moderate_discussion",
                        "manage_api_keys",
                        "manage_webhooks",
                        "manage_settings",
                        "view_analytics",
                        "export_user_data"
                      ],
                      "type": "string"
                    },
                    "type": "array",
                    "uniqueItems": true
                  },
                  "expiresAt": {
                    "format": "date-time",
                    "nullable": true,
                    "type": "string"
                  },
                  "label": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "label",
                  "capabilities"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "capabilities": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "expiresAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isAdmin": {
                          "type": "boolean"
                        },
                        "key": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "label",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Create a new API key for the current tenant",
        "tags": [
          "API Keys"
        ]
      }
    },
    "/api/v1/keys/{keyId}": {
      "delete": {
        "description": "Marks the API key as revoked. Subsequent requests bearing this key will be rejected with 401. The revoked key row is returned for audit purposes.",
        "parameters": [
          {
            "in": "path",
            "name": "keyId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "capabilities": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "expiresAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isAdmin": {
                          "type": "boolean"
                        },
                        "key": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "label",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Revoke an API key by id",
        "tags": [
          "API Keys"
        ]
      }
    },
    "/api/v1/moderation/filters": {
      "get": {
        "description": "Returns every blacklist/greylist word filter configured for the tenant. Dual-auth: mirrored under API-key and admin-JWT paths; both paths require `moderate_content`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isRegex": {
                            "type": "boolean"
                          },
                          "pattern": {
                            "type": "string"
                          },
                          "severity": {
                            "enum": [
                              "blacklist",
                              "greylist"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "pattern",
                          "severity",
                          "isRegex",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List tenant word filters",
        "tags": [
          "Moderation"
        ]
      },
      "put": {
        "description": "Wholesale replace of the tenant word-filter list (up to 500 entries). Existing filters are removed. Dual-auth: mirrored under API-key and admin-JWT paths; both paths require `moderate_content`.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "filters": {
                    "items": {
                      "additionalProperties": false,
                      "properties": {
                        "is_regex": {
                          "type": "boolean"
                        },
                        "pattern": {
                          "maxLength": 500,
                          "minLength": 1,
                          "type": "string"
                        },
                        "severity": {
                          "enum": [
                            "blacklist",
                            "greylist"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "pattern",
                        "severity"
                      ],
                      "type": "object"
                    },
                    "maxItems": 500,
                    "type": "array"
                  }
                },
                "required": [
                  "filters"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isRegex": {
                            "type": "boolean"
                          },
                          "pattern": {
                            "type": "string"
                          },
                          "severity": {
                            "enum": [
                              "blacklist",
                              "greylist"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "pattern",
                          "severity",
                          "isRegex",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Replace the full set of tenant word filters",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/moderation/log": {
      "get": {
        "description": "Returns cursor-paginated moderation actions (approve/reject/auto_block/auto_pending) taken on tenant comments. Dual-auth: mirrored under API-key and admin-JWT paths; both paths require `moderate_content`.",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "action": {
                            "enum": [
                              "approve",
                              "reject",
                              "auto_block",
                              "auto_pending",
                              "auto_approve",
                              "hide"
                            ],
                            "type": "string"
                          },
                          "commentId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "moderatorId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "reason": {
                            "nullable": true,
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "commentId",
                          "action",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List the tenant moderation audit log",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/moderation/queue": {
      "get": {
        "description": "Returns cursor-paginated comments in `pending` status. Dual-auth: mirrored under API-key and admin-JWT paths; both paths require `moderate_content`.",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "body": {
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "depth": {
                            "type": "integer"
                          },
                          "descendantCount": {
                            "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "discussionCreated": {
                            "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                            "type": "boolean"
                          },
                          "discussionId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "editWindowClosesAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "editedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isPinned": {
                            "type": "boolean"
                          },
                          "parentId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "replyCount": {
                            "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "status": {
                            "enum": [
                              "published",
                              "pending",
                              "deleted",
                              "hidden",
                              "removed"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "discussionId",
                          "userId",
                          "depth",
                          "body",
                          "status",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List pending comments awaiting moderation",
        "tags": [
          "Moderation"
        ]
      }
    },
    "/api/v1/preferences": {
      "get": {
        "description": "Returns a cursor-paginated list of all preference keys for the acting end-user. Each item carries the first (lowest-position) value for that key. Reads are not cached — the result set is unbounded.",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Required in trust mode (dev/test); ignored in production (identity comes from headers).",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "value": {}
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List all preference keys (paginated)",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}": {
      "delete": {
        "description": "Deletes the preference key and all its items. Returns 404 when the key does not exist. The delete is applied synchronously.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "deleted": {
                          "type": "boolean"
                        },
                        "key": {
                          "type": "string"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Delete a preference key",
        "tags": [
          "Preferences"
        ]
      },
      "get": {
        "description": "Returns the first (lowest-position) item value for the given key. Served from Redis cache when warm. Returns 404 when the key does not exist.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "value": {}
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Get a preference value by key",
        "tags": [
          "Preferences"
        ]
      },
      "put": {
        "description": "Replaces the preference key with a single value. If the key held multiple items (from prior pushes) they are deleted. The write is enqueued — the response reflects intent, not committed DB state.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "value": {
                    "description": "Any JSON value to store."
                  }
                },
                "required": [
                  "value"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "value": {}
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Set a preference key (destructive replace)",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/items": {
      "get": {
        "description": "Returns all items for the given preference key ordered by position. Served from Redis cache when warm. Returns 404 when the key does not exist.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "items": {
                          "items": {
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "value": {}
                            },
                            "type": "object"
                          },
                          "type": "array"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List all items in a preference list",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/items/{itemId}": {
      "delete": {
        "description": "Removes the item identified by `itemId`. Returns 404 when the item does not exist under the given key for this user. The write is enqueued.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "itemId",
            "required": true,
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Remove a specific preference list item",
        "tags": [
          "Preferences"
        ]
      },
      "put": {
        "description": "Replaces the value of the item at `itemId`. Returns 404 when the item does not exist under the given key for this user. The write is enqueued.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "itemId",
            "required": true,
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "value": {
                    "description": "Any JSON value to store."
                  }
                },
                "required": [
                  "value"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Update a specific preference list item",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/length": {
      "get": {
        "description": "Returns the item count for the given key. Returns `{ length: 0 }` when the key does not exist — no 404. Not cached.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "length": {
                          "type": "integer"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Get the number of items in a preference list",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/pop": {
      "post": {
        "description": "Removes the item at the highest position. Returns 404 when the key does not exist. The write is enqueued — the response reflects intent, not committed DB state.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {},
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Pop the last item from a preference list",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/push": {
      "post": {
        "description": "Appends a new item to the preference key list at the highest position + 1. The item id is pre-generated and returned immediately — the caller can reference it before the consumer commits the row. The write is enqueued.",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "description": "Required in trust mode (dev/test); ignored when identity verification is configured.",
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "value": {
                    "description": "Any JSON value to store."
                  }
                },
                "required": [
                  "value"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      },
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Push a value onto a preference list",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/preferences/{key}/search": {
      "get": {
        "description": "Returns items whose JSON value contains the query value (`@>` containment). `value` is a URL-encoded JSON string. Exact JSON equality for v1. Not cached. `limit` caps the result set (default 100, max 100).",
        "parameters": [
          {
            "description": "URL-encoded JSON string to match against item values.",
            "in": "query",
            "name": "value",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum number of results to return (default 100, max 100).",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Required in trust mode (dev/test); ignored in production (identity comes from headers).",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "maxLength": 255,
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "value": {}
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Search preference list items by value",
        "tags": [
          "Preferences"
        ]
      }
    },
    "/api/v1/settings": {
      "get": {
        "description": "Returns the tenant settings object merged on top of platform defaults. Dual-auth: mirrored under API-key and admin-JWT paths.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "allowedReactions": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "discussionExternalIdPattern": {
                          "type": "string"
                        },
                        "discussionSourceUrlTemplate": {
                          "maxLength": 2048,
                          "type": "string"
                        },
                        "editWindowMinutes": {
                          "type": "integer"
                        },
                        "emitExternalReactorId": {
                          "type": "boolean"
                        },
                        "maxCommentLength": {
                          "type": "integer"
                        },
                        "maxNestingDepth": {
                          "type": "integer"
                        },
                        "moderationEnabled": {
                          "type": "boolean"
                        },
                        "notificationsEnabled": {
                          "type": "boolean"
                        },
                        "rateLimit": {
                          "additionalProperties": false,
                          "properties": {
                            "commentsPerMinute": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "commentsPerMinute"
                          ],
                          "type": "object"
                        },
                        "sports": {
                          "additionalProperties": true,
                          "properties": {
                            "basketball": {
                              "type": "boolean"
                            },
                            "football": {
                              "type": "boolean"
                            },
                            "ice_hockey": {
                              "type": "boolean"
                            },
                            "tennis": {
                              "type": "boolean"
                            }
                          },
                          "type": "object"
                        }
                      },
                      "required": [
                        "moderationEnabled",
                        "maxCommentLength",
                        "allowedReactions",
                        "rateLimit",
                        "notificationsEnabled"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Read merged tenant settings",
        "tags": [
          "Settings"
        ]
      },
      "put": {
        "description": "Merges the supplied keys into the stored tenant settings; unspecified keys are untouched. Requires the `manage_settings` capability (both auth paths). Dual-auth: mirrored under API-key and admin-JWT paths.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "aiModerationBillingAlertEmail": {
                    "maxLength": 254,
                    "type": "string"
                  },
                  "aiModerationEnabled": {
                    "type": "boolean"
                  },
                  "allowedReactions": {
                    "items": {
                      "maxLength": 50,
                      "minLength": 1,
                      "type": "string"
                    },
                    "maxItems": 50,
                    "type": "array"
                  },
                  "discussionExternalIdPattern": {
                    "maxLength": 500,
                    "minLength": 1,
                    "nullable": true,
                    "type": "string"
                  },
                  "discussionSourceUrlTemplate": {
                    "maxLength": 2048,
                    "nullable": true,
                    "type": "string"
                  },
                  "editWindowMinutes": {
                    "maximum": 1440,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "emitExternalReactorId": {
                    "type": "boolean"
                  },
                  "identityAssertionFreshnessSec": {
                    "maximum": 86400,
                    "minimum": 60,
                    "type": "integer"
                  },
                  "maxApiKeys": {
                    "maximum": 20,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "maxCommentLength": {
                    "maximum": 20000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "maxNestingDepth": {
                    "maximum": 10,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "maxWebhookDeliveriesPerMinute": {
                    "maximum": 60000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "maxWebhookEndpoints": {
                    "maximum": 1000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "moderationEnabled": {
                    "type": "boolean"
                  },
                  "notificationsEnabled": {
                    "type": "boolean"
                  },
                  "rateLimit": {
                    "additionalProperties": false,
                    "properties": {
                      "commentsPerMinute": {
                        "maximum": 1000,
                        "minimum": 1,
                        "type": "integer"
                      }
                    },
                    "type": "object"
                  },
                  "sports": {
                    "additionalProperties": false,
                    "properties": {
                      "basketball": {
                        "type": "boolean"
                      },
                      "football": {
                        "type": "boolean"
                      },
                      "ice_hockey": {
                        "type": "boolean"
                      },
                      "tennis": {
                        "type": "boolean"
                      }
                    },
                    "type": "object"
                  },
                  "sseBufferSize": {
                    "maximum": 10000,
                    "minimum": 10,
                    "type": "integer"
                  },
                  "sseHeartbeatMs": {
                    "maximum": 120000,
                    "minimum": 5000,
                    "type": "integer"
                  },
                  "sseMaxClientsPerDiscussion": {
                    "maximum": 10000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "sseMaxClientsPerTenant": {
                    "maximum": 100000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "userInactivityAnonymizeDays": {
                    "maximum": 3650,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "userInactivityDeactivateDays": {
                    "maximum": 3650,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "userInactivityWarnDays": {
                    "maximum": 3650,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "userPreferenceCacheTtlSec": {
                    "maximum": 86400,
                    "minimum": 60,
                    "type": "integer"
                  },
                  "webhookAutoDisableThreshold": {
                    "maximum": 1000,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "webhookCircuitCooldownMs": {
                    "maximum": 3600000,
                    "minimum": 1000,
                    "type": "integer"
                  },
                  "webhookCircuitFailThreshold": {
                    "maximum": 100,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "webhookRetryBaseMs": {
                    "maximum": 60000,
                    "minimum": 100,
                    "type": "integer"
                  },
                  "webhookRetryMax": {
                    "maximum": 10,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "webhookTimeoutMs": {
                    "maximum": 60000,
                    "minimum": 1000,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "allowedReactions": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "discussionExternalIdPattern": {
                          "type": "string"
                        },
                        "discussionSourceUrlTemplate": {
                          "maxLength": 2048,
                          "type": "string"
                        },
                        "editWindowMinutes": {
                          "type": "integer"
                        },
                        "emitExternalReactorId": {
                          "type": "boolean"
                        },
                        "maxCommentLength": {
                          "type": "integer"
                        },
                        "maxNestingDepth": {
                          "type": "integer"
                        },
                        "moderationEnabled": {
                          "type": "boolean"
                        },
                        "notificationsEnabled": {
                          "type": "boolean"
                        },
                        "rateLimit": {
                          "additionalProperties": false,
                          "properties": {
                            "commentsPerMinute": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "commentsPerMinute"
                          ],
                          "type": "object"
                        },
                        "sports": {
                          "additionalProperties": true,
                          "properties": {
                            "basketball": {
                              "type": "boolean"
                            },
                            "football": {
                              "type": "boolean"
                            },
                            "ice_hockey": {
                              "type": "boolean"
                            },
                            "tennis": {
                              "type": "boolean"
                            }
                          },
                          "type": "object"
                        }
                      },
                      "required": [
                        "moderationEnabled",
                        "maxCommentLength",
                        "allowedReactions",
                        "rateLimit",
                        "notificationsEnabled"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Partial-merge-update tenant settings",
        "tags": [
          "Settings"
        ]
      }
    },
    "/api/v1/stream/ticket": {
      "post": {
        "description": "Returns a 60s single-use ticket scoped to one tenant and one discussion. Use it as `?ticket=<value>` on the SSE stream URL. Consumed atomically via `GETDEL`; reusing the same ticket returns 401.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "discussionId": {
                    "format": "uuid",
                    "type": "string"
                  }
                },
                "required": [
                  "discussionId"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "discussionStatus": {
                          "description": "The discussion's current lifecycle status at mint time. Lets publishers seed lock/archive UI before the first SSE event arrives.",
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "expiresAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "ticket": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "ticket",
                        "expiresAt",
                        "discussionStatus"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Mint a short-lived SSE ticket",
        "tags": [
          "Stream"
        ]
      }
    },
    "/api/v1/stream/ticket-by-external": {
      "post": {
        "description": "Resolves the tenant-scoped `external_id` to an internal discussion UUID and mints a 60s single-use ticket scoped to it. 404 when no discussion exists yet. Returns `{ ticket, discussionId, expiresAt }` — use `discussionId` on the SSE attach URL.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "externalId": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "externalId"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "discussionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "discussionStatus": {
                          "description": "The discussion's current lifecycle status at mint time. Lets publishers seed lock/archive UI before the first SSE event arrives.",
                          "enum": [
                            "open",
                            "locked",
                            "archived"
                          ],
                          "type": "string"
                        },
                        "expiresAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "ticket": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "ticket",
                        "discussionId",
                        "expiresAt",
                        "discussionStatus"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Mint an SSE ticket by publisher external id",
        "tags": [
          "Stream"
        ]
      }
    },
    "/api/v1/stream/{discussionId}": {
      "get": {
        "description": "Server-Sent Events stream. Auth via `X-API-Key` header, `?ticket=` (preferred for browsers; mint via `POST /api/v1/stream/ticket`), or `?token=` (deprecated — emits `Deprecation: true` and `Sunset` response headers). Supports `Last-Event-ID` for replay after reconnect. See `components.schemas.SseEvent` for the per-event `data` payload shapes. Event names: `comment_created`, `comment_edited`, `comment_deleted`, `comment_approved`, `comment_rejected`, `comment_pinned`, `comment_unpinned`, `reaction_toggled`, `discussion_locked`, `discussion_unlocked`, `discussion_archived`, `notification_reply`. Framing events (no domain payload): `connected`, `connection-timeout`.",
        "parameters": [
          {
            "in": "query",
            "name": "token",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ticket",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "discussionId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response"
          }
        },
        "summary": "Subscribe to real-time events for a discussion",
        "tags": [
          "Stream"
        ]
      }
    },
    "/api/v1/users": {
      "get": {
        "description": "Returns a cursor-paginated list of publisher end-users for the resolved tenant. Dual-auth: API-key path requires an admin key; admin-JWT path mirrors the same response.",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "Filter by lifecycle stage. warn_pending = active users with warn_threshold_reached_at set; inactive = auto-deactivated users; anonymized = scrubbed users.",
            "in": "query",
            "name": "lifecycleStatus",
            "required": false,
            "schema": {
              "enum": [
                "warn_pending",
                "inactive",
                "anonymized"
              ],
              "type": "string"
            }
          },
          {
            "description": "Return only users whose updated_at >= since. Lifecycle transitions always set updated_at, making this the correct column for catch-up reconciliation queries.",
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deactivatedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "lastActivityAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "status": {
                            "enum": [
                              "active",
                              "banned",
                              "shadow_banned",
                              "anonymized",
                              "inactive"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "warnThresholdReachedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "externalId",
                          "displayName",
                          "status",
                          "createdAt",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List tenant end-users (cursor paginated)",
        "tags": [
          "Users"
        ]
      },
      "put": {
        "description": "Idempotent upsert keyed by the tenant-scoped `user_id` (external identity from the publisher SDK). Creates on first call, updates `display_name` on subsequent calls. Intended to be fired whenever a logged-in end-user interacts with widgets. **Rejected with 409 on verify-mode tenants** — identity is provisioned from the signed assertion, not this endpoint.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "display_name": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "user_id": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "user_id",
                  "display_name"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Upsert a publisher end-user",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/by-external/{externalId}/export": {
      "get": {
        "description": "Collects user row, comments, reactions, poll votes, comment reports, moderation actions, and preferences. Returns a JSON file download. Requires the `export_user_data` capability (both auth paths). Writes an admin_audit_log entry.",
        "parameters": [
          {
            "in": "path",
            "name": "externalId",
            "required": true,
            "schema": {
              "maxLength": 255,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "commentReports": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "commentId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "description": {
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "reason": {
                            "enum": [
                              "spam",
                              "harassment",
                              "hate_speech",
                              "misinformation",
                              "other"
                            ],
                            "type": "string"
                          },
                          "reporterUserId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "resolvedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "status": {
                            "enum": [
                              "pending",
                              "resolved",
                              "dismissed"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "commentId",
                          "reporterUserId",
                          "reason",
                          "status",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "comments": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "body": {
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "depth": {
                            "type": "integer"
                          },
                          "descendantCount": {
                            "description": "Comment-list and `/replies` routes only. Replies at any depth that the caller can open: each one and every reply above it pass the same visibility rules as the listing.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "discussionCreated": {
                            "description": "Present only on responses from the by-external comment-create endpoint. `true` when this request materialised the discussion; `false` when the discussion already existed and the supplied `title` was discarded.",
                            "type": "boolean"
                          },
                          "discussionId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "editWindowClosesAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "editedAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isPinned": {
                            "type": "boolean"
                          },
                          "parentId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "replyCount": {
                            "description": "Comment-list and `/replies` routes only. Direct replies visible to the caller.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "status": {
                            "enum": [
                              "published",
                              "pending",
                              "deleted",
                              "hidden",
                              "removed"
                            ],
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "discussionId",
                          "userId",
                          "depth",
                          "body",
                          "status",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "exportedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "moderationActions": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "action": {
                            "enum": [
                              "approve",
                              "reject",
                              "auto_block",
                              "auto_pending",
                              "auto_approve",
                              "hide"
                            ],
                            "type": "string"
                          },
                          "commentId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "moderatorId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          },
                          "reason": {
                            "nullable": true,
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "commentId",
                          "action",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "pollVotes": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "ballotKey": {
                            "nullable": true,
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "optionId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "pollId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "nullable": true,
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "pollId",
                          "optionId",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "preferences": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "items": {
                            "items": {
                              "additionalProperties": true,
                              "properties": {
                                "createdAt": {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                "id": {
                                  "type": "string"
                                },
                                "position": {
                                  "type": "integer"
                                },
                                "preferenceId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                "value": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "additionalProperties": true,
                                      "type": "object"
                                    },
                                    {
                                      "items": {},
                                      "type": "array"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "preferenceId",
                                "value",
                                "position",
                                "createdAt",
                                "updatedAt"
                              ],
                              "type": "object"
                            },
                            "type": "array"
                          },
                          "key": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "userId",
                          "key",
                          "createdAt",
                          "updatedAt",
                          "items"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "reactions": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "commentId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "reactionType": {
                            "type": "string"
                          },
                          "userId": {
                            "format": "uuid",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "commentId",
                          "userId",
                          "reactionType",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "tenant": {
                      "type": "string"
                    },
                    "user": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "exportedAt",
                    "tenant",
                    "user",
                    "comments",
                    "reactions",
                    "pollVotes",
                    "commentReports",
                    "moderationActions",
                    "preferences"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Export all personal data for a tenant end-user (GDPR data-subject access)",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/id/{userId}": {
      "get": {
        "description": "Returns a single end-user identified by the internal Edgar UUID. Returns 404 if the user does not exist. Mirrored under admin-JWT and admin-API-key paths.",
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Fetch a tenant end-user by internal UUID",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/id/{userId}/anonymize": {
      "post": {
        "description": "Strips personally identifiable information from the user record and marks them `anonymized`. Irreversible. Requires the `anonymize_users` capability (both auth paths). Idempotent — re-running with the same `Idempotency-Key` replays the original successful response.",
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Anonymise a tenant end-user (GDPR erasure)",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/id/{userId}/ban": {
      "post": {
        "description": "Marks the end-user as banned; they can no longer post, react, or vote. Idempotent — repeated calls remain a no-op on an already-banned user. Requires the `ban_users` capability (both auth paths).",
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Ban a tenant end-user",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/id/{userId}/shadow-ban": {
      "post": {
        "description": "Marks the user as shadow-banned — their posts appear to them but are hidden from other readers. Idempotent. Requires the `ban_users` capability (both auth paths).",
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Shadow-ban a tenant end-user",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/id/{userId}/unban": {
      "post": {
        "description": "Restores a banned or shadow-banned user to active status. Idempotent. Requires the `ban_users` capability (both auth paths).",
        "parameters": [
          {
            "in": "path",
            "name": "userId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Lift a ban or shadow-ban on a tenant end-user",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/users/{externalId}": {
      "get": {
        "description": "Looks up a tenant-scoped user by the publisher-supplied `externalId`. Returns 404 when the id has never been upserted.",
        "parameters": [
          {
            "in": "path",
            "name": "externalId",
            "required": true,
            "schema": {
              "minLength": 1,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deactivatedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastActivityAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "active",
                            "banned",
                            "shadow_banned",
                            "anonymized",
                            "inactive"
                          ],
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "warnThresholdReachedAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "externalId",
                        "displayName",
                        "status",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Fetch a publisher end-user by external id",
        "tags": [
          "Users"
        ]
      }
    },
    "/api/v1/webhooks": {
      "get": {
        "description": "Returns every webhook endpoint registered for the tenant. Secrets are omitted from list output. Dual-auth: both paths require `manage_webhooks`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "description": {
                            "nullable": true,
                            "type": "string"
                          },
                          "events": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "secret": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "verificationReason": {
                            "type": "string"
                          },
                          "verified": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "url",
                          "events",
                          "isActive",
                          "createdAt",
                          "updatedAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List tenant webhook endpoints",
        "tags": [
          "Webhooks"
        ]
      },
      "post": {
        "description": "Registers a new webhook endpoint subscribed to the supplied event list. Response includes the signing `secret` (shown only on create + rotate). Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`. Idempotent — pass `Idempotency-Key: <uuid>` to avoid duplicate endpoints on retries.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "description": {
                    "maxLength": 500,
                    "type": "string"
                  },
                  "events": {
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 20,
                    "minItems": 1,
                    "type": "array"
                  },
                  "url": {
                    "maxLength": 2000,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "url",
                  "events"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "description": {
                          "nullable": true,
                          "type": "string"
                        },
                        "events": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "secret": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "verificationReason": {
                          "type": "string"
                        },
                        "verified": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "url",
                        "events",
                        "isActive",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Create a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/events": {
      "get": {
        "description": "Returns the array of string event identifiers (e.g. `comment.created`) that a webhook endpoint can subscribe to. Dual-auth: mirrored under API-key and admin-JWT paths; both paths require `manage_webhooks`.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List webhook event types the platform emits",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}": {
      "delete": {
        "description": "Permanently removes the endpoint and its delivery history. Returns `{ id, deletedAt }`. Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Delete a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      },
      "patch": {
        "description": "Partial update of url, events, is_active, or description. Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "description": {
                    "maxLength": 500,
                    "type": "string"
                  },
                  "events": {
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 20,
                    "minItems": 1,
                    "type": "array"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "url": {
                    "maxLength": 2000,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "description": {
                          "nullable": true,
                          "type": "string"
                        },
                        "events": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "secret": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "verificationReason": {
                          "type": "string"
                        },
                        "verified": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "url",
                        "events",
                        "isActive",
                        "createdAt",
                        "updatedAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Update a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/deliveries": {
      "get": {
        "description": "Cursor-paginated delivery history filterable by `status`, `event_type`, and an `after`/`before` date window. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "enum": [
                "pending",
                "success",
                "failed",
                "retrying",
                "dead_letter"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "event_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "attempts": {
                            "type": "integer"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "endpointId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "eventType": {
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "lastAttemptAt": {
                            "format": "date-time",
                            "nullable": true,
                            "type": "string"
                          },
                          "responseBody": {
                            "nullable": true,
                            "type": "string"
                          },
                          "responseStatus": {
                            "nullable": true,
                            "type": "integer"
                          },
                          "status": {
                            "enum": [
                              "pending",
                              "success",
                              "failed",
                              "retrying",
                              "dead_letter"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "endpointId",
                          "eventType",
                          "status",
                          "attempts",
                          "createdAt"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/ApiMeta"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "List delivery attempts for a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/deliveries/{deliveryId}/replay": {
      "post": {
        "description": "Creates a fresh delivery row with the original payload and queues it for dispatch. Only `failed` or `dead_letter` rows can be replayed; in-flight rows return 422. Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "deliveryId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "attempts": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "endpointId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "eventType": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastAttemptAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "responseBody": {
                          "nullable": true,
                          "type": "string"
                        },
                        "responseStatus": {
                          "nullable": true,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "pending",
                            "success",
                            "failed",
                            "retrying",
                            "dead_letter"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "endpointId",
                        "eventType",
                        "status",
                        "attempts",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Replay a failed webhook delivery",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/purge-deliveries": {
      "post": {
        "description": "Operator cleanup — deletes all delivery attempts for this endpoint and returns the count. Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "deleted": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "deleted"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Purge delivery history for a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/rotate-secret": {
      "post": {
        "description": "Generates a new HMAC signing secret and returns it in the response body (only time it is shown). Secret is never written to the audit log. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "previousSecretExpiresAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "secret": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "secret",
                        "previousSecretExpiresAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Rotate the signing secret on a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/test": {
      "post": {
        "description": "Enqueues a test event to the endpoint and returns the resulting delivery row. Useful for verifying URL reachability and signing. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "properties": {
                        "attempts": {
                          "type": "integer"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "endpointId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "eventType": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "lastAttemptAt": {
                          "format": "date-time",
                          "nullable": true,
                          "type": "string"
                        },
                        "responseBody": {
                          "nullable": true,
                          "type": "string"
                        },
                        "responseStatus": {
                          "nullable": true,
                          "type": "integer"
                        },
                        "status": {
                          "enum": [
                            "pending",
                            "success",
                            "failed",
                            "retrying",
                            "dead_letter"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "endpointId",
                        "eventType",
                        "status",
                        "attempts",
                        "createdAt"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Fire a synthetic test delivery to a webhook endpoint",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/api/v1/webhooks/{webhookId}/verify": {
      "post": {
        "description": "POSTs a signed challenge to the endpoint URL and requires the receiver to echo the `challenge` value in the JSON response body within 30 s. Returns `{ verified, reason? }`. Emits an audit log entry. Dual-auth: both paths require `manage_webhooks`.",
        "parameters": [
          {
            "in": "path",
            "name": "webhookId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": false,
                      "properties": {
                        "reason": {
                          "type": "string"
                        },
                        "verified": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "verified"
                      ],
                      "type": "object"
                    },
                    "error": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "meta": {
                      "enum": [
                        null
                      ],
                      "nullable": true,
                      "type": "object"
                    },
                    "success": {
                      "enum": [
                        true
                      ],
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "error",
                    "meta"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Default Response"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            },
            "description": "Default Response"
          }
        },
        "summary": "Re-run the URL-ownership verification handshake",
        "tags": [
          "Webhooks"
        ]
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ],
  "servers": [
    {
      "url": "https://{slug}.rsmg-engage.com",
      "description": "Your tenant — replace {slug} with your tenant slug.",
      "variables": {
        "slug": {
          "default": "your-tenant",
          "description": "Your tenant slug"
        }
      }
    }
  ],
  "tags": [
    {
      "description": "Publisher end-user identity (upsert, lookup, ban).",
      "name": "Users"
    },
    {
      "description": "Article/page discussion containers.",
      "name": "Discussions"
    },
    {
      "description": "Threaded comments + edit/delete lifecycle.",
      "name": "Comments"
    },
    {
      "description": "Per-comment and per-discussion reactions.",
      "name": "Reactions"
    },
    {
      "description": "Server-Sent Events for real-time updates.",
      "name": "Stream"
    },
    {
      "description": "Approval queue, bulk actions, word filters, reports.",
      "name": "Moderation"
    },
    {
      "description": "Outbound delivery endpoints + delivery log.",
      "name": "Webhooks"
    },
    {
      "description": "Per-tenant moderation / rate-limit settings.",
      "name": "Settings"
    },
    {
      "description": "Per-tenant identity-verification signing secret (verify mode).",
      "name": "Identity"
    },
    {
      "description": "Per-user key-value preference store with list and scalar support.",
      "name": "Preferences"
    },
    {
      "description": "Mint, list, and revoke tenant API keys (scoped capabilities, ADR-0051).",
      "name": "API Keys"
    }
  ]
}
