POST /api/user/init
Initialize user profile after Supabase authentication. This endpoint is idempotent - if the user already exists, it returns the existing profile without creating a duplicate.Authentication
Requires valid JWT token from Supabase Auth in theAuthorization header.
Request Body
User’s display name. Can be derived from OAuth provider (e.g., Google full name) or email username.
Request Example
Response
User’s unique identifier (matches Supabase auth.users ID)
User’s email address from Supabase Auth
User’s display name
Total number of emails generated by the user
Total number of templates created by the user
Whether the user has completed onboarding flow
User’s default email template with placeholders
Timestamp when user profile was created
Response Example
Error Responses
401 Unauthorized
Invalid or missing JWT token
422 Validation Error
Invalid request body format
500 Internal Server Error
Database or system error
GET /api/user/profile
Retrieve the current user’s profile. Requires that the user has been initialized via POST/api/user/init.
Authentication
Requires valid JWT token from Supabase Auth in theAuthorization header.
Request Example
Response
Returns the sameUserResponse schema as the /init endpoint with current user data.
Response Example
Error Responses
401 Unauthorized
Invalid or missing JWT token
404 Not Found
User profile not initialized. Call POST
/api/user/init first.PATCH /api/user/onboarding
Mark the current user as having completed the onboarding flow. This is used to track whether the user has seen the initial setup wizard.Authentication
Requires valid JWT token from Supabase Auth in theAuthorization header.
Request Example
Response
Returns the updatedUserResponse with onboarded set to true.
Response Example
PATCH /api/user/template
Update the user’s default email template. This template is used as the default for batch email generation.Authentication
Requires valid JWT token from Supabase Auth in theAuthorization header.
Request Body
Email template text with variable placeholders (e.g.,
{{professor_name}}, {{research_area}}). Must be between 1-10,000 characters and cannot be only whitespace.Request Example
Response
Returns the updatedUserResponse with the new template.
Response Example
Error Responses
422 Validation Error
Template validation failed (empty, too short/long, or whitespace only)
