Skip to main content

POST /api/auth/register

Creates a new user account and sends a verification email. The registration process validates role-specific requirements and creates associated resources (e.g., stores for store employees).

Request body

name
string
required
User’s full name (minimum 2 characters)
email
string
required
User’s email address. Students and faculty must use a christuniversity.in email (subdomains allowed)
password
string
required
Password must meet the following requirements:
  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one digit
confirmPassword
string
required
Must match the password field
role
string
required
User role. Must be one of: student, faculty, or store_employee
registerNumber
string
Student registration number. Required when role is student
employeeId
string
Employee identification number. Required when role is faculty or store_employee
phoneNumber
string
Indian mobile number (10 digits starting with 6-9). Required when role is store_employee
storeName
string
Name of the store. Required when role is store_employee
storeUpiId
string
Store UPI ID for payments (format: username@provider). Required when role is store_employee

Response

success
boolean
Indicates if the registration was successful
message
string
Human-readable response message
data
object
The created user object (sanitized)

Status codes

  • 201 - Registration successful, verification email sent
  • 400 - Invalid request data or email domain mismatch
  • 409 - Email already registered
  • 500 - Internal server error
After registration, users must verify their email before logging in. A verification email is sent automatically with a unique token.
Students and faculty must use a christuniversity.in email address. Store employees can use any valid email.

Examples

curl -X POST https://api.campusbite.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "SecurePass123",
    "confirmPassword": "SecurePass123",
    "role": "student",
    "registerNumber": "2021CS001"
  }'

Success response (201)

{
  "success": true,
  "message": "Registration successful. Please check your email to verify your account.",
  "data": {
    "_id": "507f1f77bcf86cd799439011",
    "name": "John Doe",
    "email": "[email protected]",
    "role": "student",
    "register_number": "2021CS001",
    "employee_id": null,
    "phone_number": null,
    "is_email_verified": false,
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-15T10:30:00.000Z"
  }
}

Error response (409)

{
  "success": false,
  "message": "An account with this email already exists."
}

Error response (400)

{
  "success": false,
  "message": "Student and faculty accounts must use a christuniversity.in email (subdomains are allowed)."
}

Build docs developers (and LLMs) love