🛣️ Chat routes
Chat routes are SDK composers, not Express middleware. The inventory and details below document the exact public HTTP and WebSocket endpoints.
Inventory
Details
createChatChannelRoute
Implementation
Endpoint: POST /channels
Access: isAuthenticated() → some(...) → checkIdentityType(...) → isSelf(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), isSelf(['params', 'requestBody', 'ownerId']) ),.
Request: createChatChannelSchema validates the application/json body: Required name and ownerId; optional nullable icon.
Pipeline: createChatChannel → getChatChannelById → createChatChannelTerminator.
Success: 201 with the normalized channel in the response descriptor’s data.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
findChatChannelsRoute
Implementation
Endpoint: GET /channels
Access: isAuthenticated() → some(...) → checkIdentityType(...) → isSelf(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), isSelf(['params', 'requestQuery', 'ownerId']) ),.
Request: findChatChannelsSchema validates query parameters: Optional name, ownerId, and shared pagination fields.
Pipeline: findChatChannels → normalizeChatChannelsListTerminator.
Success: 200 with normalized channels and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
getChatChannelRoute
Implementation
Endpoint: GET /channels/:channelId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsChannel(...) → hasSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsChannel(['params', 'requestParams', 'channelId']), hasSubscription(['params', 'requestParams', 'channelId']) ),.
Request: getChatChannelSchema validates path parameters: Required channelId.
Pipeline: getChatChannelById → normalizeChatChannelTerminator.
Success: 200 with the normalized channel.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
updateChatChannelRoute
Implementation
Endpoint: PATCH /channels/:channelId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsChannel(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsChannel(['params', 'requestParams', 'channelId']) ),.
Request: updateChatChannelSchema validates path parameters and the application/json body: Required channelId; body permits optional name and nullable icon.
Pipeline: updateChatChannel → getChatChannelById → normalizeChatChannelTerminator.
Success: 200 with the updated, normalized channel.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
deleteChatChannelRoute
Implementation
Endpoint: DELETE /channels/:channelId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsChannel(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsChannel(['params', 'requestParams', 'channelId']) ),.
Request: deleteChatChannelSchema validates path parameters: Required channelId.
Pipeline: deleteChatChannel → deleteChatChannelTerminator.
Success: Empty 204 response.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
getChannelMessagesRoute
Implementation
Endpoint: GET /channels/:channelId/messages
Access: isAuthenticated() → hasSubscription(...) → channelExists(...) execute in the source order shown here. Exact invocation: isAuthenticated(), channelExists(['params', 'requestParams', 'channelId']), hasSubscription(['params', 'requestParams', 'channelId']),.
Request: getChannelMessagesSchema validates path and query parameters: Required channelId and optional shared pagination fields.
Pipeline: getChannelMessagesByChannelId → pagination → normalizeChatMessages → response projection.
Success: 200 with normalized messages and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatChannelUnknownError → 500 as shown in its source.View complete source
getChatChannelIconUploadUrlRoute
Implementation
Endpoint: GET /channels/:channelId/icon-upload-url
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsChannel(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsChannel(['params', 'requestParams', 'channelId']) ),.
Request: The shared getSignedImageUploadUrlSchema validates the path channelId and the signed-image upload request contract.
Pipeline: generateChatChannelIconUploadUrl → orThrow.
Success: 200 with { objectId, url }.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps FileStorageServiceError → 500, ChatChannelUnknownError → 500 as shown in its source.View complete source
createChatMessageRoute
Implementation
Endpoint: POST /messages
Access: isAuthenticated() → isSelf(...) → hasSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), isSelf(['params', 'requestBody', 'senderId']), hasSubscription(['params', 'requestBody', 'channelId']),.
Request: createChatMessageSchema validates the application/json body: Required content, senderId, and channelId; optional title.
Pipeline: createChatMessage → getChatMessageById → normalizeChatMessage → orThrow.
Success: 201 with the normalized message and signed attachment URLs.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, FileStorageServiceError → 500, ChatMessageUnexpectedDBError → 500 as shown in its source.View complete source
findChatMessagesRoute
Implementation
Endpoint: GET /messages
Access: isAuthenticated() → some(...) → checkIdentityType(...) → isSelf(...) → hasSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasSubscription(['params', 'requestQuery', 'channelId']), isSelf(['params', 'requestQuery', 'senderId']) ),.
Request: findChatMessagesSchema validates query parameters: Required channelId; optional message filters and pagination.
Pipeline: findChatMessages.
Success: 200 with normalized messages and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, FileStorageServiceError → 500, ChatMessageBlockError → 500 as shown in its source.View complete source
getChatMessageRoute
Implementation
Endpoint: GET /messages/:messageId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsMessage(['params', 'requestParams', 'messageId']) ),.
Request: getChatMessageSchema validates path parameters: Required messageId.
Pipeline: getChatMessageById → normalizeChatMessage → orThrow.
Success: 200 with the normalized message.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, FileStorageServiceError → 500, ChatMessageBlockError → 500 as shown in its source.View complete source
updateChatMessageRoute
Implementation
Endpoint: PATCH /messages/:messageId
Access: isAuthenticated() → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), ownsMessage(['params', 'requestParams', 'messageId']),.
Request: updateChatMessageSchema validates path parameters and the application/json body: Required messageId; optional content, senderId, and title.
Pipeline: updateChatMessage → getChatMessageById.
Success: 200 with the updated, normalized message.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, FileStorageServiceError → 500, ChatMessageBlockError → 500 as shown in its source.View complete source
deleteChatMessageRoute
Implementation
Endpoint: DELETE /messages/:messageId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsMessage(['params', 'requestParams', 'messageId']) ),.
Request: deleteChatMessageSchema validates path parameters: Required messageId.
Pipeline: deleteChatMessage → deleteChatMessageTerminator.
Success: Empty 204 response.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
getChatMessageAttachmentUploadUrlRoute
Implementation
Endpoint: GET /messages/:messageId/attachment-upload-url
Access: isAuthenticated() → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), ownsMessage(['params', 'requestParams', 'messageId']),.
Request: The shared getSignedFileUploadUrlSchema validates the path messageId and the signed-file upload request contract.
Pipeline: generateChatMessageAttachmentUploadUrl → orThrow.
Success: 200 with { objectId, url }.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps FileStorageServiceError → 500, ChatMessageBlockError → 500 as shown in its source.View complete source
streamChatMessagesRoute
Implementation
Endpoint: ws /messages/listen
Access: No active validator. The source comments out isAuthenticated() and hasSubscription(...), so the current WebSocket endpoint does not enforce Bearer/cookie authentication or channel membership.
Request: streamChatMessagesSchema validates query parameters: Required channelId.
Pipeline: streamChatMessages → normalizeChatMessageStream → orThrow, producing the WebSocket subject.
Success: A WebSocket subject that emits normalized inserted messages and serializes each value as JSON.
Failure: No access validator runs. Pipeline mappings are ChatMessageBadRequestError → 400, ChatMessageUnknownError → 500; subject/database failures can also terminate the WebSocket stream.View complete source
createChatMessageAttachmentRoute
Implementation
Endpoint: POST /messages/:messageId/attachments
Access: isAuthenticated() → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), ownsMessage(['params', 'requestParams', 'messageId']),.
Request: createChatMessageAttachmentSchema validates the application/json body: Required UUID objectId and string type.
Pipeline: createChatMessageAttachment → getChatMessageAttachmentById → normalizeChatMessageAttachment → orThrow.
Success: 201 with the normalized attachment { type, url }.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, ChatMessageAttachmentNotFoundBlockError → 404, ChatMessageUnexpectedDBError → 500 as shown in its source.View complete source
deleteChatMessageAttachmentRoute
Implementation
Endpoint: DELETE /messages/:messageId/attachments/:attachmentId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsMessage(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsMessage(['params', 'requestParams', 'messageId']) ),.
Request: deleteChatMessageAttachmentSchema validates path parameters: Required messageId and attachmentId.
Pipeline: deleteChatMessageAttachment → orThrow.
Success: Empty 204 response after metadata and stored file deletion.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageNotFoundBlockError → 404, ChatMessageAttachmentNotFoundBlockError → 404, ChatMessageUnexpectedDBError → 500, ChatMessageBlockError → 500, FileStorageServiceError → 500 as shown in its source.View complete source
createChatMessageTemplateRoute
Implementation
Endpoint: POST /message-templates
Access: isAuthenticated() → some(...) → checkIdentityType(...) → hasOrgRole(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasOrgRole( ['owner', 'admin'], ['params', 'requestBody', 'organizationId'] ) ),.
Request: createChatMessageTemplateSchema validates the application/json body: Required content and title; optional organizationId.
Pipeline: createChatMessageTemplate → getChatMessageTemplateById → orThrow.
Success: 201 with the created template, excluding MongoDB _id.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
getChatMessageTemplateRoute
Implementation
Endpoint: GET /message-templates/:messageTemplateId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → hasOrganizationAccessToMessageTemplate(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasOrganizationAccessToMessageTemplate( ['owner', 'admin'], ['params', 'requestParams', 'messageTemplateId'] ) ),.
Request: getChatMessageTemplateSchema validates path parameters: Required messageTemplateId.
Pipeline: getChatMessageTemplateById → orThrow.
Success: 200 with the template, excluding MongoDB _id.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateUnauthorizedError → 403, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
updateChatMessageTemplateRoute
Implementation
Endpoint: PATCH /message-templates/:messageTemplateId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → hasOrganizationAccessToMessageTemplate(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasOrganizationAccessToMessageTemplate( ['owner', 'admin'], ['params', 'requestParams', 'messageTemplateId'] ) ),.
Request: updateChatMessageTemplateSchema validates path parameters and the application/json body: Required template ID; optional content and title.
Pipeline: updateChatMessageTemplate → getChatMessageTemplateById → orThrow.
Success: 200 with the updated template, excluding MongoDB _id.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateUnauthorizedError → 403, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
deleteChatMessageTemplateRoute
Implementation
Endpoint: DELETE /message-templates/:messageTemplateId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → hasOrganizationAccessToMessageTemplate(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasOrganizationAccessToMessageTemplate( ['owner', 'admin'], ['params', 'requestParams', 'messageTemplateId'] ) ),.
Request: deleteChatMessageTemplateSchema validates path parameters: Required messageTemplateId.
Pipeline: deleteChatMessageTemplate → orThrow.
Success: Empty 204 response.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateUnauthorizedError → 403, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
findChatMessageTemplatesRoute
Implementation
Endpoint: GET /message-templates
Access: isAuthenticated() → checkIdentityType(...) execute in the source order shown here. Exact invocation: isAuthenticated(), checkIdentityType(['admin']).
Request: findChatMessageTemplatesSchema validates query parameters: Shared pagination fields only.
Pipeline: findChatMessageTemplates → pagination → shared normalizeDocuments → orThrow.
Success: 200 with normalized templates and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateUnauthorizedError → 403, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
findChatMessageTemplatesForOrganizationRoute
Implementation
Endpoint: GET /organizations/:organizationId/message-templates
Access: isAuthenticated() → hasOrgRole(...) execute in the source order shown here. Exact invocation: isAuthenticated(), hasOrgRole( ['owner', 'admin'], ['params', 'requestParams', 'organizationId'] ),.
Request: findChatMessageTemplatesForOrganizationSchema validates path and query parameters: Required organizationId and shared pagination fields.
Pipeline: buildFilterToGetChatMessageTemplatesByOrganizationId → findChatMessageTemplates → pagination → shared normalizeDocuments → orThrow.
Success: 200 with normalized templates for the path organization and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatMessageTemplateNotFoundError → 404, ChatMessageTemplateUnauthorizedError → 403, ChatMessageTemplateInternalError → 500, ChatMessageTemplateDbError → 500 as shown in its source.View complete source
upsertChatChannelReadStateRoute
Implementation
Endpoint: PUT /channels/:channelId/read-state
Access: isAuthenticated() → isSelf(...) → hasSubscription(...) → channelExists(...) execute in the source order shown here. Exact invocation: isAuthenticated(), channelExists(['params', 'requestParams', 'channelId']), hasSubscription(['params', 'requestParams', 'channelId']), isSelf(['params', 'requestBody', 'identityId']),.
Request: upsertChatChannelReadStateSchema validates path parameters and the application/json body: Required channelId, identityId, and lastReadMessageId.
Pipeline: findChatMessages.
Success: Empty 204 response after creating or updating the read state.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. This route maps ChatChannelReadStateNotFoundError → 404, ChatChannelReadStateDatabaseError → 500, ChatChannelReadStateUnknownError → 500 as shown in its source.View complete source
createChatSubscriptionRoute
Implementation
Endpoint: POST /subscriptions
Access: isAuthenticated() → some(...) → checkIdentityType(...) → isSelf(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), isSelf(['params', 'requestBody', 'subscribedId']) ),.
Request: createChatSubscriptionSchema validates the application/json body: Required channelId and subscribedId; other subscription fields optional.
Pipeline: createChatSubscription → getChatSubscriptionById → createChatSubscriptionTerminator.
Success: 201 with the created subscription in the response descriptor’s data.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
findChatSubscriptionsRoute
Implementation
Endpoint: GET /subscriptions
Access: isAuthenticated() → some(...) → checkIdentityType(...) → isSelf(...) → ownsChannel(...) → hasSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), hasSubscription(['params', 'requestQuery', 'channelId']), ownsChannel(['params', 'requestQuery', 'channelId']), isSelf(['params', 'requestQuery', 'subscribedId']) ),.
Request: findChatSubscriptionsSchema validates query parameters: Optional subscription filters and shared pagination fields.
Pipeline: findChatSubscriptions → normalizeChatSubscriptionsListTerminator.
Success: 200 with normalized subscriptions and pagination metadata.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
getChatSubscriptionRoute
Implementation
Endpoint: GET /subscriptions/:subscriptionId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsSubscription(['params', 'requestParams', 'subscriptionId']) ),.
Request: getChatSubscriptionSchema validates path parameters: Required subscriptionId.
Pipeline: getChatSubscriptionById → normalizeChatSubscriptionTerminator.
Success: 200 with the subscription excluding MongoDB _id.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source
deleteChatSubscriptionRoute
Implementation
Endpoint: DELETE /subscriptions/:subscriptionId
Access: isAuthenticated() → some(...) → checkIdentityType(...) → ownsSubscription(...) execute in the source order shown here. Exact invocation: isAuthenticated(), some( checkIdentityType(['admin']), ownsSubscription(['params', 'requestParams', 'subscriptionId']) ),.
Request: deleteChatSubscriptionSchema validates path parameters: Required subscriptionId.
Pipeline: deleteChatSubscription → deleteChatSubscriptionTerminator.
Success: Empty 204 response.
Failure: Authentication and authorization failures follow the linked validators before the handler pipeline. Pipeline failures follow the linked handler/block contracts and shared error middleware; this route adds no separate inline error mapping.View complete source