openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: CipherChat E2EE messaging API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: users description: User management - name: chats description: Chat management - name: messages description: Messages paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/register: post: operationId: register tags: [auth] summary: Register a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterInput" responses: "201": description: Registered content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "409": description: Username or email already taken /auth/login: post: operationId: login tags: [auth] summary: Login requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Invalid credentials /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/UserProfile" "401": description: Unauthorized /users/search: get: operationId: searchUsers tags: [users] summary: Search users by username parameters: - name: q in: query required: true schema: type: string responses: "200": description: Users list content: application/json: schema: type: array items: $ref: "#/components/schemas/UserProfile" /users/{userId}: get: operationId: getUserById tags: [users] summary: Get user profile parameters: - name: userId in: path required: true schema: type: integer responses: "200": description: User profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" "404": description: User not found /users/profile: put: operationId: updateProfile tags: [users] summary: Update own profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProfileUpdate" responses: "200": description: Updated profile content: application/json: schema: $ref: "#/components/schemas/UserProfile" /chats: get: operationId: getChats tags: [chats] summary: Get all chats for current user responses: "200": description: Chats list content: application/json: schema: type: array items: $ref: "#/components/schemas/Chat" post: operationId: createChat tags: [chats] summary: Create a new chat requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ChatInput" responses: "201": description: Chat created content: application/json: schema: $ref: "#/components/schemas/Chat" /chats/{chatId}: get: operationId: getChatById tags: [chats] summary: Get chat by ID parameters: - name: chatId in: path required: true schema: type: integer responses: "200": description: Chat content: application/json: schema: $ref: "#/components/schemas/Chat" "404": description: Chat not found /chats/{chatId}/messages: get: operationId: getMessages tags: [messages] summary: Get messages for a chat parameters: - name: chatId in: path required: true schema: type: integer responses: "200": description: Messages content: application/json: schema: type: array items: $ref: "#/components/schemas/Message" post: operationId: sendMessage tags: [messages] summary: Send a message parameters: - name: chatId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MessageInput" responses: "201": description: Message sent content: application/json: schema: $ref: "#/components/schemas/Message" /messages/{messageId}: patch: operationId: editMessage tags: [messages] summary: Edit a message parameters: - name: messageId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MessageUpdate" responses: "200": description: Edited message content: application/json: schema: $ref: "#/components/schemas/Message" delete: operationId: deleteMessage tags: [messages] summary: Delete a message parameters: - name: messageId in: path required: true schema: type: integer responses: "204": description: Deleted /messages/{messageId}/read: post: operationId: markMessageRead tags: [messages] summary: Mark message as read parameters: - name: messageId in: path required: true schema: type: integer responses: "200": description: Marked read /chats/{chatId}/members: post: operationId: addChatMember tags: [chats] summary: Add member to group chat parameters: - name: chatId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MemberInput" responses: "200": description: Member added /chats/{chatId}/members/{userId}: delete: operationId: removeChatMember tags: [chats] summary: Remove member from group chat parameters: - name: chatId in: path required: true schema: type: integer - name: userId in: path required: true schema: type: integer responses: "204": description: Member removed /chats/{chatId}/group-key: get: operationId: getGroupKey tags: [chats] summary: Get user's group key for a chat parameters: - name: chatId in: path required: true schema: type: integer responses: "200": description: Group key retrieved content: application/json: schema: $ref: "#/components/schemas/GroupKeyResponse" "404": description: Group key not found /chats/{chatId}/group-keys: post: operationId: saveGroupKeys tags: [chats] summary: Save group keys for chat members parameters: - name: chatId in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GroupKeysInput" responses: "200": description: Group keys saved content: application/json: schema: type: object properties: success: type: boolean required: [success] components: schemas: HealthStatus: type: object properties: status: type: string required: - status RegisterInput: type: object required: [username, email, password, publicKey] properties: username: type: string minLength: 3 email: type: string password: type: string minLength: 8 publicKey: type: string description: Base64-encoded X25519 public key LoginInput: type: object required: [email, password] properties: email: type: string password: type: string AuthResponse: type: object required: [token, user] properties: token: type: string user: $ref: "#/components/schemas/UserProfile" UserProfile: type: object required: [id, username, email, publicKey, createdAt] properties: id: type: integer username: type: string email: type: string publicKey: type: string bio: type: ["string", "null"] profileImage: type: ["string", "null"] isOnline: type: boolean lastSeen: type: ["string", "null"] createdAt: type: string ProfileUpdate: type: object properties: username: type: string bio: type: string profileImage: type: string publicKey: type: string description: Base64-encoded X25519 public key for E2EE Chat: type: object required: [id, type, createdAt, members] properties: id: type: integer type: type: string enum: [direct, group] name: type: ["string", "null"] avatar: type: ["string", "null"] description: type: ["string", "null"] lastMessage: $ref: "#/components/schemas/Message" members: type: array items: $ref: "#/components/schemas/ChatMember" unreadCount: type: integer createdAt: type: string ChatInput: type: object required: [type, memberIds] properties: type: type: string enum: [direct, group] memberIds: type: array items: type: integer name: type: string description: type: string ChatMember: type: object required: [userId, role, user] properties: userId: type: integer role: type: string enum: [admin, member] user: $ref: "#/components/schemas/UserProfile" Message: type: object required: [id, chatId, senderId, encryptedContent, iv, type, createdAt] properties: id: type: integer chatId: type: integer senderId: type: integer encryptedContent: type: string description: Base64-encoded encrypted message iv: type: string description: Base64-encoded nonce/IV type: type: string enum: [text, image, file] status: type: string enum: [sent, delivered, read] replyToId: type: ["integer", "null"] isEdited: type: boolean deletedAt: type: ["string", "null"] reactions: type: array items: $ref: "#/components/schemas/MessageReaction" readBy: type: array items: type: integer sender: $ref: "#/components/schemas/UserProfile" createdAt: type: string updatedAt: type: string MessageInput: type: object required: [encryptedContent, iv] properties: encryptedContent: type: string iv: type: string type: type: string enum: [text, image, file] replyToId: type: integer MessageUpdate: type: object required: [encryptedContent, iv] properties: encryptedContent: type: string iv: type: string MessageReaction: type: object required: [userId, emoji] properties: userId: type: integer emoji: type: string MemberInput: type: object required: [userId] properties: userId: type: integer GroupKeyResponse: type: object required: [chatId, userId, encryptedKey, iv] properties: chatId: type: integer userId: type: integer encryptedKey: type: string iv: type: string GroupKeysInput: type: object required: [keys] properties: keys: type: array items: $ref: "#/components/schemas/GroupKeyItem" GroupKeyItem: type: object required: [userId, encryptedKey, iv] properties: userId: type: integer encryptedKey: type: string iv: type: string