Overview
Creates a new user account in Noteverse. This endpoint registers a user with email, username, and password credentials. Upon successful registration, the user receives a verification token that must be used to verify their email address.
Users must verify their email address using the verification token before gaining full access to the platform. The verification token is returned in the response and should be sent to the user’s email.
Request
Body Parameters
The user’s email address. Must be unique in the system.
The user’s display name (stored as username in the database).
The user’s password. Will be hashed using bcrypt with 10 salt rounds before storage.
Response
The registered user’s email address.
The hashed password (bcrypt hash).
A randomly generated 32-byte hex token used for email verification. This token should be sent to the user’s email and used with the verify endpoint.
Status Codes
- 201 Created - User successfully created
- 400 Bad Request - User already exists or error during creation
Examples
curl -X POST https://your-domain.com/api/auth/signup \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"name": "Alice Johnson",
"password": "SecurePass123!"
}'
Success Response (201)
{
"email": "[email protected]",
"password": "$2b$10$rZ3qJ7X9Y2K8wL5mN3pQ1O",
"verificationToken": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
}
Error Response (400)
{
"error": "User already exists. Please Log In or try with another account."
}
Error Cases
Duplicate Email: If a user with the provided email already exists, the request will fail with a 400 status code and an error message indicating the user should log in or use a different email.
Common Error Scenarios
-
User Already Exists
- Status: 400
- Message: “User already exists. Please Log In or try with another account.”
- Cause: Email is already registered in the system
-
User Creation Failed
- Status: 400
- Message: “Error signing in”
- Cause: Database error or invalid data during user creation
-
Invalid Request Body
- Status: 500 (Internal Server Error)
- Cause: Missing required fields (email, name, or password)
Implementation Details
- Password Hashing: Passwords are hashed using bcrypt with 10 salt rounds
- Auth Token: A 64-byte random hex token is automatically generated for API authentication
- Verification Token: A 32-byte random hex token is generated for email verification
- Email Verified: Defaults to
false until the user verifies their email via the verify endpoint
Next Steps
After successful registration:
- Send the
verificationToken to the user’s email
- Direct the user to verify their email using the Verify Email endpoint
- Once verified, the user can sign in to access their account