This endpoint completes the two-step registration flow. After callingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dev0302/nextjs-project-1/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/send-otp and receiving a 6-digit OTP by email, submit all registration fields here. The server validates every field, confirms the email is not already taken, verifies the OTP against the most recent OTP document in MongoDB, bcrypt-hashes the password, and persists the new user record. On success it returns the newly created user’s safe (non-sensitive) profile data.
Method and URL
Authentication
None required. This endpoint is publicly accessible.Request Body
The desired display name for the account. Must be between 2 and 20 characters and may only contain letters, numbers, and underscores (
/^[a-zA-Z0-9_]+$/).A valid, unique email address. Must match the address that was passed to
POST /api/send-otp to receive the OTP.The account password. Minimum 3 characters. The value is never stored in plain text — it is hashed with bcrypt (salt rounds: 10) before being written to the database.
The 6-digit numeric OTP delivered by
POST /api/send-otp. The server fetches the most recent OTP document for the given email and performs a strict string comparison. The OTP expires after 5 minutes.Example Request
Response Fields
true when the account was created successfully, false on any error.A human-readable description of the outcome (e.g.,
"User Registered Successfully").The MongoDB
ObjectId of the newly created user document, serialised as a plain string.The username chosen during registration.
The verified email address associated with the account.
Always
true for accounts created through this endpoint — OTP verification is a prerequisite.Always
true immediately after registration. Users can update this preference later.An empty array at the point of creation. Populated as anonymous messages are received.
HTTP Status Codes
| Status | Meaning |
|---|---|
201 | Account created successfully. |
400 | One or more required fields are missing from the request body. |
401 | The supplied OTP does not match the most recent OTP for this email, or no OTP document exists. |
409 | An account with this email address already exists. |
500 | Unexpected server error (database failure, bcrypt error, etc.). |