Endpoint
Authentication required
This endpoint requires an authenticated user session via Clerk. Requests must include valid Clerk session credentials.Request parameters
This endpoint does not require a request body. User information is automatically extracted from the authenticated session.Response
On success, returns a Liveblocks authentication token in the response body. The exact format depends on the Liveblocks SDK but typically includes:- Authentication token for WebSocket connections
- User identity information
- Token expiration time
User identification
The API automatically identifies users with the following information:The user’s primary email address is used as the unique identifier
Additional user information sent to Liveblocks:
name(string): User’s full name from Clerk, or “Unnamed User” if not setimageUrl(string): User’s profile image URL from Clerkcolor(string): Randomly assigned color for user presence indicators
Color assignment
Each authentication request assigns a random color to the user from a predefined palette:Error responses
User not found (404)
Returned when no authenticated user is found in the session.Email not set (404)
Returned when the authenticated user does not have a primary email address configured.Example request
Integration with Liveblocks
This endpoint is designed to work with the Liveblocks real-time collaboration platform. The authentication flow typically works as follows:- User authenticates with Clerk
- Client calls
/api/liveblocks-authto obtain a Liveblocks token - Client uses the token to establish a WebSocket connection to Liveblocks
- User can now participate in real-time collaboration features
Security considerations
- Tokens are scoped to the authenticated user’s email address
- Each request generates a fresh authentication token
- The endpoint requires a valid Clerk session
- User information is pulled directly from Clerk (cannot be spoofed)
Environment variables
This endpoint requires the following environment variable:LIVEBLOCKS_SECRET_KEY- Secret key for authenticating with the Liveblocks API