This documentation outlines the RESTful endpoints, WebSocket events, and internal gRPC definitions for the Lynk platform.
Base URL: Varies per service (via Load Balancer/Gateway in production, mapped ports in Dev).
Headers: Unless specified as Public, all endpoints require the following header:
Authorization: Bearer <access_token>Common Response Codes:
200 OK- Success201 Created- Resource created successfully400 Bad Request- Validation error401 Unauthorized- Invalid or expired token403 Forbidden- Insufficient permissions (e.g., Non-Admin trying to kick user)404 Not Found- Resource does not exist429 Too Many Requests- Rate limit exceeded
Port: 8081
Handles user registration, login, and session management.
POST /api/v1/auth/register (Public)
Initiates user registration. Sends an OTP via SMS.
Body:
{
"firstName": "John",
"lastName": "Doe",
"phoneNumber": "+1234567890",
"mfa": true
}Response:
200 OK:{"type": "otp"}(OTP sent)200 OK:{"type": "mfa", "qrCode": "base64..."}(If MFA enabled)
GET /api/v1/auth/register/{phoneNumber}/{otp} (Public)
Verifies the SMS OTP to complete registration.
Response:
{
"type": "token",
"accessToken": "eyJhbG...",
"refreshToken": "eyJhbG..."
}POST /api/v1/auth/login (Public)
Login via Phone Number. May trigger OTP or require TOTP.
Body:
{
"phoneNumber": "+1234567890",
"totp": "123456"
}Response:
200 OK:{"accessToken": "...", "refreshToken": "..."}403 Forbidden:{"message": "OTP Sent..."}(OTP triggered, user needs to wait/verify)400 Bad Request:{"message": "TOTP required"}
POST /api/v1/token/refresh
Refreshes an expired access token using a valid refresh token.
Headers:
Authorization: Bearer <refresh_token>
POST /api/v1/auth/logout
Invalidates the current session.
Port: 8085
Manages user profiles, blocking logic, and 1:1 conversation metadata.
GET /users/me: Get current user details.GET /users/{userId}: Get public profile of another user.GET /users/search?username=john&page=0&size=20: Search users.PATCH /users/me: Update profile.- Params:
username,bio,profile(avatar URL).
- Params:
POST /conversation: Initialize a conversation.- Body:
{"userId": "uuid-of-recipient"}
- Body:
GET /conversation: List all active 1:1 conversations.DELETE /conversation/{recipientId}: Delete a conversation.PATCH /conversation/block/{userId}: Block a user.PATCH /conversation/unblock/{userId}: Unblock a user.GET /users/me/blocked: List blocked users.
Port: 8086
Handles Group metadata, membership logic, roles, and moderation (bans/kicks).
POST /rooms: Create a new room.- Body:
{ "idempotencyKey": "uuid", "roomName": "Tech Talk", "maxSize": 100, "visibility": "PUBLIC" }PATCH /rooms: Update room details (Admin/Mod).DELETE /rooms/{roomId}: Delete a room (Admin).
POST /memberships/{roomId}: Join a public room.POST /memberships/leave/{roomId}: Leave a room.POST /memberships/kick/{userId}/{roomId}: Kick a user (Admin/Mod).GET /memberships/{roomId}/members: List all members in a room.GET /memberships/my-rooms: List rooms the current user has joined.
POST /ban/{roomId}/{userId}: Ban a user from the room (Mod+).DELETE /ban/{roomId}/{userId}: Unban a user (Mod+).
Port: 8082
Handles real-time chat persistence (Cassandra), WebSocket connections, and online status.
GET /api/v1/rooms/{roomId}/messages: Get chat history.- Params:
start(Instant),end(Instant).
- Params:
POST /api/v1/rooms/{roomId}/messages: Send a message via REST (Alternative to WS).- Body:
{"content": "Hello", "replyToMessageId": "uuid"}
- Body:
POST /api/v1/rooms: Create chat room bucket.GET /api/v1/rooms: Get user's chat rooms.POST /api/v1/rooms/{roomId}/members: Add member to chat bucket.
1. 1:1 Chat
- Endpoint:
ws://localhost:8082/ws/chat - Auth: Bearer Token in Handshake headers.
- Payload (Send):
{ "recipientId": "uuid", "content": "Hello world", "replyToMessageId": "uuid (optional)" }
2. Group Chat
- Endpoint:
ws://localhost:8082/ws/room - Payload (Send):
{ "roomId": "uuid", "content": "Hello Team", "replyToMessageId": "uuid (optional)" }
Port: 8084
Handles secure file uploads to S3.
POST /api/v1/media/user-profile: Upload user avatar.- Content-Type:
multipart/form-data - Key:
file
- Content-Type:
POST /api/v1/media/room-profile: Upload room avatar.- Pre-requisite: Requires a valid session/cache entry validating the user is the room admin.
GET /api/v1/media/{fileName}: Download/Stream file.PUT /api/v1/media/{fileName}: Update existing file.DELETE /api/v1/media/{fileName}: Delete file (Admin only).
Port: 8083
Manages FCM tokens and push notifications.
POST /api/v1/token/{fcmToken}: Register a device's FCM token for the current user.POST /api/v1/subscribe/{topic}: Subscribe the current user's device to a specific notification topic (e.g.,chat_room_123).
Port: 9090 (User Service)
Used for inter-service communication (primarily Message Service checking validation rules).
Service: ValidationService
validateConversation(ConversationValidationRequest): Checks if a sender/recipient pair is valid (exists and not blocked).- Returns:
OK,NOT_FOUND,SENDER_BLOCKED_RECIPIENT,RECIPIENT_BLOCKED_SENDER.
- Returns: